@galacean/effects 1.2.2 → 1.2.4
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/index.js +50 -24
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +50 -24
- package/dist/index.mjs.map +1 -1
- package/dist/player.d.ts +1 -1
- package/dist/weapp.js +49 -23
- package/dist/weapp.js.map +1 -1
- package/dist/weapp.mjs +49 -23
- package/dist/weapp.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.min.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* Description: Galacean Effects runtime player for the web
|
|
4
4
|
* Author: Ant Group CO., Ltd.
|
|
5
5
|
* Contributors: 燃然,飂兮,十弦,云垣,茂安,意绮
|
|
6
|
-
* Version: v1.2.
|
|
6
|
+
* Version: v1.2.4
|
|
7
7
|
*/
|
|
8
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ge={})}(this,(function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},i.apply(this,arguments)};function n(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?n(t.value):function(t){return t instanceof r?t:new r((function(e){e(t)}))}(t.value).then(s,a)}u((i=i.apply(t,e||[])).next())}))}function o(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function u(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var l=6,c="editor",h="none",f={"Filter not imported":"https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg","Item duration can't be less than 0":"https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg"};function p(t,e,r){var i;if(void 0===e&&(e="webgl"),"webgl2"===e&&((i=t.getContext("webgl2",r))||console.debug("WebGL2 context retrieval failed, falling back to WebGL context.")),i&&"webgl"!==e||(i=t.getContext("webgl",r)),!i)throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");return i}function d(t){var e=this,r=t.getExtension("EXT_disjoint_timer_query_webgl2");if(r){var i=t.createQuery(),s=function(){return n(e,void 0,void 0,(function(){return o(this,(function(e){return[2,new Promise((function(e,n){if(i){var o=t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE),a=t.getParameter(r.GPU_DISJOINT_EXT);if(o&&!a){var u=t.getQueryParameter(i,t.QUERY_RESULT);e(u/1e3/1e3)}(o||a)&&(t.deleteQuery(i),i=null),null!==o&&i&&window.setTimeout((function(){s().then(e).catch}),1)}}))]}))}))};if(!i)return;return{begin:function(){i&&t.beginQuery(r.TIME_ELAPSED_EXT,i)},end:function(){t.endQuery(r.TIME_ELAPSED_EXT)},getTime:s}}}var m=[],v={};function y(){"function"==typeof WebGL2RenderingContext?x(WebGL2RenderingContext):"undefined"!=typeof WebGLRenderingContext?(x(WebGLRenderingContext),x(WebGLRenderingContext.prototype)):m.push("iOS16 lockdown mode, WebGL Constants not in global"),m.length||"HALF_FLOAT"in v||(v.HALF_FLOAT=5131)}function g(t){return"undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name}function x(t){for(var e in t)/^[A-Z_]/.test(e)&&(v[e]=t[e])}m.length||y();var T,E,S,b,A,_,C,R,O,w,M,L,I={},P={};function F(t,e,r){t in I&&console.error("Filter ".concat(t," registered twice.")),I[t]=e,P[t]=r}function N(t){Object.keys(t).forEach((function(e){var r=a(t[e],2);F(e,r[0],r[1])}))}function V(t){var e=P[t.name];if(!e)throw Error("Filter ".concat(t.name," not imported, see ").concat(f["Filter not imported"]));return e(t)}function D(t,e){var r=I[t.name];if(!r)throw Error("Filter ".concat(t.name," not imported, see ").concat(f["Filter not imported"]));var i=r(t,e);return i.passSplitOptions||(i.passSplitOptions={attachments:[{texture:{format:v.RGBA}}]}),i}function z(t,e){return t.includes(e)||t.push(e),t}function B(t,e){var r=t.indexOf(e);return r>-1&&t.splice(r,1),t}function U(t,e,r,i){if(void 0===i&&(i=!1),!t.includes(e)&&(t.push(e),1!==t.length)){var n=t.length-1;if(n){var o=t[n];if(i)for(;t[n-1][r]<o[r]&&(t[n]=t[n-1],0!=--n););else for(;t[n-1][r]>o[r]&&(t[n]=t[n-1],0!=--n););t[n]=o}}}function k(t,e,r,i){if(void 0===r&&(r=1),t.buffer.byteLength<t.BYTES_PER_ELEMENT*e){var n=Math.ceil(e*r);isNaN(i)||(n=Math.min(n,i));var o=new ArrayBuffer(t.BYTES_PER_ELEMENT*n),s=new t.constructor(o);return s.set(t),s}return t}function G(t,e){var r=[0,0,0,0];if(ke(t)){t=t.replace(/[\s\t\r\n]/g,"");var i=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(i){var n=+i[4];r=[+i[1],+i[2],+i[3],isNaN(n)?255:255*n]}else/^#[a-f\d]{3}$/i.test(t)?r=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(r=[parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16),255]||[0,0,0,255])}else t instanceof Array&&(r=[t[0],t[1],t[2],isNaN(t[3])?255:t[3]]);if(e)for(var o=0;o<4;o++)r[o]/=255;return r}function X(t,e,r){if(t.length){for(var i=void 0,n=1;n<=t.length-1;n++){var o=t[n-1],s=t[n];if(o.stop<=e&&e<=s.stop){i=Y(o.color,s.color,(e-o.stop)/(s.stop-o.stop));break}}return i||(i=t[t.length-1].color),r?i.map((function(t){return t/255})):i}return[0,0,0,0]}function H(t){var e=[];if(t instanceof Array?t.forEach((function(t){var r=a(t,5),i=r[0],n=r[1],o=r[2],s=r[3],u=r[4];e.push({stop:j(i),color:[n,o,s,u]})})):Object.keys(t).forEach((function(r){var i=G(t[r]);e.push({stop:j(r),color:i})})),(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 r=e[e.length-1];1!==r.stop&&e.push({stop:1,color:r.color.slice()})}return e}function Y(t,e,r,i){var n=[],o=1-r;if(i)for(var s=0;s<4;s++)n[s]=t[s]*o+e[s]*r;else{for(s=0;s<3;s++)n[s]=Math.round(Math.sqrt(t[s]*t[s]*o+e[s]*e[s]*r));n[3]=Math.round(t[3]*o+e[3]*r)}return n}function j(t){var e=/^(-)?([\d+.]+)%$/.exec(t);return e?+e[2]/100*(e[1]?-1:1):+t}function W(){if("object"==typeof screen&&"object"==typeof document){var t=Math.max(document.documentElement.clientWidth,window.innerWidth||0),e=screen.width/t;return Math.min(2*e,2)}return 1}function Z(){return/\b[Aa]ndroid\b/.test(navigator.userAgent)}function q(){return Z()||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent)}function K(t){ke(t)&&(t=G(t));for(var e=t,r={width:1,height:1,data:new Uint8Array(4)},i=r.data,n=0;n<4;n++)i[n]=e[n];return r}function Q(t){var e=128,r={width:e,height:1,data:new Uint8Array(512)},i=r.data,n=H(t);if(n.length){i.set(n[0].color,0);for(var o=1;o<127;o++){for(var s=o/e,a=void 0,u=void 0,l=0;l<n.length&&(a=n[l],u=n[l+1],!(a.stop<=s&&u.stop>s));l++);var c=Y(a.color,u.color,(s-a.stop)/(u.stop-a.stop));i.set(c,4*o)}i.set(n[n.length-1].color,508)}return r}function J(e,r){void 0===r&&(r=t.OrderType.ascending);var i=e.length;if(i<=1||r===t.OrderType.none)return e;if(i<=30){for(var n=1;n<i;n++)tt(e,n,r);return e}return et(e,r)}function $(e,r,i){return void 0===i&&(i=t.OrderType.ascending),e.includes(r)?e:(e.push(r),1===e.length||i!==t.OrderType.none&&tt(e,e.length-1,i),e)}function tt(e,r,i){var n=e[r];if(i!==t.OrderType.ascending)for(;r>=1&&e[r-1].priority<n.priority&&(e[r]=e[r-1],0!=--r););else for(;r>=1&&e[r-1].priority>n.priority&&(e[r]=e[r-1],0!=--r););e[r]=n}function et(e,r,i,n){var o,s;if(void 0===i&&(i=0),void 0===n&&(n=e.length-1),i>=n)return e;for(var u=e[i],l=i,c=n;l<c;){if(r===t.OrderType.ascending){for(;e[c].priority>u.priority&&c>=l;)c--;for(;e[l].priority<=u.priority&&l<c;)l++}else{for(;e[c].priority<u.priority&&c>=l;)c--;for(;e[l].priority>=u.priority&&l<c;)l++}o=a([e[c],e[l]],2),e[l]=o[0],e[c]=o[1]}return s=a([e[l],e[i]],2),e[i]=s[0],e[l]=s[1],et(e,r,i,l-1),et(e,r,c+1,n),e}function rt(t,e){if(void 0===e&&(e="item doesn't exist"),null==t)throw new Error(e)}t.OrderType=void 0,(T=t.OrderType||(t.OrderType={}))[T.none=1]="none",T[T.ascending=2]="ascending",T[T.descending=3]="descending",function(t){t.S="S",t.APlus="A+",t.A="A",t.BPlus="B+",t.B="B"}(E||(E={})),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"}(S||(S={})),function(t){t[t.DOUBLE=1032]="DOUBLE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK"}(b||(b={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(A||(A={})),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"}(_||(_={})),function(t){t[t.GYROSCOPE=0]="GYROSCOPE",t[t.SPINE=1]="SPINE"}(C||(C={})),function(t){t[t.CLICK=0]="CLICK",t[t.MESSAGE=1]="MESSAGE",t[t.DRAG=2]="DRAG"}(R||(R={})),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"}(O||(O={})),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.filter="8",t.spine="spine",t.mesh="mesh",t.tree="tree",t.text="text",t.light="light",t.skybox="skybox"}(w||(w={})),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"}(M||(M={})),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"}(L||(L={}));var it,nt,ot,st,at,ut,lt,ct;!function(t){t[t.portrait=1]="portrait",t[t.landscape=0]="landscape"}(it||(it={})),function(t){t[t.destroy=0]="destroy",t[t.pause=1]="pause",t[t.restart=5]="restart",t[t.forward=2]="forward",t[t.pause_destroy=3]="pause_destroy"}(nt||(nt={})),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"}(ot||(ot={})),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"}(st||(st={})),function(t){t[t.destroy=0]="destroy",t[t.loop=5]="loop",t[t.freeze=4]="freeze"}(at||(at={})),function(t){t[t.destroyChildren=6]="destroyChildren"}(ut||(ut={})),function(t){t[t.none=0]="none",t[t.removeParticle=1]="removeParticle"}(lt||(lt={})),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"}(ct||(ct={}));var ht,ft,pt,dt,mt,vt,yt,gt,xt;!function(t){t[t.box=2]="box",t[t.sphere=3]="sphere"}(ht||(ht={})),function(t){t.unlit="unlit",t.pbr="pbr",t.hair="hair"}(ft||(ft={})),function(t){t[t.opaque=100]="opaque",t[t.masked=101]="masked",t[t.translucent=102]="translucent",t[t.additive=103]="additive"}(pt||(pt={})),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"}(dt||(dt={})),function(t){t[t.display=0]="display",t[t.clip=1]="clip",t[t.ellipsis=2]="ellipsis"}(mt||(mt={})),function(t){t[t.top=0]="top",t[t.middle=1]="middle",t[t.bottom=2]="bottom"}(vt||(vt={})),function(t){t[t.left=0]="left",t[t.middle=1]="middle",t[t.right=2]="right"}(yt||(yt={})),function(t){t.normal="normal",t.bold="bold",t.lighter="lighter"}(gt||(gt={})),function(t){t.normal="normal",t.italic="italic",t.oblique="oblique"}(xt||(xt={}));var Tt=Object.freeze({__proto__:null,get BezierKeyframeType(){return st},get BlendingMode(){return S},BloomFilterThresholdAvgColor:0,CAMERA_CLIP_MODE_NORMAL:0,CAMERA_CLIP_MODE_VERTICAL:1,get CameraClipMode(){return it},get CompositionEndBehavior(){return nt},END_BEHAVIOR_DESTROY:0,END_BEHAVIOR_DESTROY_CHILDREN:6,END_BEHAVIOR_FORWARD:2,END_BEHAVIOR_FREEZE:4,END_BEHAVIOR_PAUSE:1,END_BEHAVIOR_PAUSE_AND_DESTROY:3,END_BEHAVIOR_RESTART:5,get FontStyle(){return xt},get InteractBehavior(){return O},get InteractType(){return R},get ItemEndBehavior(){return at},get ItemType(){return w},MESSAGE_ITEM_PHRASE_BEGIN:2,MESSAGE_ITEM_PHRASE_END:1,get MaskMode(){return A},get MaterialBlending(){return pt},get MaterialType(){return ft},get ModelBoundingType(){return ht},get ParentItemEndBehavior(){return ut},get ParticleInteractionBehavior(){return lt},get ParticleOrigin(){return L},get PluginType(){return C},get RenderLevel(){return E},get RenderMode(){return M},get RenderMode3D(){return dt},get ShapeArcMode(){return ct},get ShapeType(){return _},get SideMode(){return b},get TextAlignment(){return yt},get TextBaseline(){return vt},get TextOverflow(){return mt},get TextWeight(){return gt},get ValueType(){return ot}}),Et=2*Math.PI,St=Math.PI/180,bt=180/Math.PI,At=1e-6;function _t(t,e){return Math.abs(t-e)<At||t===1/0&&e===1/0||t===-1/0&&e===-1/0}var Ct=function(t,e,r){return(1-r)*t+r*e};function Rt(t,e,r){var i=isNaN(e)?-1/0:e,n=isNaN(r)?1/0:r,o=Math.min(i,n),s=Math.max(i,n);return Math.min(Math.max(t,o),s)}var Ot,wt=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.set=function(t,e){return this.x=t,this.y=e,this},t.prototype.setZero=function(){return this.x=0,this.y=0,this},t.prototype.setFromNumber=function(t){return this.x=t,this.y=t,this},t.prototype.setFromArray=function(t,e){var r,i;return void 0===e&&(e=0),this.x=null!==(r=t[e])&&void 0!==r?r:0,this.y=null!==(i=t[e+1])&&void 0!==i?i:0,this},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t):t instanceof Array?(this.x+=t[0],this.y+=t[1]):(this.x+=t.x,this.y+=t.y),this},t.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},t.prototype.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t):t instanceof Array?(this.x-=t[0],this.y-=t[1]):(this.x-=t.x,this.y-=t.y),this},t.prototype.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},t.prototype.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t):t instanceof Array?(this.x*=t[0],this.y*=t[1]):(this.x*=t.x,this.y*=t.y),this},t.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this},t.prototype.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t):t instanceof Array?(this.x/=t[0],this.y/=t[1]):(this.x/=t.x,this.y/=t.y),this},t.prototype.scale=function(t){return this.x*=t,this.y*=t,this},t.prototype.sum=function(){return this.x+this.y},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},t.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},t.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},t.prototype.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},t.prototype.normalize=function(){return this.divide(this.length()||1)},t.prototype.setLength=function(t){return this.normalize().multiply(t)},t.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},t.prototype.lerpVectors=function(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y},t.prototype.cross=function(t){return this.x*t.y-this.y*t.x},t.prototype.distance=function(t){var e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)},t.prototype.distanceSquared=function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},t.prototype.equals=function(t){return this.x===t.x&&this.y===t.y},t.prototype.isZero=function(){var t=At,e=(this,this.x),r=this.y;return Math.abs(e)<=t&&Math.abs(r)<=t},t.prototype.toArray=function(){return[this.x,this.y]},t.prototype.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y},t.prototype.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,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.ONE=new t(1,1),t.ZERO=new t(0,0),t}(),Mt=function(){function t(t,e,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),this.x=t,this.y=e,this.z=r}return t.prototype.set=function(t,e,r){return this.x=t,this.y=e,this.z=r,this},t.prototype.setZero=function(){return this.x=0,this.y=0,this.z=0,this},t.prototype.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this},t.prototype.setFromArray=function(t,e){var r,i,n;return void 0===e&&(e=0),this.x=null!==(r=t[e])&&void 0!==r?r:0,this.y=null!==(i=t[e+1])&&void 0!==i?i:0,this.z=null!==(n=t[e+2])&&void 0!==n?n:0,this},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t):t instanceof 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},t.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},t.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},t.prototype.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t):t instanceof 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},t.prototype.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},t.prototype.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t):t instanceof 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},t.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},t.prototype.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t):t instanceof 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},t.prototype.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.sum=function(){return this.x+this.y+this.z},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},t.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},t.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},t.prototype.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},t.prototype.normalize=function(){return this.divide(this.length()||1)},t.prototype.setLength=function(t){return this.normalize().multiply(t)},t.prototype.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},t.prototype.lerpVectors=function(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},t.prototype.cross=function(t){return this.crossVectors(this,t)},t.prototype.crossVectors=function(t,e){var r=t.x,i=t.y,n=t.z,o=e.x,s=e.y,a=e.z;return this.x=i*a-n*s,this.y=n*o-r*a,this.z=r*s-i*o,this},t.prototype.reflect=function(t){return this.subtract(t.clone().multiply(2*this.dot(t)))},t.prototype.distance=function(t){return Math.sqrt(this.distanceSquared(t))},t.prototype.distanceSquared=function(t){var e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},t.prototype.isZero=function(){var t,e=At,r=(t=this).x,i=t.y,n=t.z;return Math.abs(r)<=e&&Math.abs(i)<=e&&Math.abs(n)<=e},t.prototype.toArray=function(){return[this.x,this.y,this.z]},t.prototype.toVector2=function(){return new wt(this.x,this.y)},t.prototype.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z},t.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},t.prototype.applyEuler=function(t,e){return t.rotateVector3(this,e)},t.prototype.applyQuaternion=function(t,e){return t.rotateVector3(this,e)},t.prototype.applyMatrix=function(t,e){return t.transformPoint(this,e)},t.prototype.applyNormalMatrix=function(t,e){return t.transformNormal(this,e)},t.prototype.applyProjectionMatrix=function(t,e){return t.projectPoint(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.X=new t(1,0,0),t.Y=new t(0,1,0),t.Z=new t(0,0,1),t.ONE=new t(1,1,1),t.ZERO=new t(0,0,0),t}(),Lt=function(){function t(t,e,r,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=r,this.w=i}return t.prototype.set=function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},t.prototype.setFromEuler=function(t){return t.toQuaternion(this),this},t.prototype.setFromAxisAngle=function(e,r){var i=r/2,n=Math.sin(i),o=t.tempVec0;return o.copyFrom(e).normalize(),this.x=o.x*n,this.y=o.y*n,this.z=o.z*n,this.w=Math.cos(i),this},t.prototype.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},t.prototype.setFromRotationMatrix=function(t){var e=t.elements,r=e[0],i=e[4],n=e[8],o=e[1],s=e[5],a=e[9],u=e[2],l=e[6],c=e[10],h=r+s+c;if(h>0){var f=.5/Math.sqrt(h+1);this.w=.25/f,this.x=(l-a)*f,this.y=(n-u)*f,this.z=(o-i)*f}else if(r>s&&r>c){f=2*Math.sqrt(1+r-s-c);this.w=(l-a)/f,this.x=.25*f,this.y=(i+o)/f,this.z=(n+u)/f,this.negate()}else if(s>c){f=2*Math.sqrt(1+s-r-c);this.w=(n-u)/f,this.x=(i+o)/f,this.y=.25*f,this.z=(a+l)/f,this.negate()}else{f=2*Math.sqrt(1+c-r-s);this.w=(o-i)/f,this.x=(n+u)/f,this.y=(a+l)/f,this.z=.25*f,this.negate()}return this},t.prototype.setFromUnitVectors=function(t,e){var r=t.dot(e)+1;return r<Number.EPSILON?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this.x=-t.y,this.y=t.x,this.z=0,this.w=r):(this.x=0,this.y=-t.z,this.z=t.y,this.w=r)):(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=r),this.normalize()},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.angleTo=function(t){return 2*Math.acos(Math.abs(Rt(this.dot(t),-1,1)))},t.prototype.rotateTowards=function(t,e){var r=this.angleTo(t);if(0===r)return this;var i=Math.min(1,e/r);return this.slerp(t,i),this},t.prototype.identity=function(){return this.set(0,0,0,1)},t.prototype.invert=function(){return this.conjugate()},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},t.prototype.conjugate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.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},t.prototype.multiply=function(t){return this.multiplyQuaternions(this,t)},t.prototype.premultiply=function(t){return this.multiplyQuaternions(t,this)},t.prototype.multiplyQuaternions=function(t,e){var r=t.x,i=t.y,n=t.z,o=t.w,s=e.x,a=e.y,u=e.z,l=e.w;return this.x=r*l+o*s+i*u-n*a,this.y=i*l+o*a+n*s-r*u,this.z=n*l+o*u+r*a-i*s,this.w=o*l-r*s-i*a-n*u,this},t.prototype.slerp=function(t,e){var r;if(0===e)return this;if(1===e)return this.copyFrom(t);var i=(r=this).x,n=r.y,o=r.z,s=r.w,a=s*t.w+i*t.x+n*t.y+o*t.z;if(a<0?(this.w=-t.w,this.x=-t.x,this.y=-t.y,this.z=-t.z,a=-a):this.copyFrom(t),a>=1)return this.w=s,this.x=i,this.y=n,this.z=o,this;var u=1-a*a;if(u<=Number.EPSILON){var l=1-e;return this.w=l*s+e*this.w,this.x=l*i+e*this.x,this.y=l*n+e*this.y,this.z=l*o+e*this.z,this.normalize(),this}var c=Math.sqrt(u),h=Math.atan2(c,a),f=Math.sin((1-e)*h)/c,p=Math.sin(e*h)/c;return this.w=s*f+this.w*p,this.x=i*f+this.x*p,this.y=n*f+this.y*p,this.z=o*f+this.z*p,this},t.prototype.slerpQuaternions=function(t,e,r){this.copyFrom(t).slerp(e,r)},t.prototype.rotateVector3=function(t,e){var r,i=(r=this).x,n=r.y,o=r.z,s=r.w,a=t.x,u=t.y,l=t.z,c=s*a+n*l-o*u,h=s*u+o*a-i*l,f=s*l+i*u-n*a,p=-i*a-n*u-o*l,d=null!=e?e:t;return d.x=c*s+p*-i+h*-o-f*-n,d.y=h*s+p*-n+f*-i-c*-o,d.z=f*s+p*-o+c*-n-h*-i,d},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},t.prototype.toArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.toVector4=function(t){return t.set(this.x,this.y,this.z,this.w)},t.prototype.toEuler=function(t){return t.setFromQuaternion(this)},t.prototype.toMatrix4=function(t){return t.compose(Mt.ZERO,this,Mt.ONE)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromAxisAngle=function(e,r){return(new t).setFromAxisAngle(e,r)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromRotationMatrix=function(e){return(new t).setFromRotationMatrix(e)},t.fromUnitVectors=function(e,r){return(new t).setFromUnitVectors(e,r)},t.tempVec0=new Mt,t}(),It=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},Pt=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Ft=function(){function t(t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m){void 0===t&&(t=1),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=1),void 0===s&&(s=0),void 0===a&&(a=0),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=1),void 0===h&&(h=0),void 0===f&&(f=0),void 0===p&&(p=0),void 0===d&&(d=0),void 0===m&&(m=1),this.elements=[t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m]}return t.prototype.set=function(t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m){var v=this.elements;return v[0]=t,v[1]=e,v[2]=r,v[3]=i,v[4]=n,v[5]=o,v[6]=s,v[7]=a,v[8]=u,v[9]=l,v[10]=c,v[11]=h,v[12]=f,v[13]=p,v[14]=d,v[15]=m,this},t.prototype.setFromRowMajorData=function(t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=r,v[12]=i,v[1]=n,v[5]=o,v[9]=s,v[13]=a,v[2]=u,v[6]=l,v[10]=c,v[14]=h,v[3]=f,v[7]=p,v[11]=d,v[15]=m,this},t.prototype.setFromColumnVectors=function(t,e,r,i){return this.set(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,r.x,r.y,r.z,r.w,i.x,i.y,i.z,i.w)},t.prototype.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},t.prototype.setFromArray=function(t,e){void 0===e&&(e=0);for(var r=0;r<16;r++)this.elements[r]=t[e+r];return this},t.prototype.setFromScale=function(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1)},t.prototype.setFromTranslation=function(t,e,r){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,t,e,r,1)},t.prototype.setFromRotationX=function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,r,0,0,-r,e,0,0,0,0,1)},t.prototype.setFromRotationY=function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,0,-r,0,0,1,0,0,r,0,e,0,0,0,0,1)},t.prototype.setFromRotationZ=function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,r,0,0,-r,e,0,0,0,0,1,0,0,0,0,1)},t.prototype.setFromRotationAxis=function(e,r){var i=t.tempVec0;i.copyFrom(e).normalize();var n=Math.cos(r),o=Math.sin(r),s=1-n,a=i.x,u=i.y,l=i.z,c=s*a,h=s*u;return this.set(c*a+n,c*u+o*l,c*l-o*u,0,c*u-o*l,h*u+n,h*l+o*a,0,c*l+o*u,h*l-o*a,s*l*l+n,0,0,0,0,1)},t.prototype.setFromEuler=function(t){return t.toMatrix4(this),this},t.prototype.setFromQuaternion=function(t){return this.compose(Mt.ZERO,t,Mt.ONE)},t.prototype.setFromShear=function(t,e,r){return this.set(1,t,t,0,e,1,e,0,r,r,1,0,0,0,0,1)},t.prototype.setFromBasis=function(t,e,r){return this.set(t.x,t.y,t.z,0,e.x,e.y,e.z,0,r.x,r.y,r.z,0,0,0,0,1)},t.prototype.setZero=function(){for(var t=0;t<16;t++)this.elements[t]=0;return this},t.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.prototype.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]},t.prototype.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])},t.prototype.copyFrom=function(t){return this.elements=Pt([],It(t.elements),!1),this},t.prototype.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])},t.prototype.lookAt=function(e,r,i){var n=t.tempVec0,o=t.tempVec1,s=t.tempVec2;s.subtractVectors(e,r),s.normalize(),n.crossVectors(i,s),n.normalize(),o.crossVectors(s,n);var a=this.elements;return a[0]=n.x,a[1]=o.x,a[2]=s.x,a[3]=0,a[4]=n.y,a[5]=o.y,a[6]=s.y,a[7]=0,a[8]=n.z,a[9]=o.z,a[10]=s.z,a[11]=0,a[12]=-n.dot(e),a[13]=-o.dot(e),a[14]=-s.dot(e),a[15]=1,this},t.prototype.addScaledMatrix=function(t,e){for(var r=this.elements,i=t.elements,n=0;n<16;n++)r[n]+=i[n]*e;return this},t.prototype.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)},t.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},t.prototype.multiplyMatrices=function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],s=r[4],a=r[8],u=r[12],l=r[1],c=r[5],h=r[9],f=r[13],p=r[2],d=r[6],m=r[10],v=r[14],y=r[3],g=r[7],x=r[11],T=r[15],E=i[0],S=i[4],b=i[8],A=i[12],_=i[1],C=i[5],R=i[9],O=i[13],w=i[2],M=i[6],L=i[10],I=i[14],P=i[3],F=i[7],N=i[11],V=i[15];return n[0]=o*E+s*_+a*w+u*P,n[4]=o*S+s*C+a*M+u*F,n[8]=o*b+s*R+a*L+u*N,n[12]=o*A+s*O+a*I+u*V,n[1]=l*E+c*_+h*w+f*P,n[5]=l*S+c*C+h*M+f*F,n[9]=l*b+c*R+h*L+f*N,n[13]=l*A+c*O+h*I+f*V,n[2]=p*E+d*_+m*w+v*P,n[6]=p*S+d*C+m*M+v*F,n[10]=p*b+d*R+m*L+v*N,n[14]=p*A+d*O+m*I+v*V,n[3]=y*E+g*_+x*w+T*P,n[7]=y*S+g*C+x*M+T*F,n[11]=y*b+g*R+x*L+T*N,n[15]=y*A+g*O+x*I+T*V,this},t.prototype.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},t.prototype.determinant=function(){var t=this.elements,e=t[0],r=t[4],i=t[8],n=t[12],o=t[1],s=t[5],a=t[9],u=t[13],l=t[2],c=t[6],h=t[10],f=t[14];return t[3]*(+n*a*c-i*u*c-n*s*h+r*u*h+i*s*f-r*a*f)+t[7]*(+e*a*f-e*u*h+n*o*h-i*o*f+i*u*l-n*a*l)+t[11]*(+e*u*c-e*s*f-n*o*c+r*o*f+n*s*l-r*u*l)+t[15]*(-i*s*l-e*a*c+e*s*h+i*o*c-r*o*h+r*a*l)},t.prototype.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},t.prototype.invert=function(){var t=this.elements,e=t[0],r=t[1],i=t[2],n=t[3],o=t[4],s=t[5],a=t[6],u=t[7],l=t[8],c=t[9],h=t[10],f=t[11],p=t[12],d=t[13],m=t[14],v=t[15],y=c*m*u-d*h*u+d*a*f-s*m*f-c*a*v+s*h*v,g=p*h*u-l*m*u-p*a*f+o*m*f+l*a*v-o*h*v,x=l*d*u-p*c*u+p*s*f-o*d*f-l*s*v+o*c*v,T=p*c*a-l*d*a-p*s*h+o*d*h+l*s*m-o*c*m,E=e*y+r*g+i*x+n*T;if(0===E)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var S=1/E;return t[0]=y*S,t[1]=(d*h*n-c*m*n-d*i*f+r*m*f+c*i*v-r*h*v)*S,t[2]=(s*m*n-d*a*n+d*i*u-r*m*u-s*i*v+r*a*v)*S,t[3]=(c*a*n-s*h*n-c*i*u+r*h*u+s*i*f-r*a*f)*S,t[4]=g*S,t[5]=(l*m*n-p*h*n+p*i*f-e*m*f-l*i*v+e*h*v)*S,t[6]=(p*a*n-o*m*n-p*i*u+e*m*u+o*i*v-e*a*v)*S,t[7]=(o*h*n-l*a*n+l*i*u-e*h*u-o*i*f+e*a*f)*S,t[8]=x*S,t[9]=(p*c*n-l*d*n-p*r*f+e*d*f+l*r*v-e*c*v)*S,t[10]=(o*d*n-p*s*n+p*r*u-e*d*u-o*r*v+e*s*v)*S,t[11]=(l*s*n-o*c*n-l*r*u+e*c*u+o*r*f-e*s*f)*S,t[12]=T*S,t[13]=(l*d*i-p*c*i+p*r*h-e*d*h-l*r*m+e*c*m)*S,t[14]=(p*s*i-o*d*i-p*r*a+e*d*a+o*r*m-e*s*m)*S,t[15]=(o*c*i-l*s*i+l*r*a-e*c*a-o*r*h+e*s*h)*S,this},t.prototype.extractBasis=function(t,e,r){var i=this.elements;return t.set(i[0],i[1],i[2]),e.set(i[4],i[5],i[6]),r.set(i[8],i[9],i[10]),this},t.prototype.compose=function(t,e,r,i){void 0===i&&(i=Mt.ZERO);var n=this.elements,o=e.x,s=e.y,a=e.z,u=e.w,l=-i.x,c=-i.y,h=-i.z,f=o+o,p=s+s,d=a+a,m=o*f,v=o*p,y=o*d,g=s*p,x=s*d,T=a*d,E=u*f,S=u*p,b=u*d,A=r.x,_=r.y,C=r.z;return n[0]=(1-(g+T))*A,n[1]=(v+b)*A,n[2]=(y-S)*A,n[3]=0,n[4]=(v-b)*_,n[5]=(1-(m+T))*_,n[6]=(x+E)*_,n[7]=0,n[8]=(y+S)*C,n[9]=(x-E)*C,n[10]=(1-(m+g))*C,n[11]=0,n[12]=l*n[0]+c*n[4]+h*n[8]-l+t.x,n[13]=l*n[1]+c*n[5]+h*n[9]-c+t.y,n[14]=l*n[2]+c*n[6]+h*n[10]-h+t.z,this},t.prototype.decompose=function(e,r,i){var n=t.tempVec0,o=this.elements,s=n.set(o[0],o[1],o[2]).length(),a=n.set(o[4],o[5],o[6]).length(),u=n.set(o[8],o[9],o[10]).length();this.determinant()<0&&(s=-s),e.x=o[12],e.y=o[13],e.z=o[14];var l=t.tempMat0;l.copyFrom(this);var c=1/s,h=1/a,f=1/u;return l.elements[0]*=c,l.elements[1]*=c,l.elements[2]*=c,l.elements[4]*=h,l.elements[5]*=h,l.elements[6]*=h,l.elements[8]*=f,l.elements[9]*=f,l.elements[10]*=f,r.setFromRotationMatrix(l),i.x=s,i.y=a,i.z=u,this},t.prototype.getTranslation=function(t){var e=this.elements;return t.set(e[12],e[13],e[14])},t.prototype.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]))},t.prototype.getTransform=function(){var t=new Mt,e=new Lt,r=new Mt;return this.decompose(t,e,r),{translation:t,rotation:e,scale:r}},t.prototype.orthographic=function(t,e,r,i,n,o){var s=1/(e-t),a=1/(r-i),u=1/(o-n),l=-(e+t)*s,c=-(r+i)*a,h=-(o+n)*u;s*=2,a*=2,u*=-2;var f=this.elements;return f[0]=s,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=a,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=u,f[11]=0,f[12]=l,f[13]=c,f[14]=h,f[15]=1,this},t.prototype.perspective=function(t,e,r,i,n){var o=1/Math.tan(.5*t),s=1/(r-i),a=this.elements;return a[0]=n?o:o/e,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=n?o*e:o,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(i+r)*s,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*i*r*s,a[15]=0,null!==i&&i!==1/0||(a[10]=-1,a[14]=-2*r),this},t.prototype.projectPoint=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;s.x=o[0]*r+o[4]*i+o[8]*n+o[12],s.y=o[1]*r+o[5]*i+o[9]*n+o[13],s.z=o[2]*r+o[6]*i+o[10]*n+o[14];var a=o[3]*r+o[7]*i+o[11]*n+o[15];return s.multiply(1/a)},t.prototype.transformPoint=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;return s.x=o[0]*r+o[4]*i+o[8]*n+o[12],s.y=o[1]*r+o[5]*i+o[9]*n+o[13],s.z=o[2]*r+o[6]*i+o[10]*n+o[14],s},t.prototype.transformNormal=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;return s.x=o[0]*r+o[4]*i+o[8]*n,s.y=o[1]*r+o[5]*i+o[9]*n,s.z=o[2]*r+o[6]*i+o[10]*n,s.normalize()},t.prototype.transformVector4=function(t,e){var r=t.x,i=t.y,n=t.z,o=t.w,s=this.elements,a=null!=e?e:t;return a.x=s[0]*r+s[4]*i+s[8]*n+s[12]*o,a.y=s[1]*r+s[5]*i+s[9]*n+s[13]*o,a.z=s[2]*r+s[6]*i+s[10]*n+s[14]*o,a.w=s[3]*r+s[7]*i+s[11]*n+s[15]*o,a},t.prototype.equals=function(t){for(var e=this.elements,r=t.elements,i=0;i<16;i++)if(!_t(e[i],r[i]))return!1;return!0},t.prototype.toArray=function(){return Pt([],It(this.elements),!1)},t.prototype.fill=function(t,e){void 0===e&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[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,r,i){return(new t).lookAt(e,r,i)},t.fromPerspective=function(e,r,i,n,o){return(new t).perspective(e,r,i,n,o)},t.fromColumnVectors=function(e,r,i,n){return(new t).setFromColumnVectors(e,r,i,n)},t.fromMatrix3=function(e){return(new t).setFromMatrix3(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromScale=function(e,r,i){return(new t).setFromScale(e,r,i)},t.fromTranslation=function(e,r,i){return(new t).setFromTranslation(e,r,i)},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,r){return(new t).setFromRotationAxis(e,r)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromShear=function(e,r,i){return(new t).setFromShear(e,r,i)},t.fromBasis=function(e,r,i){return(new t).setFromBasis(e,r,i)},t.fromRowMajorData=function(e,r,i,n,o,s,a,u,l,c,h,f,p,d,m,v){return new t(e,o,l,p,r,s,c,d,i,a,h,m,n,u,f,v)},t.IDENTITY=new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),t.ZERO=new t(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),t.tempVec0=new Mt,t.tempVec1=new Mt,t.tempVec2=new Mt,t.tempMat0=new t,t}();!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"}(Ot||(Ot={}));var Nt,Vt,Dt=function(){function t(e,r,i,n){void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=t.DEFAULT_ORDER),this.x=e,this.y=r,this.z=i,this.order=n}return t.prototype.set=function(t,e,r,i){return void 0===i&&(i=this.order),this.x=t,this.y=e,this.z=r,this.order=i,this},t.prototype.setZero=function(t){return void 0===t&&(t=this.order),this.set(0,0,0,t)},t.prototype.setFromRotationMatrix4=function(t,e){void 0===e&&(e=this.order);var r=t.elements,i=r[0],n=r[4],o=r[8],s=r[1],a=r[5],u=r[9],l=r[2],c=r[6],h=r[10];switch(e){case Ot.XYZ:this.y=Math.asin(Rt(o,-1,1)),Math.abs(o)<.9999999?(this.x=Math.atan2(-u,h),this.z=Math.atan2(-n,i)):(this.x=Math.atan2(c,a),this.z=0);break;case Ot.YXZ:this.x=Math.asin(-Rt(u,-1,1)),Math.abs(u)<.9999999?(this.y=Math.atan2(o,h),this.z=Math.atan2(s,a)):(this.y=Math.atan2(-l,i),this.z=0);break;case Ot.ZXY:this.x=Math.asin(Rt(c,-1,1)),Math.abs(c)<.9999999?(this.y=Math.atan2(-l,h),this.z=Math.atan2(-n,a)):(this.y=0,this.z=Math.atan2(s,i));break;case Ot.ZYX:this.y=Math.asin(-Rt(l,-1,1)),Math.abs(l)<.9999999?(this.x=Math.atan2(c,h),this.z=Math.atan2(s,i)):(this.x=0,this.z=Math.atan2(-n,a));break;case Ot.YZX:this.z=Math.asin(Rt(s,-1,1)),Math.abs(s)<.9999999?(this.x=Math.atan2(-u,a),this.y=Math.atan2(-l,i)):(this.x=0,this.y=Math.atan2(o,h));break;case Ot.XZY:this.z=Math.asin(-Rt(n,-1,1)),Math.abs(n)<.9999999?(this.x=Math.atan2(c,a),this.y=Math.atan2(o,i)):(this.x=Math.atan2(-u,h),this.y=0);break;default:console.error("setFromRotationMatrix: unknown order: "+e)}return this.x*=bt,this.y*=bt,this.z*=bt,this.order=e,this},t.prototype.setFromQuaternion=function(e,r){void 0===r&&(r=this.order);var i=t.tempMat0;return i.setFromQuaternion(e),this.setFromRotationMatrix4(i,r)},t.prototype.setFromVector3=function(t,e){return void 0===e&&(e=this.order),this.set(t.x,t.y,t.z,e)},t.prototype.setFromArray=function(t,e,r){var i,n,o,s;return void 0===e&&(e=0),void 0===r&&(r=this.order),this.x=null!==(i=t[e])&&void 0!==i?i:0,this.y=null!==(n=t[e+1])&&void 0!==n?n:0,this.z=null!==(o=t[e+2])&&void 0!==o?o:0,this.order=null!==(s=t[e+3])&&void 0!==s?s:r,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.order)},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.order=t.order,this},t.prototype.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)},t.prototype.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)},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.reorder=function(t){var e=new Lt;return e.setFromEuler(this),this.setFromQuaternion(e,t)},t.prototype.rotateVector3=function(e,r){return t.tempQuat0.setFromEuler(this).rotateVector3(e,r)},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.order===this.order},t.prototype.toVector3=function(t){return t.set(this.x,this.y,this.z)},t.prototype.toArray=function(){return[this.x,this.y,this.z]},t.prototype.toQuaternion=function(t){var e,r=(e=this).x,i=e.y,n=e.z,o=e.order,s=Math.cos(r*St*.5),a=Math.cos(i*St*.5),u=Math.cos(n*St*.5),l=Math.sin(r*St*.5),c=Math.sin(i*St*.5),h=Math.sin(n*St*.5);switch(o){case Ot.XYZ:t.set(l*a*u+s*c*h,s*c*u-l*a*h,s*a*h+l*c*u,s*a*u-l*c*h);break;case Ot.YXZ:t.set(l*a*u+s*c*h,s*c*u-l*a*h,s*a*h-l*c*u,s*a*u+l*c*h);break;case Ot.ZXY:t.set(l*a*u-s*c*h,s*c*u+l*a*h,s*a*h+l*c*u,s*a*u-l*c*h);break;case Ot.ZYX:t.set(l*a*u-s*c*h,s*c*u+l*a*h,s*a*h-l*c*u,s*a*u+l*c*h);break;case Ot.YZX:t.set(l*a*u+s*c*h,s*c*u+l*a*h,s*a*h-l*c*u,s*a*u-l*c*h);break;case Ot.XZY:t.set(l*a*u-s*c*h,s*c*u-l*a*h,s*a*h+l*c*u,s*a*u+l*c*h);break;default:console.error("unknown euler order: "+o)}return t},t.prototype.toMatrix4=function(t){var e,r=t.elements,i=(e=this).x,n=e.y,o=e.z,s=e.order,a=Math.cos(i*St),u=Math.sin(i*St),l=Math.cos(n*St),c=Math.sin(n*St),h=Math.cos(o*St),f=Math.sin(o*St);if(s===Ot.XYZ){var p=a*h,d=a*f,m=u*h,v=u*f;r[0]=l*h,r[4]=-l*f,r[8]=c,r[1]=d+m*c,r[5]=p-v*c,r[9]=-u*l,r[2]=v-p*c,r[6]=m+d*c,r[10]=a*l}else if(s===Ot.YXZ){var y=l*h,g=l*f,x=c*h,T=c*f;r[0]=y+T*u,r[4]=x*u-g,r[8]=a*c,r[1]=a*f,r[5]=a*h,r[9]=-u,r[2]=g*u-x,r[6]=T+y*u,r[10]=a*l}else if(s===Ot.ZXY){y=l*h,g=l*f,x=c*h,T=c*f;r[0]=y-T*u,r[4]=-a*f,r[8]=x+g*u,r[1]=g+x*u,r[5]=a*h,r[9]=T-y*u,r[2]=-a*c,r[6]=u,r[10]=a*l}else if(s===Ot.ZYX){p=a*h,d=a*f,m=u*h,v=u*f;r[0]=l*h,r[4]=m*c-d,r[8]=p*c+v,r[1]=l*f,r[5]=v*c+p,r[9]=d*c-m,r[2]=-c,r[6]=u*l,r[10]=a*l}else if(s===Ot.YZX){var E=a*l,S=a*c,b=u*l,A=u*c;r[0]=l*h,r[4]=A-E*f,r[8]=b*f+S,r[1]=f,r[5]=a*h,r[9]=-u*h,r[2]=-c*h,r[6]=S*f+b,r[10]=E-A*f}else if(s===Ot.XZY){E=a*l,S=a*c,b=u*l,A=u*c;r[0]=l*h,r[4]=-f,r[8]=c*h,r[1]=E*f+A,r[5]=a*h,r[9]=S*f-b,r[2]=b*f-S,r[6]=u*h,r[10]=A*f+E}else console.error("toMatrix4: Invalid order "+s);return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,t},t.fromRotationMatrix4=function(e,r){return void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromRotationMatrix4(e,r)},t.fromQuaternion=function(e,r){return void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromQuaternion(e,r)},t.fromVector3=function(e,r){return void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromVector3(e,r)},t.fromArray=function(e,r,i){return void 0===r&&(r=0),void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromArray(e,r,i)},t.DEFAULT_ORDER=Ot.ZYX,t.tempQuat0=new Lt,t.tempMat0=new Ft,t}(),zt=function(){function t(t,e,r,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=r,this.w=i}return t.prototype.set=function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},t.prototype.setZero=function(){return this.x=0,this.y=0,this.z=0,this.w=0,this},t.prototype.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},t.prototype.setFromArray=function(t,e){var r,i,n,o;return void 0===e&&(e=0),this.x=null!==(r=t[e])&&void 0!==r?r:0,this.y=null!==(i=t[e+1])&&void 0!==i?i:0,this.z=null!==(n=t[e+2])&&void 0!==n?n:0,this.w=null!==(o=t[e+3])&&void 0!==o?o:0,this},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t,this.w+=t):t instanceof 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},t.prototype.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},t.prototype.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},t.prototype.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t,this.w-=t):t instanceof 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},t.prototype.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},t.prototype.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):t instanceof 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},t.prototype.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},t.prototype.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t,this.w/=t):t instanceof 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},t.prototype.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},t.prototype.sum=function(){return this.x+this.y+this.z+this.w},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.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},t.prototype.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},t.prototype.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},t.prototype.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},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.normalize=function(){return this.divide(this.length()||1)},t.prototype.setLength=function(t){return this.normalize().multiply(t)},t.prototype.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},t.prototype.lerpVectors=function(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},t.prototype.isZero=function(){var t,e=At,r=(t=this).x,i=t.y,n=t.z,o=t.w;return Math.abs(r)<=e&&Math.abs(i)<=e&&Math.abs(n)<=e&&Math.abs(o)<=e},t.prototype.toArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.toVector3=function(){return new Mt(this.x,this.y,this.z)},t.prototype.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},t.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this},t.prototype.applyMatrix=function(t,e){return t.transformVector4(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.ONE=new t(1,1,1,1),t.ZERO=new t(0,0,0,0),t}(),Bt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},Ut=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},kt=function(){function t(t,e,r,i,n,o,s,a,u){void 0===t&&(t=1),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===u&&(u=1),this.elements=[t,e,r,i,n,o,s,a,u]}return t.prototype.set=function(t,e,r,i,n,o,s,a,u){var l=this.elements;return l[0]=t,l[3]=i,l[6]=s,l[1]=e,l[4]=n,l[7]=a,l[2]=r,l[5]=o,l[8]=u,this},t.prototype.setFromRowMajorData=function(t,e,r,i,n,o,s,a,u){var l=this.elements;return l[0]=t,l[3]=e,l[6]=r,l[1]=i,l[4]=n,l[7]=o,l[2]=s,l[5]=a,l[8]=u,this},t.prototype.setFromColumnVectors=function(t,e,r){return this.set(t.x,t.y,t.z,e.x,e.y,e.z,r.x,r.y,r.z)},t.prototype.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])},t.prototype.setFromArray=function(t,e){void 0===e&&(e=0);for(var r=0;r<9;r++)this.elements[r]=t[e+r];return this},t.prototype.setFromQuaternion=function(t){var e=t.x,r=t.y,i=t.z,n=t.w,o=e+e,s=r+r,a=i+i,u=e*o,l=e*s,c=e*a,h=r*s,f=r*a,p=i*a,d=n*o,m=n*s,v=n*a,y=this.elements;return y[0]=1-(h+p),y[1]=l+v,y[2]=c-m,y[3]=l-v,y[4]=1-(u+p),y[5]=f+d,y[6]=c+m,y[7]=f-d,y[8]=1-(u+h),this},t.prototype.setZero=function(){for(var t=0;t<9;t++)this.elements[t]=0;return this},t.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1)},t.prototype.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])},t.prototype.copyFrom=function(t){return this.elements=Ut([],Bt(t.elements),!1),this},t.prototype.getColumnVector=function(t,e){return e.set(this.elements[3*t],this.elements[3*t+1],this.elements[3*t+2])},t.prototype.scale=function(t,e){var r=this.elements;return r[0]*=t,r[3]*=t,r[6]*=t,r[1]*=e,r[4]*=e,r[7]*=e,this},t.prototype.rotate=function(t){var e=Math.cos(t),r=Math.sin(t),i=this.elements,n=i[0],o=i[3],s=i[6],a=i[1],u=i[4],l=i[7];return i[0]=e*n+r*a,i[3]=e*o+r*u,i[6]=e*s+r*l,i[1]=-r*n+e*a,i[4]=-r*o+e*u,i[7]=-r*s+e*l,this},t.prototype.translate=function(t,e){var r=this.elements;return r[0]+=t*r[2],r[3]+=t*r[5],r[6]+=t*r[8],r[1]+=e*r[2],r[4]+=e*r[5],r[7]+=e*r[8],this},t.prototype.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)},t.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},t.prototype.multiplyMatrices=function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],s=r[3],a=r[6],u=r[1],l=r[4],c=r[7],h=r[2],f=r[5],p=r[8],d=i[0],m=i[3],v=i[6],y=i[1],g=i[4],x=i[7],T=i[2],E=i[5],S=i[8];return n[0]=o*d+s*y+a*T,n[3]=o*m+s*g+a*E,n[6]=o*v+s*x+a*S,n[1]=u*d+l*y+c*T,n[4]=u*m+l*g+c*E,n[7]=u*v+l*x+c*S,n[2]=h*d+f*y+p*T,n[5]=h*m+f*g+p*E,n[8]=h*v+f*x+p*S,this},t.prototype.determinant=function(){var t=this.elements,e=t[0],r=t[3],i=t[6],n=t[1],o=t[4],s=t[7],a=t[2],u=t[5],l=t[8];return e*(o*l-u*s)+n*(u*i-r*l)+a*(r*s-o*i)},t.prototype.invert=function(){var t=this.elements,e=t[0],r=t[3],i=t[6],n=t[1],o=t[4],s=t[7],a=t[2],u=t[5],l=t[8],c=l*o-u*s,h=u*i-l*r,f=s*r-o*i,p=e*c+n*h+a*f;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);var d=1/p;return t[0]=c*d,t[1]=(a*s-l*n)*d,t[2]=(u*n-a*o)*d,t[3]=h*d,t[4]=(l*e-a*i)*d,t[5]=(a*r-u*e)*d,t[6]=f*d,t[7]=(n*i-s*e)*d,t[8]=(o*e-n*r)*d,this},t.prototype.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},t.prototype.transformPoint=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;return s.x=o[0]*r+o[3]*i+o[6]*n,s.y=o[1]*r+o[4]*i+o[7]*n,s.z=o[2]*r+o[5]*i+o[8]*n,s},t.prototype.transformNormal=function(t,e){return this.transformPoint(t,e).normalize()},t.prototype.equals=function(t){for(var e=this.elements,r=t.elements,i=0;i<9;i++)if(!_t(e[i],r[i]))return!1;return!0},t.prototype.toArray=function(){return Ut([],Bt(this.elements),!1)},t.prototype.fill=function(t,e){void 0===e&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8]},t.fromIdentity=function(){return new t(1,0,0,0,1,0,0,0,1)},t.fromColumnVectors=function(e,r,i){return(new t).setFromColumnVectors(e,r,i)},t.fromMatrix4=function(e){return(new t).setFromMatrix4(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromRowMajorData=function(e,r,i,n,o,s,a,u,l){return new t(e,n,a,r,o,u,i,s,l)},t}(),Gt=function(){function t(t,e){void 0===t&&(t=Mt.ZERO),void 0===e&&(e=Mt.X),this.origin=new Mt,this.direction=new Mt,this.origin.copyFrom(t),this.direction.copyFrom(e).normalize()}return t.prototype.set=function(t,e){return this.origin.copyFrom(t),this.direction.copyFrom(e).normalize(),this},t.prototype.clone=function(){return new t(this.origin,this.direction)},t.prototype.copyFrom=function(t){return this.set(t.origin,t.direction)},t.prototype.recast=function(e){return this.origin.copyFrom(this.at(e,t.tempVec0)),this},t.prototype.at=function(t,e){var r=e||new Mt;return r.copyFrom(this.origin),r.addScaledVector(this.direction,t)},t.prototype.equals=function(t){return this.origin.equals(t.origin)&&this.direction.equals(t.direction)},t.prototype.applyMatrix=function(t){return this.origin.applyProjectionMatrix(t),this.direction.applyNormalMatrix(t),this},t.prototype.intersectBox=function(t,e){var r,i,n,o,s,a,u,l,c,h,f=(r=this.origin).x,p=r.y,d=r.z,m=(i=this.direction).x,v=i.y,y=i.z,g=(n=t.min).x,x=n.y,T=n.z,E=(o=t.max).x,S=o.y,b=o.z,A=1/m,_=1/v,C=1/y;if(A>=0?(s=(g-f)*A,a=(E-f)*A):(s=(E-f)*A,a=(g-f)*A),_>=0?(u=(x-p)*_,l=(S-p)*_):(u=(S-p)*_,l=(x-p)*_),!(s>l||u>a||((u>s||s!=s)&&(s=u),(l<a||a!=a)&&(a=l),(u>s||s!=s)&&(s=u),(l<a||a!=a)&&(a=l),C>=0?(c=(T-d)*C,h=(b-d)*C):(c=(b-d)*C,h=(T-d)*C),s>h||c>a||((c>s||s!=s)&&(s=c),(h<a||a!=a)&&(a=h),a<0))))return s>=0?this.at(s,e):this.at(a,e)},t.prototype.intersectPlane=function(t,e){var r=t.normal,i=t.distance,n=r.dot(this.direction);if(0===n)return 0===r.dot(this.origin)+i?(e||new Mt).copyFrom(this.origin):void 0;var o=-(this.origin.dot(r)+i)/n;return o>=0?this.at(o,e):void 0},t.prototype.intersectSphere=function(e,r){var i=e.center,n=t.tempVec0.subtractVectors(i,this.origin),o=n.dot(this.direction),s=n.dot(n)-o*o,a=e.radius*e.radius;if(!(s>a)){var u=Math.sqrt(a-s),l=o-u,c=o+u;if(!(c<0))return l>=0?this.at(l,r):this.at(c,r)}},t.prototype.intersectTriangle=function(e,r,i){var n,o=e.p0,s=e.p1,a=e.p2,u=t.tempVec0.subtractVectors(s,o),l=t.tempVec1.subtractVectors(a,o),c=t.tempVec2.subtractVectors(this.origin,o),h=t.tempVec3.crossVectors(u,l),f=this.direction.dot(h);if(f>0){if(i)return;n=1}else{if(!(f<0))return;n=-1,f=-f}l.crossVectors(c,l);var p=n*this.direction.dot(l);if(!(p<0)){u.cross(c);var d=n*this.direction.dot(u);if(!(d<0||p+d>f)){var m=-n*c.dot(h);if(!(m<0))return this.at(m/f,r)}}},t.tempVec0=new Mt,t.tempVec1=new Mt,t.tempVec2=new Mt,t.tempVec3=new Mt,t}(),Xt=function(){function t(t,e,r,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),this.r=t,this.g=e,this.b=r,this.a=i}return t.prototype.set=function(t,e,r,i){return this.r=t,this.g=e,this.b=r,this.a=i,this},t.prototype.setZero=function(){return this.r=0,this.g=0,this.b=0,this.a=0,this},t.prototype.setFromNumber=function(t){return this.r=t,this.g=t,this.b=t,this.a=t,this},t.prototype.setFromVector4=function(t){return this.r=t.x,this.g=t.y,this.b=t.z,this.a=t.w,this},t.prototype.setFromArray=function(t,e){var r,i,n,o;return void 0===e&&(e=0),this.r=null!==(r=t[e])&&void 0!==r?r:0,this.g=null!==(i=t[e+1])&&void 0!==i?i:0,this.b=null!==(n=t[e+2])&&void 0!==n?n:0,this.a=null!==(o=t[e+3])&&void 0!==o?o:0,this},t.prototype.setFromHSV=function(t,e,r,i){void 0===i&&(i=1);var n=r*e,o=t/60,s=n*(1-Math.abs(o%2-1)),a=0,u=0,l=0;o>=0&&o<=1?(a=n,u=s):o>=1&&o<=2?(a=s,u=n):o>=2&&o<=3?(u=n,l=s):o>=3&&o<=4?(u=s,l=n):o>=4&&o<=5?(a=s,l=n):o>=5&&o<=6&&(a=n,l=s);var c=r-n;return this.set(a+c,u+c,l+c,i)},t.prototype.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,r=parseInt(t.substring(3,5),16)/255,i=parseInt(t.substring(5,7),16)/255,n=9===t.length?parseInt(t.substring(7,9),16)/255:1;return this.set(e,r,i,n)},t.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.r+=t,this.g+=t,this.b+=t,this.a+=t):t instanceof 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},t.prototype.subtract=function(t){return"number"==typeof t?(this.r-=t,this.g-=t,this.b-=t,this.a-=t):t instanceof 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},t.prototype.multiply=function(t){return"number"==typeof t?(this.r*=t,this.g*=t,this.b*=t,this.a*=t):t instanceof 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},t.prototype.divide=function(t){return"number"==typeof t?(this.r/=t,this.g/=t,this.b/=t,this.a/=t):t instanceof 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},t.prototype.scale=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.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},t.prototype.luminance=function(){return.3*this.r+.59*this.g+.11*this.b},t.prototype.equals=function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a},t.prototype.toLinear=function(){return this.r=t.gammaToLinear(this.r),this.g=t.gammaToLinear(this.g),this.b=t.gammaToLinear(this.b),this},t.prototype.toGamma=function(){return this.r=t.linearToGamma(this.r),this.g=t.linearToGamma(this.g),this.b=t.linearToGamma(this.b),this},t.prototype.toArray=function(){return[this.r,this.g,this.b,this.a]},t.prototype.toVector4=function(){return new zt(this.r,this.g,this.b,this.a)},t.prototype.toHSV=function(){var e,r=(e=this).r,i=e.g,n=e.b,o=e.a,s=Math.max(r,i,n),a=Math.min(r,i,n),u=s-a,l=0,c=0;return 0!==s&&(c=u/s),s!=a&&(s==r?(l=(i-n)/u,i<n&&(l+=6)):s==i?l=(n-r)/u+2:s==n&&(l=(r-i)/u+4),l*=60),new t(l,c,s,o)},t.prototype.toHexString=function(e){void 0===e&&(e=!0);var r=t.ToHex(Math.round(255*this.r)),i=t.ToHex(Math.round(255*this.g)),n=t.ToHex(Math.round(255*this.b)),o=t.ToHex(Math.round(255*this.a));return e?"#"+r+i+n+o:"#"+r+i+n},t.prototype.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,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromHexString=function(e){return(new t).setFromHexString(e)},t.fromHSV=function(e,r,i,n){return void 0===n&&(n=1),(new t).setFromHSV(e,r,i,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.BLACK=new t(0,0,0,1),t.BLUE=new t(0,0,1,1),t.CLEAR=new t(0,0,0,0),t.CYAN=new t(0,1,1,1),t.GRAY=new t(.5,.5,.5,1),t.GREEN=new t(0,1,0,1),t.MAGENTA=new t(1,0,1,1),t.RED=new t(1,0,0,1),t.WHITE=new t(1,1,1,1),t.YELLOW=new t(1,.92,.016,1),t}(),Ht=function(){function t(t,e){void 0===t&&(t=new Mt(1/0,1/0,1/0)),void 0===e&&(e=new Mt(-1/0,-1/0,-1/0)),this.min=t.clone(),this.max=e.clone()}return t.prototype.set=function(t,e){return this.min.copyFrom(t),this.max.copyFrom(e),this},t.prototype.setFromArray=function(t){for(var e=Number(1/0),r=Number(1/0),i=Number(1/0),n=-1/0,o=-1/0,s=-1/0,a=0,u=t.length;a<u;a+=3){var l=t[a],c=t[a+1],h=t[a+2];l<e&&(e=l),c<r&&(r=c),h<i&&(i=h),l>n&&(n=l),c>o&&(o=c),h>s&&(s=h)}return this.min.set(e,r,i),this.max.set(n,o,s),this},t.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this},t.prototype.setFromCenterAndSize=function(t,e){var r=e.clone().multiply(.5);return this.min.copyFrom(t).subtract(r),this.max.copyFrom(t).add(r),this},t.prototype.setFromObject=function(t){return this.makeEmpty(),this.expandByObject(t)},t.prototype.clone=function(){return(new t).copyFrom(this)},t.prototype.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},t.prototype.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},t.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},t.prototype.getCenter=function(t){return void 0===t&&(t=new Mt),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiply(.5)},t.prototype.getSize=function(t){return void 0===t&&(t=new Mt),this.isEmpty()?t.set(0,0,0):t.subtractVectors(this.max,this.min)},t.prototype.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},t.prototype.expandByVector=function(t){return this.min.subtract(t),this.max.add(t),this},t.prototype.expandByScalar=function(t){return this.min.add(-t),this.max.add(t),this},t.prototype.expandByBox=function(t){return this.min.min(t.min),this.max.max(t.max),this},t.prototype.expandByObject=function(e){e.updateWorldMatrix(!1,!1);var r=e.geometry;if(void 0!==r){null===r.boundingBox&&r.computeBoundingBox();var i=new t;i.copyFrom(r.boundingBox),i.applyMatrix4(e.matrixWorld),this.union(i)}for(var n=e.children,o=0,s=n.length;o<s;o++)this.expandByObject(n[o]);return this},t.prototype.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)},t.prototype.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},t.prototype.getParameter=function(t,e){return void 0===e&&(e=new Mt),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))},t.prototype.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)},t.prototype.intersectsSphere=function(t){var e=new Mt;return this.clampPoint(t.center,e),e.distanceSquared(t.center)<=t.radius*t.radius},t.prototype.clampPoint=function(t,e){return void 0===e&&(e=new Mt),e.copyFrom(t).clamp(this.min,this.max)},t.prototype.distanceToPoint=function(t){return t.clone().clamp(this.min,this.max).subtract(t).length()},t.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},t.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},t.prototype.applyMatrix4=function(t,e){if(void 0===e&&(e=new Mt),this.isEmpty())return this;var r=this.getOBBPoints(t,e);return this.setFromPoints(r),this},t.prototype.getOBBPoints=function(t,e){if(void 0===e&&(e=new Mt),this.isEmpty())return[];var r=[];return r[0]=new Mt(this.min.x,this.min.y,this.min.z),r[1]=new Mt(this.min.x,this.min.y,this.max.z),r[2]=new Mt(this.min.x,this.max.y,this.min.z),r[3]=new Mt(this.min.x,this.max.y,this.max.z),r[4]=new Mt(this.max.x,this.min.y,this.min.z),r[5]=new Mt(this.max.x,this.min.y,this.max.z),r[6]=new Mt(this.max.x,this.max.y,this.min.z),r[7]=new Mt(this.max.x,this.max.y,this.max.z),r.forEach((function(r){r.subtract(e),r.applyMatrix(t),r.add(e)})),r},t.prototype.getBoundingSphere=function(t){this.getCenter(t.center);var e=new Mt;return t.radius=.5*this.getSize(e).length(),t},t.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},t.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},t}(),Yt=function(){function t(t,e){void 0===t&&(t=Mt.ZERO),void 0===e&&(e=-1),this.center=t.clone(),this.radius=e}return t.prototype.set=function(t,e){return this.center.copyFrom(t),this.radius=e,this},t.prototype.setFromPoints=function(t,e){var r=this.center;if(void 0!==e){r.copyFrom(e);for(var i=0,n=0;n<t.length;n++)i=Math.max(i,r.distanceSquared(t[n]));this.radius=Math.sqrt(i)}else{var o=(new Ht).setFromPoints(t);o.getCenter(r),this.radius=o.getSize().length()/2}return this},t.prototype.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},t.prototype.isEmpty=function(){return this.radius<0},t.prototype.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},t.prototype.containsPoint=function(t){return t.distanceSquared(this.center)<=this.radius*this.radius},t.prototype.distanceToPoint=function(t){return t.distance(this.center)-this.radius},t.prototype.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceSquared(this.center)<=e*e},t.prototype.intersectsBox=function(t){return t.intersectsSphere(this)},t.prototype.clampPoint=function(t,e){var r=this.center.distanceSquared(t);return void 0===e&&(e=new Mt),e.copyFrom(t),r>this.radius*this.radius&&(e.subtract(this.center).normalize(),e.multiply(this.radius).add(this.center)),e},t.prototype.getBoundingBox=function(t){return void 0===t&&(t=new Ht),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},t.prototype.applyMatrix4=function(t){var e=t.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=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],o=Math.sqrt(Math.max(r,i,n));return this.center.applyMatrix(t),this.radius=this.radius*o,this},t.prototype.translate=function(t){return this.center.add(t),this},t.prototype.expandByPoint=function(t){var e=(new Mt).subtractVectors(t,this.center),r=e.lengthSquared();if(r>this.radius*this.radius){var i=Math.sqrt(r),n=.5*(i-this.radius);this.center.add(e.multiply(n/i)),this.radius+=n}return this},t.prototype.union=function(t){var e=new Mt,r=new Mt;return r.subtractVectors(t.center,this.center).normalize().multiply(t.radius),this.expandByPoint(e.copyFrom(t.center).add(r)),this.expandByPoint(e.copyFrom(t.center).subtract(r)),this},t.prototype.intersect=function(t){var e=(new Mt).subtractVectors(this.center,t.center),r=e.length();return r>this.radius+t.radius?this.makeEmpty():(this.center=this.center.add(e.normalize().multiply(r/2)),this.radius=this.radius+t.radius-r,this)},t.prototype.equals=function(t){return t.center.equals(this.center)&&t.radius===this.radius},t.prototype.clone=function(){return(new t).copyFrom(this)},t}(),jt=Object.freeze({__proto__:null,get EulerOrder(){return Ot},Euler:Dt,Quaternion:Lt,Vector2:wt,Vector3:Mt,Vector4:zt,Matrix3:kt,Matrix4:Ft,Ray:Gt,PI2:Et,DEG2RAD:St,RAD2DEG:bt,NumberEpsilon:At,isZero:function(t){return isNaN(t)||Math.abs(t)<At},isEqual:_t,damp:function(t,e,r,i){return Ct(t,e,1-Math.exp(-r*i))},lerp:Ct,degToRad:function(t){return t*St},radToDeg:function(t){return t*bt},clamp:Rt,Color:Xt,Box3:Ht,Sphere:Yt}),Wt=(Nt=new Float32Array(1),Vt=new Int32Array(Nt.buffer),function(t){Nt[0]=t;var e=Vt[0],r=e>>16&32768,i=e>>12&2047,n=e>>23&255;return n<103?r:n>142?(r|=31744,r|=(255==n?0:1)&&8388607&e):n<113?r|=((i|=2048)>>114-n)+(i>>113-n&1):(r|=n-112<<10|i>>1,r+=1&i)}),Zt=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),r=0;r<e.length;r++)e[r]=Wt(t[r])}return t.prototype.set=function(t,e){for(var r=0;r<t.length;r++)this.data[r+e]=Wt(t[r])},t}();var qt,Kt=new Dt,Qt=new Ft;function Jt(t,e,r,i,n,o,s){var a=t,u=i/n,l=i,c=e.speedOverLifetime;c&&(l=c.getIntegrateValue(0,i,n));var h=e.gravityModifier?e.gravityModifier.getIntegrateByTime(0,i):0;a.copyFrom(o),a.addScaledVector(s,l),a.addScaledVector(r,h);var f=e.linearVelOverLifetime||{},p=e.orbitalVelOverLifetime||{},d=["x","y","z"];if(p.enabled){var m=new Mt;p.center&&m.setFromArray(p.center);var v=a.clone().subtract(m),y=p.asRotation,g=d.map((function(t){var e=p[t];return e?y?e.getValue(u):e.getIntegrateValue(0,i,n):0}));Kt.setFromArray(g).negate(),Qt.setFromEuler(Kt);var x=Qt.transformPoint(v);a.addVectors(m,x)}if(f.enabled)for(var T=f.asMovement,E=0;E<3;E++){var S=f[d[E]];if(S){var b=T?S.getValue(u):S.getIntegrateValue(0,i,n);a.setElement(E,a.getElement(E)+b)}}return a}function $t(t){return Array.isArray(t)?[t[0],t[1],t[2]]:[0,0,0]}function te(t,e){for(var r=0,i=t.length;r<i;r++)t[r]=e;return t}function ee(t,e,r,i){void 0===i&&(i=0);for(var n=0;n<r;n++)t[n]=e[n+i];return t}function re(t,e){1===arguments.length&&(e=t,t=[]);var r=e,i=Math.hypot.apply(Math,u([],a(r),!1));if(0===i)return ee(t,r,r.length);for(var n=0;n<r.length;n++)t[n]=r[n]/i;return t}function ie(t,e,r){if(e&&r)for(var i=0,n=e.length;i<n;i++)t[i]=e[i]*r[i];else if(e){if(t!==e)for(i=0;i<e.length;i++)t[i]=e[i]}else if(r&&t!==r)for(i=0;i<r.length;i++)t[i]=r[i];return t}var ne,oe=((qt={})[L.PARTICLE_ORIGIN_CENTER]=[0,0],qt[L.PARTICLE_ORIGIN_CENTER_BOTTOM]=[0,-.5],qt[L.PARTICLE_ORIGIN_CENTER_TOP]=[0,.5],qt[L.PARTICLE_ORIGIN_LEFT_TOP]=[-.5,.5],qt[L.PARTICLE_ORIGIN_LEFT_CENTER]=[-.5,0],qt[L.PARTICLE_ORIGIN_LEFT_BOTTOM]=[-.5,-.5],qt[L.PARTICLE_ORIGIN_RIGHT_CENTER]=[.5,0],qt[L.PARTICLE_ORIGIN_RIGHT_BOTTOM]=[.5,-.5],qt[L.PARTICLE_ORIGIN_RIGHT_TOP]=[.5,.5],qt);function se(t,e){return t?[t[0]-.5,.5-t[1]]:e?oe[e]:[0,0]}function ae(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function ue(t,e,r){var i=r.position,n=new Mt(t,e,0),o=new Mt;return r.getInverseViewProjectionMatrix().projectPoint(n,o),o.subtract(i),new Gt(i,o)}function le(t,e,r){var i=t.x,n=t.y,o=t.z,s=new Mt(i-e,n+r,o),a=new Mt(i-e,n-r,o),u=new Mt(i+e,n-r,o),l=new Mt(i+e,n+r,o);return[{p0:s,p1:a,p2:u},{p0:s.clone(),p1:u.clone(),p2:l}]}var ce="not_implement",he=function(){function t(t){this.onCreate(t)}return t.prototype.onCreate=function(t){throw Error(ce)},t.prototype.getIntegrateValue=function(t,e,r){throw Error(ce)},t.prototype.getIntegrateByTime=function(t,e){throw Error(ce)},t.prototype.getValue=function(t){throw Error(ce)},t.prototype.toUniform=function(t){throw Error(ce)},t.prototype.map=function(t){throw Error(ce)},t.prototype.scaleXCoord=function(t){return this},t}(),fe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.value=t},e.prototype.getIntegrateValue=function(t,e,r){return this.value*(e-t)},e.prototype.getIntegrateByTime=function(t,e){return.5*this.value*(e*e-t*t)},e.prototype.getValue=function(t){return this.value},e.prototype.toUniform=function(){return new Float32Array([0,this.value,0,0])},e.prototype.map=function(t){var e=this.value;return this.value=t(e),this},e}(he),pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.items=t},e.prototype.getValue=function(t){var e=this.items;return e[Math.floor(Math.random()*e.length)]},e.prototype.map=function(t){return this.items=this.items.map(t),this},e}(he),de=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.min=t[0],this.max=t[1]},e.prototype.getValue=function(t){return Ye(this.min,this.max)},e.prototype.toUniform=function(){return new Float32Array([4,this.min,this.max,0])},e.prototype.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},e}(he),me=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.min=t[0],this.max=t[1]},e.prototype.getValue=function(t){for(var e=this.min,r=this.max,i=[],n=0;n<e.length;n++){var o=Math.random();i[n]=e[n]*(1-o)+r[n]*o}return i},e.prototype.map=function(t){return this.min=this.min.map(t),this.max=this.max.map(t),this},e}(he),ve=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.min=t[0],this.max=t[1],this.xCoord=1},e.prototype.getValue=function(t){return t/=this.xCoord,this.min*(1-t)+this.max*t},e.prototype.toUniform=function(){return new Float32Array([1,this.min,this.max,this.xCoord])},e.prototype.getIntegrateValue=function(t,e,r){void 0===r&&(r=1);var i=this.min,n=this.max,o=this.xCoord*r;return((i+e/o*(n-i)+i)*e-(i+t/o*(n-i)+i)*t)/2},e.prototype.getIntegrateByTime=function(t,e){return _e(e,0,this.xCoord,this.min,this.max)-_e(t,0,this.xCoord,this.min,this.max)},e.prototype.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},e.prototype.scaleXCoord=function(t){return this.xCoord=t,this},e}(he),ye=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.stops=H(t)},e.prototype.getStops=function(){return this.stops},e.prototype.getValue=function(t){for(var e=this.stops,r=e.length-1,i=0;i<r;i++){var n=e[i],o=e[i+1];if(n.stop<=t&&o.stop>t){var s=(t-n.stop)/(o.stop-n.stop);return Y(n.color,o.color,s,!0)}}return e[r].color.slice()},e}(he),ge=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.getAllData=function(t,e){for(var r=new(e?Zt:Float32Array)(4*t.index),i=0,n=0,o=t.curves;i<o.length;i++){var s=o[i].toData();r.set(s,n),n+=s.length}return e?r.data:r},e.prototype.onCreate=function(t){var e=1/0,r=-1/0;if(Number.isFinite(t[0])&&Number.isFinite(t[1])){for(var i=[],n=2;n<t.length;n++)i.push(t[n].slice(0,4));this.keys=i,this.min=t[0],this.dist=t[1]-t[0]}else{i=t.map((function(t){if(Ge(t))return e=Math.min(e,t[1]),r=Math.max(r,t[1]),t.slice(0,4);if("object"==typeof t&&t){var i=t,n=i.time,o=i.value,s=i.inTangent,a=void 0===s?0:s,u=i.outTangent,l=void 0===u?0:u;return e=Math.min(e,o),r=Math.max(r,o),[n,o,a,l]}throw new Error("invalid keyframe")}));var o=r-e;if(this.keys=i,0!==o)for(n=0;n<i.length;n++){var s=i[n];s[1]=(s[1]-e)/o}var a=i[0];a[0]>0&&(a[2]=0,i.unshift([0,a[1],0,0]));var u=i[i.length-1];u[0]<1&&(u[3]=0,i.push([1,u[1],0,0])),this.min=e,this.dist=o}this.isCurveValue=!0},e.prototype.getValue=function(t){var e=this,r=e.keys,i=e.min,n=e.dist,o=r;if(t<=o[0][0])return o[0][1]*n+i;for(var s=o.length-1,a=0;a<s;a++){var u=o[a],l=o[a+1];if(t>u[0]&&t<=l[0])return Ce(t,u,l)*n+i}return o[s][1]*n+i},e.prototype.getIntegrateByTime=function(t,e){var r=this.integrate(e,!0)-this.integrate(t,!0);return.5*this.min*(e-t)*(e-t)+r*this.dist},e.prototype.getIntegrateValue=function(t,e,r){r=r||1;var i=(this.integrate(e/r,!1)-this.integrate(t/r,!1))*r,n=(e-t)/r;return this.min*n+i*this.dist},e.prototype.integrate=function(t,e){var r=this.keys;if(t<=r[0][0])return 0;for(var i=0,n=r.length-1,o=e?Oe:Re,s=0;s<n;s++){var a=r[s],u=r[s+1],l=a[0],c=u[0];if(t>l&&t<=c)return i+o(t,a,u);i+=o(c,a,u)}return i},e.prototype.toData=function(){for(var t=this.keys,e=new Float32Array(4*t.length),r=0,i=0;r<t.length;r++,i+=4)e.set(t[r],i);return e},e.prototype.toUniform=function(t){var e=t.index,r=this.keys;return t.curves.push(this),t.index+=r.length,t.max=Math.max(t.max,r.length),t.curveCount+=r.length,new Float32Array([2,e+1/r.length,this.min,this.dist])},e.prototype.map=function(t){return this.keys.forEach((function(e){e[1]=t(e[1])})),this},e.prototype.scaleXCoord=function(t){return this.keys.forEach((function(e){return e[0]=t*e[0]})),this},e}(he),xe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.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 r=this.keys[0];r[0]>0&&this.keys.unshift([0,r[1]]),this.isLineSeg=!0},e.prototype.getValue=function(t){var e=this.keys;if(t<e[0][0])return e[0][1];for(var r=e.length-1,i=0;i<r;i++){var n=e[i],o=e[i+1],s=n[0],a=o[0];if(t>=s&&t<=a){var u=(t-s)/(a-s),l=n[1];return l+u*(o[1]-l)}}return e[r][1]},e.prototype.getIntegrateValue=function(t,e,r){return void 0===r&&(r=1),(this.integrate(e,!1)-this.integrate(t,!1))*r},e.prototype.getIntegrateByTime=function(t,e){return this.integrate(e,!0)-this.integrate(t,!0)},e.prototype.integrate=function(t,e){var r=this.keys;if(t<=r[0][0])return 0;for(var i=0,n=r.length-1,o=e?_e:Ae,s=0;s<n;s++){var a=r[s],u=r[s+1],l=a[0],c=u[0];if(t>l&&t<=c)return i+o(t,l,c,a[1],u[1]);i+=o(c,l,c,a[1],u[1])}return i},e.prototype.toData=function(){for(var t=this.keys,e=new Float32Array(4*Math.ceil(t.length/2)),r=0,i=0;r<t.length;r++,i+=2)e.set(t[r],i);return e.set(t[t.length-1],e.length-2),e},e.prototype.toUniform=function(t){var e=t.index,r=this.keys,i=Math.ceil(r.length/2);return t.lineSegCount+=i,t.curves.push(this),t.index+=i,t.max=Math.max(t.max,i),new Float32Array([3,e,i,0])},e.prototype.map=function(t){return this.keys.forEach((function(e){return e[1]=t(e[1])})),this},e.prototype.scaleXCoord=function(t){return this.keys.forEach((function(e){return e[0]=t*e[0]})),this},e}(he),Te=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.keys=t[0],this.values=t[1]},e.prototype.getValue=function(t){for(var e=this.keys,r=this.values,i=0;i<e.length-1;i++){var n=e[i],o=e[i+1];if(n[0]<=t&&o[0]>=t){var s=o[1]-n[1],a=void 0;if(0===s)a=(t-n[0])/(o[0]-n[0]);else a=(Ce(t,n,o)-n[1])/s;return this.calculateVec(i,a)}}return t<=e[0][0]?r[0].slice():r[r.length-1].slice()},e.prototype.calculateVec=function(t,e){for(var r=this.values[t],i=this.values[t+1],n=[0,0,0],o=0;o<r.length;o++)n[o]=r[o]*(1-e)+i[o]*e;return n},e}(he),Ee=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(e){t.prototype.onCreate.call(this,e),this.cps=e[2]},e.prototype.calculateVec=function(t,e){for(var r=this.values[t],i=this.values[t+1],n=this.cps[t+t],o=this.cps[t+t+1],s=[0,0,0],a=1-e,u=a*a*a,l=3*e*a*a,c=3*e*e*a,h=e*e*e,f=0;f<r.length;f++)s[f]=u*r[f]+l*n[f]+c*o[f]+h*i[f];return s},e}(Te),Se=((ne={})[ot.RANDOM]=function(t){return t[0]instanceof Array?new me(t):new de(t)},ne[ot.CONSTANT]=function(t){return new fe(t)},ne[ot.CONSTANT_VEC2]=function(t){return new fe(t)},ne[ot.CONSTANT_VEC3]=function(t){return new fe(t)},ne[ot.CONSTANT_VEC4]=function(t){return new fe(t)},ne[ot.CURVE]=function(t){return new ge(t)},ne[ot.RGBA_COLOR]=function(t){return new fe(t)},ne[ot.COLORS]=function(t){return new pe(t.map((function(t){return G(t,!1)})))},ne[ot.LINE]=function(t){return 2===t.length&&0===t[0][0]&&1===t[1][0]?new ve([t[0][1],t[1][1]]):new xe(t)},ne[ot.GRADIENT_COLOR]=function(t){return new ye(t)},ne[ot.LINEAR_PATH]=function(t){return new Te(t)},ne[ot.BEZIER_PATH]=function(t){return new Ee(t)},ne);function be(t){if(!t||!isNaN(+t))return new fe(t||0);if(t instanceof he)return t;if(Xe(Se[t[0]]))return Se[t[0]](t[1]);throw new Error("ValueType: ".concat(t[0]," is not support"))}function Ae(t,e,r,i,n){var o=t-e;return(i+i+(n-i)*o/(r-e))*o/2}function _e(t,e,r,i,n){var o=t*t,s=e*e;return(2*(o*t)*(i-n)+3*o*(e*n-r*i)-s*e*(2*i+n)+3*s*r*i)/(6*(e-r))}function Ce(t,e,r){var i=r[0]-e[0],n=e[3]*i,o=r[2]*i,s=(t-e[0])/i,a=s*s,u=a*s,l=u-2*a+s,c=u-a,h=-2*u+3*a;return(2*u-3*a+1)*e[1]+l*n+c*o+h*r[1]}function Re(t,e,r){var i=r[0]-e[0],n=e[3]*i,o=r[2]*i,s=e[0],a=e[1],u=r[1],l=s-t,c=l*l,h=c*l;return(n+o+2*a-2*u)*h*l/(4*i*i*i)+(2*n+o+3*a-3*u)*h/(3*i*i)+n*c/2/i-a*l}function Oe(t,e,r){var i=r[0]-e[0],n=e[3]*i,o=r[2]*i,s=e[0],a=e[1],u=r[1],l=s-t,c=l*l,h=c*l,f=i*i,p=f*i;return(-30*p*a*(s+t)*l+10*f*n*(s+2*t)*c+5*i*(s+3*t)*(2*n+o+3*a-3*u)*h+3*(s+4*t)*(n+o+2*a-2*u)*h*l)/60/p}function we(t,e){if(e){var r=e[0],i=e[1];if(r===ot.CURVE){t.curves.push(i);var n=i.length;i[0][0]>0&&n++,i[i.length-1][0]<1&&n++,t.index+=n,t.max=Math.max(t.max,n),t.curveCount+=n}else if(r===ot.LINE){if(2===(n=i.length)&&0===i[0][0]&&1===i[1][0])return;i[0][0]>0&&n++,i[i.length-1][0]<1&&n++;var o=Math.ceil(n/2);t.lineSegCount+=o,t.curves.push(i),t.index+=o,t.max=Math.max(t.max,o)}}}function Me(){return{curves:[],index:0,max:0,lineSegCount:0,curveCount:0}}var Le,Ie=new Dt,Pe=new Mt(1,1,1),Fe=new Mt(0,0,0),Ne=function(){function t(t,e){var r,i=t.positionOverLifetime,n=void 0===i?{}:i,o=e.transform,s=e.duration,a=e.endBehavior,u=o.scale;this.transform=o,this.basicTransform={position:o.position.clone(),rotation:o.getRotation(),scale:u},n.path&&(this.basicTransform.path=be(n.path)),this.positionOverLifetime=n,this.options={startSpeed:n.startSpeed||0,startSize:u&&u.x||1,sizeAspect:u&&u.x/(u.y||1)||1,startColor:[1,1,1,1],duration:s||0,looping:a&&a===at.loop,gravity:Mt.fromArray(n.gravity||[]),gravityModifier:be(null!==(r=n.gravityOverLifetime)&&void 0!==r?r:0),direction:n.direction?Mt.fromArray(n.direction).normalize():new Mt,endBehavior:a||0};var l=t.sizeOverLifetime;l&&(l.separateAxes?(this.sizeSeparateAxes=!0,this.sizeXOverLifetime=be(l.x||1),this.sizeYOverLifetime=be(l.y||1),this.sizeZOverLifetime=be(l.z||1)):this.sizeXOverLifetime=be(l.size||1));var c=n.linearX||n.linearY||n.linearZ;c&&(this.linearVelOverLifetime={x:n.linearX&&be(n.linearX),y:n.linearY&&be(n.linearY),z:n.linearZ&&be(n.linearZ),asMovement:n.asMovement,enabled:!!c});var h=n.orbitalX||n.orbitalY||n.orbitalZ;h&&(this.orbitalVelOverLifetime={x:n.orbitalX&&be(n.orbitalX),y:n.orbitalY&&be(n.orbitalY),z:n.orbitalZ&&be(n.orbitalZ),center:$t(n.orbCenter),asRotation:n.asRotation,enabled:!!h}),this.speedOverLifetime=n.speedOverLifetime&&be(n.speedOverLifetime);var f=t.rotationOverLifetime;if(f&&(this.rotationOverLifetime={asRotation:f.asRotation,separateAxes:f.separateAxes,z:be(f.z||0)},f.separateAxes)){var p=this.rotationOverLifetime;p.x=be(f.x||0),p.y=be(f.y||0)}this.gravityModifier=this.options.gravityModifier}return t.prototype.getVelocity=function(){return this.velocity||(this.velocity=this.options.direction.clone().multiply(this.options.startSpeed)),this.velocity},t.prototype.willTranslate=function(){return!!(this.linearVelOverLifetime&&this.linearVelOverLifetime.enabled||this.orbitalVelOverLifetime&&this.orbitalVelOverLifetime.enabled||this.options.gravityModifier&&!this.options.gravity.isZero()||this.options.startSpeed&&!this.options.direction.isZero())},t.prototype.updatePosition=function(t,e,r){this.basicTransform.position.set(t,e,r)},t.prototype.updateRotation=function(t,e,r){this.basicTransform.rotation.set(t,e,r)},t.prototype.getRenderData=function(t,e){var r,i,n=this.options,o=Pe.setFromNumber(1),s=Ie.set(0,0,0),a=t<0?t:Math.max(t,0),u=n.duration,l=a/u,c={life:l,transform:this.transform,startSize:this.basicTransform.scale.clone()},h=this.basicTransform;l=l<0?0:l>1?1:l,this.sizeXOverLifetime&&(o.x=this.sizeXOverLifetime.getValue(l),this.sizeSeparateAxes?(o.y=this.sizeYOverLifetime.getValue(l),o.z=this.sizeZOverLifetime.getValue(l)):o.z=o.y=o.x,r=!0),(r||e)&&c.transform.setScale(o.x,o.y,o.z);var f,p=this.rotationOverLifetime;if(p){var d=function(t){return p.asRotation?t.getValue(l):t.getIntegrateValue(0,l,u)},m=d(p.z),v=p.separateAxes;s.x=v?d(p.x):0,s.y=v?d(p.y):0,s.z=m,i=!0}if(i||e){var y=Ie.addEulers(h.rotation,s);c.transform.setRotation(y.x,y.y,y.z)}(this.willTranslate()||e)&&(f=Jt(Pe.setFromNumber(0),this,n.gravity,a,u,h.position,this.getVelocity()));if(h.path&&(f||(f=Fe.copyFrom(h.position)),f.add(h.path.getValue(l))),f&&c.transform.setPosition(f.x,f.y,f.z),c.startSize){var g=c.transform.scale;c.transform.setScale(g.x*c.startSize.x,g.y*c.startSize.y,g.z*c.startSize.z)}return c},t}(),Ve="[Galacean Effects]";function De(t){return["%c".concat(Ve),"background: #AA0100; color: white","".concat(t)]}var ze,Be={error:function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];console.error.apply(console,u(u([],a(De(t)),!1),[e],!1)),null==Le||Le("error",t,e)},info:function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];console.debug.apply(console,u([],a(De(t)),!1)),null==Le||Le("info",t,e)},warn:function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];console.warn.apply(console,u([],a(De(t)),!1)),null==Le||Le("warn",t,e)},register:function(t){t&&Xe(t)&&(Le=t)}};function Ue(){}function ke(t){return"string"==typeof t}t.DestroyOptions=void 0,(ze=t.DestroyOptions||(t.DestroyOptions={}))[ze.destroy=0]="destroy",ze[ze.keep=1]="keep",ze[ze.force=0]="force";var Ge=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function Xe(t){return"[object Function]"===Object.prototype.toString.call(t)}function He(t){return"[object Object]"===Object.prototype.toString.call(t)}function Ye(t,e){return t+Math.random()*(e-t)}function je(){throw Error("destroyed item cannot be used again")}var We,Ze=new Lt,qe=1,Ke=function(){function t(t,e){void 0===t&&(t={}),this.position=new Mt(0,0,0),this.quat=new Lt(0,0,0,1),this.rotation=new Dt(0,0,0),this.scale=new Mt(1,1,1),this.anchor=new Mt(0,0,0),this.children=[],this.worldMatrix=Ft.fromIdentity(),this.localMatrix=Ft.fromIdentity(),this.valid=!1,this.dirtyFlags={localData:!1,localMatrix:!1,worldMatrix:!1,parentMatrix:!1},this.worldTRSCache={position:new Mt(0,0,0),quat:new Lt(0,0,0,1),scale:new Mt(1,1,1)},this.name="transform_".concat(qe++),t&&this.setTransform(t),e&&(this.parentTransform=e),void 0!==t.valid&&this.setValid(t.valid)}return t.getRotation=function(t,e){var r=Ze.copyFrom(t);return r.conjugate(),e.setFromQuaternion(r)},Object.defineProperty(t.prototype,"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)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parentMatrixDirty",{get:function(){return this.dirtyFlags.parentMatrix},set:function(t){this.dirtyFlags.parentMatrix!==t&&(this.dirtyFlags.parentMatrix=t,this.dispatchValueChange())},enumerable:!1,configurable:!0}),t.prototype.setPosition=function(t,e,r){this.position.x===t&&this.position.y===e&&this.position.z===r||(this.position.x=t,this.position.y=e,this.position.z=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.translate=function(t,e,r){0===t&&0===e&&0===r||(this.position.x+=t,this.position.y+=e,this.position.z+=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setRotation=function(t,e,r){this.rotation.x===t&&this.rotation.y===e&&this.rotation.z===r||(this.rotation.x=t,this.rotation.y=e,this.rotation.z=r,this.quat.setFromEuler(this.rotation),this.quat.conjugate(),this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setQuaternion=function(t,e,r,i){this.quat.x===t&&this.quat.y===e&&this.quat.z===r&&this.quat.w===i||(this.quat.x=t,this.quat.y=e,this.quat.z=r,this.quat.w=i,this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setScale=function(t,e,r){this.scale.x===t&&this.scale.y===e&&this.scale.z===r||(this.scale.x=t,this.scale.y=e,this.scale.z=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.rotateByQuat=function(t){this.quat.multiply(t),this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange()},t.prototype.scaleBy=function(t,e,r){this.scale.x*=t,this.scale.y*=e,this.scale.z*=r,this.dirtyFlags.localData=!0,this.dispatchValueChange()},t.prototype.setAnchor=function(t,e,r){this.anchor.x===t&&this.anchor.y===e&&this.anchor.z===r||(this.anchor.x=t,this.anchor.y=e,this.anchor.z=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setTransform=function(t,e){var r,i=t.position,n=t.rotation,o=t.scale,s=t.quat,a=t.name,u=t.anchor;if(a&&(this.name=a),i&&(i instanceof Mt?this.setPosition(i.x,i.y,i.z):this.setPosition(i[0],i[1],i[2])),s)s instanceof Lt?this.setQuaternion(s.x,s.y,s.z,s.w):this.setQuaternion(s[0],s[1],s[2],s[3]);else if(n){var l=e?-1:1;n instanceof Dt?this.setRotation(n.x*l,n.y*l,n.z*l):this.setRotation(n[0]*l,n[1]*l,n[2]*l)}o&&(o instanceof Mt?this.setScale(o.x,o.y,o.z):this.setScale(o[0],o[1],o[2])),u&&(u instanceof Mt?this.setAnchor(u.x,u.y,u.z):this.setAnchor(u[0],u[1],null!==(r=u[2])&&void 0!==r?r:0))},t.prototype.addChild=function(t){z(this.children,t)},t.prototype.removeChild=function(t){B(this.children,t)},t.prototype.getRotation=function(){return t.getRotation(this.quat,new Dt)},t.prototype.getQuaternion=function(){return this.quat},t.prototype.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)},t.prototype.getMatrix=function(){return this.updateLocalMatrix(),this.localMatrix},t.prototype.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},t.prototype.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},t.prototype.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()},t.prototype.getWorldPosition=function(){return this.updateTRSCache(),this.worldTRSCache.position.clone()},t.prototype.getWorldRotation=function(){return this.updateTRSCache(),t.getRotation(this.worldTRSCache.quat,new Dt)},t.prototype.assignWorldTRS=function(t,e,r){this.updateTRSCache(),t&&t.copyFrom(this.worldTRSCache.position),e&&e.copyFrom(this.worldTRSCache.quat),r&&r.copyFrom(this.worldTRSCache.scale)},t.prototype.cloneFromMatrix=function(t,e){t.decompose(this.position,this.quat,this.scale),e&&e.copyFrom(this.scale),this.dirtyFlags.localData=!0,this.dispatchValueChange()},t.prototype.setValid=function(t){this.valid!==t&&(this.valid=t,t?this.dirtyFlags.localData=!0:(this.localMatrix.identity(),this.dirtyFlags.localMatrix=!0),this.dispatchValueChange())},t.prototype.getValid=function(){return this.valid},t.prototype.dispose=function(){},t.prototype.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}},t.prototype.dispatchValueChange=function(){this.children.forEach((function(t){t.parentMatrixDirty=!0}))},t}(),Qe=function(){function t(t,e){this._v_priority=0,this.visible=!0,this._contentVisible=!1,this.timeInms=0,this.time=0,this._frozen=!1;var r=t.id,n=t.name,o=t.delay,s=t.parentId,a=t.endBehavior,u=t.transform,l=t.listIndex,c=void 0===l?0:l,h=t.duration,p=void 0===h?0:h;if(this.composition=e,this.id=r,this.name=n,this.delay=o,this.transform=new Ke(i({name:this.name},u),e.transform),this.parentId=s,this.duration=p,this.delayInms=1e3*(o||0),this.durInms=1e3*this.duration,this.endBehavior=a,this.lifetime=-this.delayInms/this.durInms,this.listIndex=c,this.speed=1,this.onConstructed(t),p<=0)throw Error("Item duration can't be less than 0, see ".concat(f["Item duration can't be less than 0"]))}return t.isComposition=function(t){return t.type===w.composition},t.isSprite=function(t){return t.type===w.sprite},t.isParticle=function(t){return t.type===w.particle},t.isFilterSprite=function(t){return t.type===w.filter},t.isNull=function(t){return t.type===w.null},t.isTree=function(t){return t.type===w.tree},t.isCamera=function(t){return t.type===w.camera},t.isExtraCamera=function(t){return"extra-camera"===t.id&&"extra-camera"===t.name},Object.defineProperty(t.prototype,"contentVisible",{get:function(){return this._contentVisible&&this.visible},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"content",{get:function(){return this._content},set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reusable",{get:function(){var t,e;return null!==(e=null===(t=this.composition)||void 0===t?void 0:t.reusable)&&void 0!==e&&e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return w.base},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frozen",{get:function(){return this._frozen},set:function(t){this.handleFrozenChanged(this._frozen=!!t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lifetimeStarted",{get:function(){return this.started&&!this.delaying},enumerable:!1,configurable:!0}),t.prototype.setSpeed=function(t){this.speed=t},t.prototype.getSpeed=function(){return this.speed},t.prototype.start=function(){this.started&&!this.ended||(this.started=!0,this.delaying=!0,this.timeInms=0,this.time=0,this.callEnd=!1,this.ended=!1)},t.prototype.stop=function(){this.doStop(),this.started=!1},t.prototype.doStop=function(){this._content&&this._content.stop&&this._content.stop()},t.prototype.createContent=function(){return this._content||(this._content=this.doCreateContent(this.composition)),this._content},t.prototype.doCreateContent=function(t){},t.prototype.onConstructed=function(t){},t.prototype.onUpdate=function(t){var e,r;if(this.started&&!this.frozen&&this.composition){var i=t*this.speed,n=this.timeInms+=i;this.time+=i/1e3;var o=n-this.delayInms;if(this.delaying&&o>=0&&(this.delaying=!1,this.transform.setValid(!0),this.createContent(),this._contentVisible=!0,this.onLifetimeBegin(this.composition,this.content),this.composition.itemLifetimeEvent(this,!0)),!this.delaying){var s=o/this.durInms,a=this.isEnded(o),u=!0;if(this.transform.setValid(!0),a)if(u=!1,this.callEnd||(this.callEnd=!0,this.composition.itemLifetimeEvent(this,!1),this.onEnd()),2!==this.endBehavior&&5!==this.endBehavior){if(this.ended=!0,this.transform.setValid(!1),1===this.endBehavior||3===this.endBehavior?null===(r=(e=this.composition).onPlayerPause)||void 0===r||r.call(e,this):4===this.endBehavior&&(this.transform.setValid(!0),u=!0,s=1,i=0),this.reusable)0===this.endBehavior&&(this._contentVisible=!1,u=!0,i=0,this.type===w.composition&&this.handleVisibleChanged(!1));else{if(0===this.endBehavior||3===this.endBehavior||6===this.endBehavior)return this.dispose();1===this.endBehavior&&(this.endBehavior=2)}s=Math.min(s,1)}else u=!0,5===this.endBehavior&&(this.ended=!0);else this.callEnd&&this.reusable&&(this.setVisible(!0),this.callEnd=!1);this.lifetime=s%1,u&&this.onItemUpdate(i,s)}}},t.prototype.onItemRemoved=function(t,e){},t.prototype.onItemUpdate=function(t,e){},t.prototype.onLifetimeBegin=function(t,e){},t.prototype.onEnd=function(){},t.prototype.setColor=function(t,e,r,i){},t.prototype.setOpacity=function(t){},t.prototype.getVisible=function(){return this.visible},t.prototype.setVisible=function(t){this.visible!==t&&(this.visible=!!t,this.handleVisibleChanged(this.visible))},t.prototype.handleVisibleChanged=function(t){},t.prototype.handleFrozenChanged=function(t){},t.prototype.getWorldTransform=function(t){var e=null!=t?t:new Ke({valid:!0});return e.cloneFromMatrix(this.transform.getWorldMatrix()),e},t.prototype.getNodeTransform=function(t){return this.transform},t.prototype.translate=function(t,e,r){this.transform.translate(t,e,r)},t.prototype.rotate=function(t,e,r){var i=new Dt(t,e,r),n=Lt.fromEuler(i);n.conjugate(),this.transform.rotateByQuat(n)},t.prototype.scale=function(t,e,r){this.transform.scaleBy(t,e,r)},t.prototype.setPositionByPixel=function(t,e){if(this.composition){var r=this.transform.getWorldPosition().z,i=this.composition.camera.getInverseVPRatio(r),n=i.x,o=i.y,s=this.composition.renderer.getWidth()/2,a=this.composition.renderer.getHeight()/2;this.transform.setPosition(2*t*n/s,-2*e*o/a,r)}},t.prototype.setPosition=function(t,e,r){this.transform.setPosition(t,e,r)},t.prototype.setRotation=function(t,e,r){this.transform.setRotation(t,e,r)},t.prototype.setScale=function(t,e,r){this.transform.setScale(t,e,r)},t.prototype.getBoundingBox=function(){},t.prototype.getHitTestParams=function(t){},t.prototype.getRenderData=function(){return{transform:this.transform,life:0,visible:this.visible}},t.prototype.getCurrentPosition=function(){var t=new Mt;return this.transform.assignWorldTRS(t),t},t.prototype.isEnded=function(t){return t-this.durInms>.001},t.prototype.reset=function(){this.composition&&(this.onItemRemoved(this.composition,this._content),this._content=void 0,this._contentVisible=!1),this.started=!1},t.prototype.translateByPixel=function(t,e){if(this.composition){var r=this.transform.getWorldPosition().z,i=this.composition.camera.getInverseVPRatio(r),n=i.x,o=i.y,s=this.composition.renderer.getWidth()/2,a=this.composition.renderer.getHeight()/2;this.transform.translate(2*t*n/s,-2*e*o/a,0)}},t.prototype.dispose=function(){this.composition&&(this.composition.destroyItem(this),this.reset(),this.onUpdate=function(){return-1},this.composition=null,this._contentVisible=!1,this.transform.setValid(!1))},t}();function Je(t,e){var r=t.type,i=t.pluginName;if(!i)switch(r){case w.null:case w.base:i="cal";break;case w.sprite:i="sprite";break;case w.particle:i="particle";break;case w.interact:i="interact";break;case w.camera:i="camera";break;case w.filter:i="filter";break;case w.text:i="text";break;case w.tree:i="tree";break;default:throw new Error("invalid vfx item type")}return e.pluginSystem.createPluginItem(i,t,e)}t.Item=void 0,(We=t.Item||(t.Item={})).is=function(t,e){return t.type===e},We.isFilter=function(t){return t.type===w.filter},We.isComposition=function(t){return t.type===w.composition},We.isParticle=function(t){return t.type===w.particle},We.isNull=function(t){return t.type===w.null};var $e={},tr=[],er={};function rr(t,e,r,i){er[t]=r,$e[t]=e,i&&z(tr,t)}var ir=function(){function t(t){var e={},r=[],i=function(t){var i=$e[t];r.includes(i)||(r.push(i),e[t]=i)};tr.forEach(i),t.forEach(i),this.plugins=Object.keys(e).map((function(t){var e=$e[t];if(!e)throw new Error("plugin '".concat(t,"' not found.")+function(t){var e=nr[t];return e?"\nInstall Plugin: npm i ".concat(e,"@latest --save\nImport Plugin: import '").concat(e,"'"):""}(t));var r=new e;return r.name=t,r})).sort((function(t,e){return t.order-e.order}))}return t.prototype.initializeComposition=function(t,e){this.plugins.forEach((function(r){return r.onCompositionConstructed(t,e)}))},t.prototype.destroyComposition=function(t){this.plugins.forEach((function(e){return e.onCompositionDestroyed(t)}))},t.prototype.resetComposition=function(t,e){this.plugins.forEach((function(r){return r.onCompositionReset(t,e)}))},t.prototype.createPluginItem=function(t,e,r){var i=er[t];if(!i)throw new Error("plugin ".concat(t," no registered constructor"));var n=new i(e,r);if(!(n instanceof Qe))throw new Error("plugin ".concat(t," invalid constructor type"));return n},t.prototype.processRawJSON=function(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){return[2,this.callStatic("processRawJSON",t,e)]}))}))},t.prototype.callStatic=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return n(this,void 0,void 0,(function(){var r,i,n,s,l;return o(this,(function(o){for(r=[],i=this.plugins,n=0;n<i.length;n++)s=i[n],l=$e[s.name],t in l&&r.push(Promise.resolve(l[t].apply(l,u([],a(e),!1))));return[2,Promise.all(r)]}))}))},t.prototype.precompile=function(t,e,r){return n(this,void 0,void 0,(function(){return o(this,(function(i){return[2,this.callStatic("precompile",t,e,r)]}))}))},t.prototype.loadResources=function(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){return[2,this.callStatic("prepareResource",t,e)]}))}))},t}(),nr={"alipay-downgrade":"@galacean/effects-plugin-alipay-downgrade","editor-gizmo":"@galacean/effects-plugin-editor-gizmo",tree:"@galacean/effects-plugin-model",model:"@galacean/effects-plugin-model","orientation-transformer":"@galacean/effects-plugin-orientation-transformer",spine:"@galacean/effects-plugin-spine"};var or,sr=function(){function t(){this.order=100,this.name=""}return t.precompile=function(t,e){return Promise.resolve()},t.prototype.onCompositionConstructed=function(t,e){},t.prototype.onCompositionItemLifeBegin=function(t,e){},t.prototype.onCompositionItemLifeEnd=function(t,e){},t.prototype.onCompositionItemRemoved=function(t,e){},t.prototype.onCompositionReset=function(t,e){},t.prototype.onCompositionWillReset=function(t,e){},t.prototype.onCompositionDestroyed=function(t){},t.prototype.onCompositionUpdate=function(t,e){},t.prototype.prepareRenderFrame=function(t,e){return!1},t.prototype.postProcessFrame=function(t,e){},t}(),ar=function(){function t(t,e){this.transform=t;var r=t.position,i=t.getRotation(),n=e.options,o=n.near,s=n.far,a=n.fov,u=n.clipMode;if(this.clipMode=u,this.options={position:r.clone(),rotation:i.clone(),near:be(o),far:be(s),fov:be(a)},e.positionOverLifetime){var l=e.positionOverLifetime,c=l.path,h=l.linearX,f=void 0===h?0:h,p=l.linearY,d=void 0===p?0:p,m=l.linearZ,v=void 0===m?0:m;this.translateOverLifetime={path:c&&be(c),x:be(f),y:be(d),z:be(v)}}if(e.rotationOverLifetime){var y=e.rotationOverLifetime,g=y.separateAxes,x=y.x,T=void 0===x?0:x,E=y.y,S=void 0===E?0:E,b=y.z,A=void 0===b?0:b;this.rotationOverLifetime={separateAxes:g,x:be(T),y:be(S),z:be(A)}}}return t.prototype.update=function(t){var e=new Lt,r=new Mt,i=new Dt;r.copyFrom(this.options.position),i.copyFrom(this.options.rotation);var n=this.translateOverLifetime,o=this.rotationOverLifetime;if(t=Rt(t,0,1),n&&(r.x+=n.x.getValue(t),r.y+=n.y.getValue(t),r.z+=n.z.getValue(t),n.path)){var s=n.path.getValue(t);r.x+=s[0],r.y+=s[1],r.z+=s[2]}if(o){var a=o.z.getValue(t);i.z+=a,o.separateAxes?(i.x+=o.x.getValue(t),i.y+=o.y.getValue(t)):(i.x+=a,i.y+=a)}this.far=this.options.far.getValue(t),this.near=this.options.near.getValue(t),this.fov=this.options.fov.getValue(t),this.transform.setPosition(r.x,r.y,r.z),this.transform.setRotation(i.x,i.y,i.z),this.transform.assignWorldTRS(r,e),this.position=r,this.rotation=Ke.getRotation(e,i)},t}(),ur=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(sr),lr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return w.camera},enumerable:!1,configurable:!0}),e.prototype.onConstructed=function(t){this.model=t.content},e.prototype.onItemUpdate=function(t,e){var r;null===(r=this.controller)||void 0===r||r.update(e),this.updateCamera()},e.prototype.updateCamera=function(){if(this.controller&&this.composition){var t=this.composition.camera;t.near=this.controller.near,t.far=this.controller.far,t.fov=this.controller.fov,t.clipMode=this.controller.clipMode,t.position=this.controller.position,t.rotation=this.controller.rotation}},e.prototype.getCurrentPosition=function(){return this.controller.position},e.prototype.doCreateContent=function(){return this.controller||(this.controller=new ar(this.transform,this.model)),this.controller},e}(Qe);t.HitTestType=void 0,(or=t.HitTestType||(t.HitTestType={}))[or.triangle=1]="triangle",or[or.box=2]="box",or[or.sphere=3]="sphere",or[or.custom=4]="custom";var cr,hr,fr="click",pr="touchstart",dr="touchmove",mr="touchend",vr=O,yr=function(){function t(t,e){void 0===e&&(e=!1),this.target=t,this.allowPropagation=e,this.enabled=!0,this.handlers={},this.nativeHandlers={}}return t.prototype.bindListeners=function(){var t,e,r,i,n,o,s=this;o=function(t){return t};var a="mousedown",u="mousemove",l="mouseup",c=function(t,e,r,i,o){void 0===i&&(i=0),void 0===o&&(o=0);var a=s.target,u=a.width,l=a.height,c=performance.now(),h=0,f=0;if(n){var p=c-n.ts;h=(i-n.dx)/p||0,f=(o-n.dy)/p||0,n={dx:i,dy:o,ts:c}}return{x:e,y:r,vx:h,vy:f,dx:i,dy:o,ts:c,width:u,height:l,origin:t}};q()&&(o=function(t){var e=t,r=e.touches,i=e.changedTouches;return r[0]||i[0]},a="touchstart",u="touchmove",l="touchend"),this.nativeHandlers=((t={})[a]=function(t){if(s.enabled){var a=o(t),u=gr(a);e=u.x,r=u.y,n=i={clientX:a.clientX,clientY:a.clientY,ts:performance.now(),x:e,y:r},s.dispatchEvent(pr,c(t,e,r))}},t[u]=function(t){if(i&&s.enabled){var n=gr(o(t));e=n.x,r=n.y,s.dispatchEvent(dr,c(t,e,r,e-i.x,r-i.y))}},t[l]=function(t){if(i&&s.enabled){!s.allowPropagation&&t.cancelable&&(t.preventDefault(),t.stopPropagation());var n=o(t),a=gr(n),u=Math.abs(i.clientX-n.clientX)+Math.abs(i.clientY-n.clientY);e=a.x,r=a.y,u<4&&s.dispatchEvent(fr,c(t,e,r)),s.dispatchEvent(mr,c(t,e,r,e-i.x,r-i.y))}i=0},t),Object.keys(this.nativeHandlers).forEach((function(t){var e;null===(e=s.target)||void 0===e||e.addEventListener(String(t),s.nativeHandlers[t])}))},t.prototype.dispatchEvent=function(t,e){var r=this.handlers[t];null==r||r.forEach((function(t){return t(e)}))},t.prototype.addEventListener=function(t,e){var r=this.handlers[t];return r||(r=this.handlers[t]=[]),z(r,e),function(){B(r,e)}},t.prototype.removeEventListener=function(t,e){var r=this.handlers[t];r&&B(r,e)},t.prototype.dispose=function(){var t=this;this.target&&(this.handlers={},Object.keys(this.nativeHandlers).forEach((function(e){var r;null===(r=t.target)||void 0===r||r.removeEventListener(String(e),t.nativeHandlers[e])})),this.nativeHandlers={},this.target=null)},t}();function gr(t){var e=t.target,r=t.clientX,i=t.clientY,n=e.getBoundingClientRect(),o=n.left,s=n.top;return{x:(r-o)/n.width*2-1,y:1-(i-s)/n.height*2}}function xr(t){switch(t){case S.ALPHA:case S.ADD:case S.SUBTRACTION:case S.STRONG_LIGHT:case S.WEAK_LIGHT:return 1;case S.SUPERPOSITION:return 2;case S.BRIGHTNESS:return 3;case S.MULTIPLY:return 0;default:return 1}}t.ShaderType=void 0,(cr=t.ShaderType||(t.ShaderType={}))[cr.vertex=0]="vertex",cr[cr.fragment=1]="fragment";var Tr,Er,Sr=((hr={})[t.ShaderType.vertex]={in:"attribute",out:"varying"},hr[t.ShaderType.fragment]={in:"varying"},hr);function br(t,e,r,i){var n=[],o="";n.push("#define GE_RUNTIME"),t&&(t.forEach((function(t){var e=a(t,2),r=e[0],i=e[1];!0===i?n.push("#define ".concat(r)):Number.isFinite(i)&&n.push("#define ".concat(r," ").concat(i))})),o=n.length?n.join("\n")+"\n":"");var s="WEBGL".concat(i),u=(o+="\n#ifndef ".concat(s,"\n#define ").concat(s,"\n#endif"))+"\n"+e,l=u.match(/#version\s+\b\d{3}\b\s*(es)?/),c=l?l[0]:"";if(c&&c.includes("300")){var h=new RegExp("".concat(c),"g");1===i&&(u=u.replace(/\b(in|out)\b/g,(function(t){var e;return null!==(e=Sr[r][t])&&void 0!==e?e:t}))),u=u.replace(h,"\n")}return u}function Ar(t,e){switch(e){case void 0:case S.ALPHA:t.blendFunction=[v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA];break;case S.ADD:t.blendFunction=[v.ONE,v.ONE,v.ONE,v.ONE];break;case S.SUBTRACTION:t.blendFunction=[v.ONE,v.ONE,v.ZERO,v.ONE],t.blendEquation=[v.FUNC_REVERSE_SUBTRACT,v.FUNC_REVERSE_SUBTRACT];break;case S.SUPERPOSITION:t.blendFunction=[v.ONE,v.ONE,v.ONE,v.ONE];break;case S.MULTIPLY:t.blendFunction=[v.DST_COLOR,v.ONE_MINUS_SRC_ALPHA,v.DST_COLOR,v.ONE_MINUS_SRC_ALPHA];break;case S.BRIGHTNESS:t.blendFunction=[v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA];break;case S.STRONG_LIGHT:t.blendFunction=[v.DST_COLOR,v.DST_ALPHA,v.ZERO,v.ONE];break;case S.WEAK_LIGHT:t.blendFunction=[v.DST_COLOR,v.ZERO,v.ZERO,v.ONE];break;default:console.warn("blendMode ".concat(e," not in specification, please set blend params separately"))}}function _r(t,e){e===b.DOUBLE?t.culling=!1:(t.culling=!0,t.frontFace=v.CW,t.cullFace=e===b.BACK?v.BACK:v.FRONT)}function Cr(t,e){switch(e){case void 0:t.stencilTest=!1;break;case A.MASK:t.stencilTest=!0,t.stencilFunc=[v.ALWAYS,v.ALWAYS],t.stencilOpZPass=[v.REPLACE,v.REPLACE];break;case A.OBSCURED:t.stencilTest=!0,t.stencilFunc=[v.EQUAL,v.EQUAL];break;case A.REVERSE_OBSCURED:t.stencilTest=!0,t.stencilFunc=[v.NOTEQUAL,v.NOTEQUAL];break;case A.NONE:t.stencilTest=!1;break;default:console.warn("maskMode ".concat(e," not in specification, please set stencil params seperately"))}}t.TextureLoadAction=void 0,(Tr=t.TextureLoadAction||(t.TextureLoadAction={}))[Tr.whatever=0]="whatever",Tr[Tr.clear=2]="clear",t.TextureSourceType=void 0,(Er=t.TextureSourceType||(t.TextureSourceType={}))[Er.none=0]="none",Er[Er.data=1]="data",Er[Er.image=2]="image",Er[Er.compressed=3]="compressed",Er[Er.video=4]="video",Er[Er.canvas=5]="canvas",Er[Er.framebuffer=6]="framebuffer",Er[Er.mipmaps=7]="mipmaps";var Rr=function(){function t(){this.callbacks={}}return t.prototype.downloadJSON=function(t,e,r){this.download(t,"json",e,r)},t.prototype.downloadBinary=function(t,e,r){this.download(t,"arraybuffer",e,r)},t.prototype.downloadBlob=function(t,e,r){this.download(t,"blob",e,r)},t.prototype.download=function(t,e,r,i){var n=this;if(void 0===e&&(e="json"),!this.start(t,r,i)){var o=new XMLHttpRequest,s=function(){n.finish(t,o.status,o.response)};o.responseType=e,o.addEventListener("load",(function(){200==o.status||0==o.status?n.finish(t,200,o.response):s()})),o.addEventListener("error",s),o.open("GET",t,!0),o.send()}},t.prototype.start=function(t,e,r){var i=this.callbacks[t];try{if(i)return!0;this.callbacks[t]=i=[]}finally{i.push(e,r)}},t.prototype.finish=function(t,e,r){var i=this.callbacks[t];delete this.callbacks[t];for(var n=200==e||0==e?[r]:[e,r],o=n.length-1,s=i.length;o<s;o+=2)i[o].apply(null,n)},t}(),Or=!1;function wr(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return!Or&&e?[3,2]:[4,Mr(t)];case 1:case 5:return[2,{image:r.sent(),url:t}];case 2:return r.trys.push([2,4,,6]),[4,Mr(e)];case 3:return[2,{image:r.sent(),url:e}];case 4:return r.sent(),Or=!0,[4,Mr(t)];case 6:return[2]}}))}))}function Mr(t){return n(this,void 0,void 0,(function(){var e,r;return o(this,(function(i){if(e="",t instanceof HTMLImageElement){if(t.complete)return[2,t];e=t.src}else t instanceof Blob?(e=URL.createObjectURL(t),r=!0):"string"==typeof t&&(e=t);if(!e)throw new Error("Invalid url type: ".concat(JSON.stringify(t)));return[2,new Promise((function(t,i){var n=new Image;/^data:/.test(e)||(n.crossOrigin="*"),n.onload=function(){return n.onload=null,r&&URL.revokeObjectURL(e),t(n)},n.onerror=function(t){return n.onerror=null,r&&URL.revokeObjectURL(e),i("Load image fail: ".concat(e,", reason: ").concat(JSON.stringify(t)))},n.src=e}))]}))}))}function Lr(t){return n(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new Promise((function(e,r){(new Rr).downloadBinary(t,e,(function(e,i){r("Couldn't load bins ".concat(t,": status ").concat(e,", ").concat(i))}))}))]}))}))}function Ir(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var r;return o(this,(function(i){return r=document.createElement("video"),"string"==typeof t?r.src=t:r.srcObject=t,r.crossOrigin="anonymous",r.muted=!0,e.loop&&r.addEventListener("ended",(function(){return r.play()})),Z()&&r.setAttribute("renderer","standard"),r.setAttribute("playsinline","playsinline"),[2,new Promise((function(t,e){var i=r.play();i?i.then((function(){return t(r)})):r.addEventListener("loadeddata",(function e(){t(r),r.removeEventListener("loadeddata",e)}),!0),r.addEventListener("error",(function(t){e(t)}))}))]}))}))}function Pr(e,r,s){return void 0===s&&(s=[]),n(this,void 0,void 0,(function(){var n,a,u,l,c,h,f;return o(this,(function(o){switch(o.label){case 0:return 34067!==e.target?[3,2]:(u=(n=e).mipmaps,l=n.target,c=u.map((function(t){return Promise.all(t.map((function(t){return Fr(t,r)})))})),[4,Promise.all(c)]);case 1:return h=o.sent(),f=s[u[0][0][1][0]].url,[2,i(i({keepImageSource:!1},e),{mipmaps:h,sourceFrom:{target:l,bin:f,type:t.TextureSourceType.mipmaps,mipmaps:u.map((function(t){return t.map((function(t){return[t[1][1],t[1][2]]}))}))}})];case 2:return u=(a=e).mipmaps,l=a.target,c=u.map((function(t){return Fr(t,r)})),[4,Promise.all(c)];case 3:return h=o.sent(),f=s[u[0][1][0]].url,[2,i(i({keepImageSource:!1},e),{mipmaps:h,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{target:l,bin:f,type:t.TextureSourceType.mipmaps,mipmaps:u.map((function(t){return[t[1][1],t[1][2]]}))}})]}}))}))}function Fr(t,e){return n(this,void 0,void 0,(function(){var r,i,n,s,u;return o(this,(function(o){if(r=a(t[1],3),i=r[0],n=r[1],s=r[2],!(u=e[i]))throw new Error("invalid bin pointer: ".concat(JSON.stringify(t)));return[2,Mr(new Blob([new Uint8Array(u,n,s)]))]}))}))}var Nr=1,Vr=function(){function e(){this.destroyed=!1,this.id="Tex"+Nr++}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.getWidth=function(){return this.width||0},e.prototype.getHeight=function(){return this.height||0},e.prototype.uploadCurrentVideoFrame=function(){},e.prototype.offloadData=function(){},e.prototype.reloadData=function(){},e.prototype.initialize=function(){},e.prototype.assembleOptions=function(e){var r=e.target,n=void 0===r?v.TEXTURE_2D:r,o=e.format,s=void 0===o?v.RGBA:o;return e.sourceType||(e.sourceType="image"in e?t.TextureSourceType.image:"data"in e?t.TextureSourceType.data:"video"in e?t.TextureSourceType.video:0),i({minFilter:v.NEAREST,magFilter:v.NEAREST,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE,target:n,format:v.RGBA,internalFormat:s,type:v.UNSIGNED_BYTE},e)},e}();function Dr(t,e,r,i){var n,o,s=e.length/r/i;return o=n=4===s||0===s?v.RGBA:3===s?v.RGB:2===s?v.LUMINANCE_ALPHA:v.LUMINANCE,Vr.createWithData(t,{data:e,width:r,height:i},{type:v.HALF_FLOAT,format:n,internalFormat:o,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE})}var zr=function(){function t(t,e,r){void 0===r&&(r=0),this.arrayBuffer=t,this.baseOffset=r;var i=new Uint8Array(this.arrayBuffer,this.baseOffset,12);if(171!==i[0]||75!==i[1]||84!==i[2]||88!==i[3]||32!==i[4]||49!==i[5]||49!==i[6]||187!==i[7]||13!==i[8]||10!==i[9]||26!==i[10]||10!==i[11])throw Error("texture missing KTX identifier");var n=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(this.arrayBuffer,this.baseOffset+12,13*n),s=67305985===o.getUint32(0,!0);this.glType=o.getUint32(1*n,s),this.glTypeSize=o.getUint32(2*n,s),this.glFormat=o.getUint32(3*n,s),this.glInternalFormat=o.getUint32(4*n,s),this.glBaseInternalFormat=o.getUint32(5*n,s),this.pixelWidth=o.getUint32(6*n,s),this.pixelHeight=o.getUint32(7*n,s),this.pixelDepth=o.getUint32(8*n,s),this.numberOfArrayElements=o.getUint32(9*n,s),this.numberOfFaces=o.getUint32(10*n,s),this.numberOfMipmapLevels=o.getUint32(11*n,s),this.bytesOfKeyValueData=o.getUint32(12*n,s),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:Be.warn("Number of faces expected"+e+", but found "+this.numberOfFaces):Be.warn("Texture arrays not currently supported"):Be.warn("Only 2D textures currently supported")}return t.prototype.mipmaps=function(t){for(var e=[],r=64+this.bytesOfKeyValueData,i=this.pixelWidth,n=this.pixelHeight,o=t?this.numberOfMipmapLevels:1,s=0;s<o;s++){for(var a=new Int32Array(this.arrayBuffer,this.baseOffset+r,1)[0],u=0;u<this.numberOfFaces;u++){var l=new Uint8Array(this.arrayBuffer,this.baseOffset+r+4,a);e.push({data:l,width:i,height:n}),r+=a+4,r+=3-(a+3)%4}i=Math.max(1,.5*i),n=Math.max(1,.5*n)}return e},t}();function Br(e){var r=new zr(e,1),i=r.numberOfMipmapLevels,n=r.pixelWidth,o=r.pixelHeight,s=r.glType,a=r.numberOfFaces,u=r.glInternalFormat,l=r.glFormat,c=i>=Math.floor(Math.log2(Math.max(n,o))+1);return{sourceType:t.TextureSourceType.compressed,type:s,target:6===a?v.TEXTURE_CUBE_MAP:v.TEXTURE_2D,internalFormat:u,format:l,mipmaps:r.mipmaps(c)}}var Ur,kr=function(){function e(){this.reloadPending={}}return e.prototype.reload=function(t){return n(this,void 0,void 0,(function(){var e,r;return o(this,(function(i){switch(i.label){case 0:return e=t.id,this.reloadPending[e]?[2]:t.sourceFrom?(this.reloadPending[e]=!0,[4,this.loadSource(t.sourceFrom)]):[3,2];case 1:return r=i.sent(),t.updateSource(r),this.reloadPending[e]=!1,[3,3];case 2:throw new Error("No source from");case 3:return[2]}}))}))},e.prototype.canOffloadTexture=function(e){if(e){var r=e.type;if(r===t.TextureSourceType.compressed||r===t.TextureSourceType.image){var i=e,n=i.target,o=i.map,s=e.url;return n===v.TEXTURE_CUBE_MAP?"object"==typeof o&&!!o:ke(s)&&s.length>0}if(r===t.TextureSourceType.mipmaps){var a=e,u=a.bin,l=a.mipmaps,c=e,h=(n=c.target,c.maps),f=e.urls;return u?l.length>0:n===v.TEXTURE_CUBE_MAP?h.every((function(t){return"object"==typeof t&&t})):f.every((function(t){return ke(t)&&t.length>0}))}}return!1},e.prototype.loadSource=function(e,r){return n(this,void 0,void 0,(function(){var n,s,a,u,l,c,h,f,p,d,m,y,g,x,T,E,S,b=this;return o(this,(function(o){switch(o.label){case 0:return n=e.type,s=e.target,a=e.map,u=e.url,c=(l=e).bin,h=l.mipmaps,f=e.urls,p=e.maps,s!==v.TEXTURE_CUBE_MAP||n===t.TextureSourceType.mipmaps?[3,2]:[4,this.loadCubeMap(a)];case 1:return d=o.sent(),[2,i(i({},r),{cube:d,target:v.TEXTURE_CUBE_MAP,sourceType:t.TextureSourceType.image,sourceFrom:{type:t.TextureSourceType.image,map:i({},a),target:v.TEXTURE_CUBE_MAP}})];case 2:return n!==t.TextureSourceType.image?[3,4]:[4,Mr(u)];case 3:return m=o.sent(),[2,i(i({},r),{image:m,sourceType:t.TextureSourceType.image,sourceFrom:{type:n,url:u,target:v.TEXTURE_2D}})];case 4:return n!==t.TextureSourceType.video?[3,6]:[4,Ir(u)];case 5:return y=o.sent(),[2,i(i({},r),{video:y,sourceType:t.TextureSourceType.video})];case 6:return n!==t.TextureSourceType.compressed?[3,8]:[4,Lr(u)];case 7:return g=o.sent(),[2,i(i(i({},Br(g)),r),{sourceFrom:{url:u,type:t.TextureSourceType.compressed}})];case 8:return n!==t.TextureSourceType.mipmaps?[3,17]:c?[4,Lr(c)]:[3,13];case 9:return x=o.sent(),T=null!=s?s:v.TEXTURE_2D,E=T===v.TEXTURE_2D?h.slice():h.map((function(t){return t.slice()})),S=void 0,s!==v.TEXTURE_CUBE_MAP?[3,11]:[4,Promise.all(h.map((function(t){return b.loadMipmapImages(t,x)})))];case 10:return S=o.sent(),[3,12];case 11:S=this.loadMipmapImages(h,x),o.label=12;case 12:return[2,i(i({},r),{mipmaps:S,target:T,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{bin:c,mipmaps:E,target:T,type:t.TextureSourceType.mipmaps}})];case 13:return s!==v.TEXTURE_2D&&s?[3,15]:[4,Promise.all(f.map((function(t){return Mr(t)})))];case 14:return S=o.sent(),[2,i(i({},r),{mipmaps:S,target:v.TEXTURE_2D,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{type:n,urls:f.slice(),target:v.TEXTURE_2D}})];case 15:return s!==v.TEXTURE_CUBE_MAP?[3,17]:[4,Promise.all(p.map((function(t){return b.loadCubeMap(t)})))];case 16:return S=o.sent(),[2,i(i({},r),{mipmaps:S,target:v.TEXTURE_CUBE_MAP,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{type:n,maps:p.map((function(t){return i({},t)})),target:v.TEXTURE_CUBE_MAP}})];case 17:throw new Error("Invalid resource type: ".concat(n))}}))}))},e.prototype.loadMipmapImages=function(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){return[2,Promise.all(t.map((function(t){return Mr(new Blob([new Uint8Array(e,t[0],t[1])]))})))]}))}))},e.prototype.loadCubeMap=function(t){return n(this,void 0,void 0,(function(){return o(this,(function(e){return[2,Promise.all(t.map((function(t){return Mr(t)})))]}))}))},e}();function Gr(){return Ur||(Ur=new kr),Ur}var Xr,Hr=function(){function t(t){this.destroyed=!1;var e=t.name,r=void 0===e?"defaultDataBlock":e;this.name=r}return t.prototype.setUniformValues=function(t){var e=this;Object.keys(t).forEach((function(r){e.setUniformValue(r,t[r])}))},t.prototype.invalidAllFlags=function(){},t.prototype.updateUniformSubData=function(t,e,r){},t}();function Yr(t){return"object"==typeof t&&t&&void 0===t.length&&t instanceof Vr}t.MaterialRenderType=void 0,(Xr=t.MaterialRenderType||(t.MaterialRenderType={}))[Xr.normal=0]="normal",Xr[Xr.transformFeedback=1]="transformFeedback";var jr,Wr,Zr=1,qr=function(){function e(e){this.props=e,this.destroyed=!1,this.initialized=!1;var r=e.name,n=void 0===r?"Material"+Zr++:r,o=e.renderType,s=void 0===o?t.MaterialRenderType.normal:o,a=e.shader,u=e.uniformSemantics;this.name=n,this.renderType=s,this.shaderSource=a,this.uniformSemantics=i({},u)}return Object.defineProperty(e.prototype,"blending",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendFunction",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendEquation",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilTest",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilRef",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFunc",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpZPass",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"culling",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontFace",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendColor",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthRange",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polygonOffsetFill",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polygonOffset",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sampleAlphaToCoverage",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorMask",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilMask",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpFail",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpZFail",{set:function(t){},enumerable:!1,configurable:!0}),e.prototype.initialize=function(){},e.prototype.use=function(t,e){},e}(),Kr="uniform vec2 uFilterSourceSize;uniform sampler2D uFilterSource;\n#define INTERPOLATION 1\nvec4 filterMain(vec2 texCoord,sampler2D tex){\n#ifdef INTERPOLATION\nvec2 texInPixel=texCoord*uFilterSourceSize;vec2 coordMin=floor(texInPixel);vec2 pp=texInPixel-coordMin;vec4 fCoord=vec4(coordMin/uFilterSourceSize,(coordMin+vec2(1.))/uFilterSourceSize);vec4 cLT=texture2D(uFilterSource,vec2(fCoord.x,fCoord.w));vec4 cLB=texture2D(uFilterSource,vec2(fCoord.x,fCoord.y));vec4 cRT=texture2D(uFilterSource,vec2(fCoord.z,fCoord.w));vec4 cRB=texture2D(uFilterSource,vec2(fCoord.z,fCoord.y));return mix(mix(cLB,cRB,pp.x),mix(cLT,cRT,pp.x),pp.y);\n#else\nreturn texture2D(uFilterSource,texCoord);\n#endif\n}";t.ShaderCompileResultStatus=void 0,(jr=t.ShaderCompileResultStatus||(t.ShaderCompileResultStatus={}))[jr.noShader=0]="noShader",jr[jr.success=1]="success",jr[jr.fail=2]="fail",jr[jr.compiling=3]="compiling",t.GLSLVersion=void 0,(Wr=t.GLSLVersion||(t.GLSLVersion={})).GLSL1="100",Wr.GLSL3="300 es";var Qr=function(t){this.source=t},Jr="effects-internal-copy",$r="effects-internal-copy-mesh",ti="\n#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#else\n#define vsIn attribute\n#define vsOut varying\n#endif\nprecision highp float;\nvsIn vec2 aPos;\nvsOut vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}",ei="precision mediump float;\n#ifdef WEBGL2\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#else\n#define fsIn varying\n#endif\n".concat(Kr,"\nfsIn vec2 vTex;\n#ifdef WEBGL2\nlayout (location = 0) out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#ifndef WEBGL2\n#extension GL_EXT_frag_depth : enable\n#define gl_FragDepth gl_FragDepthEXT\n#endif\n#endif\nvoid main(){\n fragColor = filterMain(vTex,uFilterSource);\n #ifdef DEPTH_TEXTURE\n gl_FragDepth = texture2D(uDepth,vTex).r;\n #endif\n}\n");function ri(e,r){var i=2===e,n=i?"#version 300 es":"";return{name:Jr,vertex:br([],n+"\n"+ti,t.ShaderType.vertex,e),fragment:br([],n+"\n"+ei,t.ShaderType.fragment,e),glslVersion:i?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1,marcos:[["WEBGL2",!!i],["DEPTH_TEXTURE",!!r]],cacheId:$r+ +r}}var ii,ni={format:v.RGBA,type:v.UNSIGNED_BYTE,minFilter:v.LINEAR,magFilter:v.LINEAR,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE},oi=Symbol("dispose"),si=function(){function e(t){this.textureCache={},this.textureRef={},this.engine=t}return e.prototype.requestColorAttachmentTexture=function(e){var r=this,i=e.width,n=e.height,o=e.name,s={sourceType:t.TextureSourceType.framebuffer,data:{width:i,height:n},name:o},a=[o];Object.getOwnPropertyNames(ni).forEach((function(t){var r,i=null!==(r=e[t])&&void 0!==r?r:ni[t];s[t]=i,a.push(t,i)}));var u=a.join(":"),l=this.textureCache[u];if(l)this.textureRef[u]++;else{var c=this.engine;rt(c),l=Vr.create(c,s),this.textureCache[u]=l,this.textureRef[u]=1,l[oi]=l.dispose,l.dispose=function(){return r.removeTexture(u)}}return l},e.prototype.removeTexture=function(t){var e=this.textureRef[t];if(e<=1){e<0&&console.error("ref count < 0");var r=this.textureCache[t];r&&(r[oi](),r.dispose=r[oi]),delete this.textureCache[t],delete this.textureRef[t]}else this.textureRef[t]=e-1},e.prototype.dispose=function(){var t=this;Object.keys(this.textureCache).forEach((function(e){var r=t.textureCache[e];r[oi](),r.dispose=r[oi]})),this.textureCache={},this.textureRef={},this.engine=void 0},e}(),ai=function(){function t(t){void 0===t&&(t={}),this.semantics=i({},t)}return t.prototype.toObject=function(){return i({},this.semantics)},t.prototype.setSemantic=function(t,e){void 0===e?delete this.semantics[t]:this.semantics[t]=e},t.prototype.getSemanticValue=function(t,e){var r=this.semantics[t];return Xe(r)?r(e):r},t.prototype.hasSemanticValue=function(t){return t in this.semantics},t.prototype.dispose=function(){var t=this;Object.keys(this.semantics).forEach((function(e){delete t.semantics[e]}))},t}(),ui=((ii={})[v.FLOAT]=Float32Array.BYTES_PER_ELEMENT,ii[v.INT]=Int32Array.BYTES_PER_ELEMENT,ii[v.SHORT]=Int16Array.BYTES_PER_ELEMENT,ii[v.BYTE]=Int8Array.BYTES_PER_ELEMENT,ii),li=function(){function t(t){this.name=t}return t.prototype.initialize=function(){},t.prototype.flush=function(){},t}();function ci(t){return t===v.INT?new Int32Array(0):t===v.SHORT?new Int16Array(0):new Float32Array(0)}var hi="lookup_texture",fi="offscreen_canvas",pi={};function di(t){return pi[t]}var mi,vi,yi=1,gi=function(){function e(t,e){this.engine=t,this.destroyed=!1,this.visible=!0;var r=e.material,i=e.geometry,n=e.name,o=void 0===n?"<unnamed>":n,s=e.priority,a=void 0===s?0:s,u=e.worldMatrix,l=void 0===u?Ft.fromIdentity():u;this.id="Mesh"+yi++,this.name=o,this.geometry=i,this.material=r,this.priority=a,this.worldMatrix=l}return Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},set:function(t){this._priority=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.setVisible=function(t){this.visible=t},e.prototype.render=function(t){var e=t.renderingData,r=this.material;e.currentFrame.globalUniforms&&(e.currentCamera&&(t.setGlobalMatrix("effects_MatrixInvV",e.currentCamera.getInverseViewMatrix()),t.setGlobalMatrix("effects_MatrixV",e.currentCamera.getViewMatrix()),t.setGlobalMatrix("effects_MatrixVP",e.currentCamera.getViewProjectionMatrix()),t.setGlobalMatrix("_MatrixP",e.currentCamera.getProjectionMatrix())),t.setGlobalMatrix("effects_ObjectToWorld",this.worldMatrix)),e.currentFrame.editorTransform&&r.setVector4("uEditorTransform",e.currentFrame.editorTransform),r.use(t,e.currentFrame.globalUniforms);var i=this.geometry;i.flush(),t.drawGeometry(i,r)},e.prototype.getVisible=function(){return this.visible},e.prototype.firstGeometry=function(){return this.geometry},e.prototype.setMaterial=function(e,r){r!==t.DestroyOptions.keep&&this.material.dispose(r),this.material=e},e.prototype.restore=function(){},e.prototype.dispose=function(e){if(!this.destroyed){(null==e?void 0:e.geometries)!==t.DestroyOptions.keep&&this.geometry.dispose();var r=null==e?void 0:e.material;r!==t.DestroyOptions.keep&&this.material.dispose(r),this.destroyed=!0,void 0!==this.engine&&(this.engine.removeMesh(this),this.engine=void 0)}},e}(),xi=1e3;t.RenderPassAttachmentStorageType=void 0,(mi=t.RenderPassAttachmentStorageType||(t.RenderPassAttachmentStorageType={}))[mi.none=0]="none",mi[mi.color=1]="color",mi[mi.stencil_8_opaque=2]="stencil_8_opaque",mi[mi.depth_16_opaque=3]="depth_16_opaque",mi[mi.depth_stencil_opaque=4]="depth_stencil_opaque",mi[mi.depth_16_texture=5]="depth_16_texture",mi[mi.depth_24_stencil_8_texture=6]="depth_24_stencil_8_texture",t.TextureStoreAction=void 0,(vi=t.TextureStoreAction||(t.TextureStoreAction={}))[vi.store=0]="store",vi[vi.clear=2]="clear";var Ti,Ei=function(){function e(e,r){if(this.destroyed=!1,r){var n=r.texture,o=r.size;if(n instanceof Vr)this.texture=n,this.externalTexture=!0;else if(n){var s=n.wrapT,a=n.wrapS,u=n.minFilter,l=n.magFilter,c=n.internalFormat,h=n.format,f=void 0===h?v.RGBA:h,p=n.type,d=void 0===p?v.UNSIGNED_BYTE:p;this.externalTexture=!1,this.textureOptions={size:o,format:f,type:d,internalFormat:c||f,wrapT:s,wrapS:a,minFilter:u,magFilter:l,name:r.name},this.texture=Vr.create(e,i(i({},this.textureOptions),{sourceType:t.TextureSourceType.framebuffer,data:{width:o[0],height:o[1]}}))}}}return e.prototype.dispose=function(){this.destroyed||(this.texture.dispose(),this.destroyed=!0)},Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"storageType",{get:function(){return t.RenderPassAttachmentStorageType.color},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){var t=this.texture;return t?[t.getWidth(),t.getHeight()]:[0,0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this.texture.getWidth()||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.texture.getHeight()||0},enumerable:!1,configurable:!0}),e}();t.RenderPassDestroyAttachmentType=void 0,(Ti=t.RenderPassDestroyAttachmentType||(t.RenderPassDestroyAttachmentType={}))[Ti.force=0]="force",Ti[Ti.keep=1]="keep",Ti[Ti.keepExternal=2]="keepExternal",Ti[Ti.destroy=0]="destroy";var Si=1,bi=function(){function e(e,r){this.attachments=[],this.destroyed=!1,this.initialized=!1;var n=r.name,o=void 0===n?"RenderPass_"+Si++:n,s=r.clearAction,a=r.semantics,u=r.depthStencilAttachment,l=r.storeAction,c=r.priority,h=void 0===c?0:c,f=r.meshOrder,p=void 0===f?t.OrderType.ascending:f,d=r.meshes,m=void 0===d?[]:d,v=r.delegate,y=void 0===v?{}:v;this.name=o,this.renderer=e,this.priority=h,this.meshOrder=p,this.meshes=J(m.slice(),this.meshOrder),this.depthStencilType=(null==u?void 0:u.storageType)||t.RenderPassAttachmentStorageType.none,this.clearAction=i({},s),this.storeAction=i({colorAction:t.TextureStoreAction.store,depthAction:t.TextureStoreAction.store,stencilAction:t.TextureStoreAction.store},l),this.semantics=new ai(a),this.options=r,this.delegate=y,this.setViewportOptions(r)}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewport",{get:function(){return this.getViewport()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilAttachment",{get:function(){return this.getStencilAttachment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthAttachment",{get:function(){return this.getDepthAttachment()},enumerable:!1,configurable:!0}),e.prototype.addMesh=function(t){$(this.meshes,t,this.meshOrder)},e.prototype.removeMesh=function(t){B(this.meshes,t)},e.prototype.setMeshes=function(t){var e;return this.meshes.length=0,(e=this.meshes).splice.apply(e,u([0,0],a(t),!1)),J(this.meshes,this.meshOrder),this.meshes},e.prototype.getInitAttachments=function(){return this.attachments.length>0?this.attachments:this.options.attachments},e.prototype.configure=function(t){if(this.frameBuffer)t.setFrameBuffer(this.frameBuffer);else{var e=a(this.getViewport(),4),r=e[0],i=e[1],n=e[2],o=e[3];t.setViewport(r,i,n,o)}},e.prototype.execute=function(t){t.clear(this.clearAction),t.renderMeshes(this.meshes),t.clear(this.storeAction)},e.prototype.frameCleanup=function(t){},e.prototype.resetColorAttachments=function(e){var r=this;if(e.length||this.resetAttachments({attachments:[]}),this.attachments.length){var i=e.map((function(e){return e.updateSource({sourceType:t.TextureSourceType.framebuffer}),new Ei(r.renderer.engine,{texture:e})}));this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments=i,this.frameBuffer&&(this.frameBuffer.bind(),this.frameBuffer.resetColorTextures(e.map((function(t){return t}))))}else this.resetAttachments({attachments:e.map((function(t){return{texture:t}}))})},e.prototype.resetAttachments=function(t){this.options=t,this.setViewportOptions(t),this.renderer&&this._resetAttachments()},e.prototype.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.prototype._resetAttachments=function(){var e,r,n=this,o=this.renderer,s=this.options;this.attachments.length&&(this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments.length=0,null===(e=this.frameBuffer)||void 0===e||e.dispose({depthStencilAttachment:t.RenderPassDestroyAttachmentType.keepExternal}),this.frameBuffer=null);var a=this.viewportScale,u=this.isCustomViewport?this.customViewport:[0,0,o.getWidth()*a,o.getHeight()*a],l=[u[2],u[3]],c=this.name;if(null===(r=s.attachments)||void 0===r?void 0:r.length){var h=s.attachments.map((function(t,e){var r;return new Ei(n.renderer.engine,i({size:l,name:(null===(r=t.texture)||void 0===r?void 0:r.name)||"".concat(c,"##color_").concat(e)},t))}));this.attachments=h;var f=cn.create({storeAction:this.storeAction,name:c,viewport:u,viewportScale:this.viewportScale,isCustomViewport:this.isCustomViewport,attachments:h.map((function(t){return t.texture})),depthStencilAttachment:s.depthStencilAttachment||{storageType:t.RenderPassAttachmentStorageType.none}},o);f.bind(),f.unbind(),this.frameBuffer=f}else this.attachments.length=0},e.prototype.getViewport=function(){var t,e=(null===(t=this.frameBuffer)||void 0===t?void 0:t.viewport)||this.customViewport;if(e)return e;var r=this.renderer,i=this.viewportScale;return r?[0,0,r.getWidth()*i,r.getHeight()*i]:[0,0,0,0]},e.prototype.getDepthAttachment=function(){var t=this.frameBuffer;if(t)return{storageType:t.depthStencilStorageType,storage:t.depthStorage,texture:t.getDepthTexture()?this.getDepthTexture(t.getDepthTexture(),t.externalStorage):void 0}},e.prototype.getStencilAttachment=function(){var t=this.frameBuffer;if(t)return{storageType:t.depthStencilStorageType,storage:t.stencilStorage,texture:t.getStencilTexture()?this.getStencilTexture(t.getStencilTexture(),t.externalStorage):void 0}},e.prototype.getDepthTexture=function(t,e){var r;if(!this.depthTexture){var i=null===(r=this.options.depthStencilAttachment)||void 0===r?void 0:r.texture,n=t===i?i:t;return e||(this.depthTexture=n),n}return this.depthTexture},e.prototype.getStencilTexture=function(t,e){var r;if(!this.stencilTexture){var i=null===(r=this.options.depthStencilAttachment)||void 0===r?void 0:r.texture,n=t===i?i:t;return e||(this.stencilTexture=n),n}return this.stencilTexture},e.prototype.initialize=function(t){return this.initialized||(this._resetAttachments(),this.initialized=!0),this},e.prototype.dispose=function(e){var r,i;if(!this.destroyed){var n=(null==e?void 0:e.meshes)||void 0;n!==t.DestroyOptions.keep&&this.meshes.forEach((function(t){t.dispose(n)})),this.meshes.length=0;var o=(null==e?void 0:e.colorAttachment)?e.colorAttachment:t.RenderPassDestroyAttachmentType.force;this.attachments.forEach((function(e){e.externalTexture&&o===t.RenderPassDestroyAttachmentType.keepExternal||o===t.RenderPassDestroyAttachmentType.keep||e.dispose()})),this.attachments.length=0,(null==e?void 0:e.semantics)!==t.DestroyOptions.keep&&this.semantics.dispose(),this.destroyed=!0;var s=(null==e?void 0:e.depthStencilAttachment)?e.depthStencilAttachment:t.RenderPassDestroyAttachmentType.force,a=this.frameBuffer;if(a)a.dispose({depthStencilAttachment:s}),a.externalStorage&&s===t.RenderPassDestroyAttachmentType.keepExternal||s===t.RenderPassDestroyAttachmentType.keep||(null===(r=this.stencilTexture)||void 0===r||r.dispose(),null===(i=this.depthTexture)||void 0===i||i.dispose());this.options=this.renderer=null,this.initialize=je}},e}(),Ai="#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(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;}in vec4 vColor;in vec4 vTexCoord;in highp vec2 vParams;uniform vec3 uFrameColor;void main(){fragColor=vec4(uFrameColor.xyz,1.0);}",_i="#version 300 es\nprecision highp float;\n#define SHADER_VERTEX 1\n#define SPRITE_SHADER 1\nin vec4 aPoint;in vec2 aIndex;uniform mat4 uMainData[MAX_ITEM_COUNT];uniform vec4 uTexParams[MAX_ITEM_COUNT];uniform vec4 uTexOffset[MAX_ITEM_COUNT];uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixInvV;uniform mat4 effects_MatrixVP;out vec4 vColor;out vec4 vTexCoord;\n#ifdef ADJUST_LAYER\nout vec2 vFeatherCoord;\n#endif\nout highp vec3 vParams;const float d2r=3.141592653589793/180.;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec4 filterMain(float t,vec4 position);\n#pragma FILTER_VERT\nvec3 rotateByQuat(vec3 a,vec4 quat){vec3 qvec=quat.xyz;vec3 uv=cross(qvec,a);vec3 uuv=cross(qvec,uv)*2.;return a+(uv*2.*quat.w+uuv);}void main(){int index=int(aIndex.x);vec4 texParams=uTexParams[index];mat4 mainData=uMainData[index];float life=mainData[1].z;if(life<0.||life>1.){gl_Position=vec4(3.,3.,3.,1.);}else{vec4 _pos=mainData[0];vec2 size=mainData[1].xy;vec3 point=rotateByQuat(vec3(aPoint.xy*size,0.),mainData[2]);vec4 pos=vec4(_pos.xyz,1.0);float renderMode=texParams.z;if(renderMode==0.){pos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixInvV[0].xyz*point.x+effects_MatrixInvV[1].xyz*point.y;}else if(renderMode==1.){pos.xyz+=point;pos=effects_ObjectToWorld*pos;}else if(renderMode==2.){pos=effects_ObjectToWorld*pos;pos.xy+=point.xy;}else if(renderMode==3.){pos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixInvV[0].xyz*point.x+effects_MatrixInvV[2].xyz*point.y;}gl_Position=effects_MatrixVP*pos;\n#ifdef ADJUST_LAYER\nvec4 filter_Position=filterMain(life,pos);\n#endif\ngl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#ifdef ADJUST_LAYER\nfilter_Position=vec4(filter_Position.xy*uEditorTransform.xy+uEditorTransform.zw*filter_Position.w,filter_Position.zw);\n#endif\n#endif\n#ifdef ADJUST_LAYER\nvTexCoord=vec4(filter_Position.xy/filter_Position.w+1.,gl_Position.xy/gl_Position.w+1.)/2.;vFeatherCoord=aPoint.zw;\n#else\nvec4 texOffset=uTexOffset[index];vTexCoord=vec4(aPoint.zw*texOffset.zw+texOffset.xy,texParams.xy);\n#endif\nvColor=mainData[3];vParams=vec3(aIndex.y,texParams.y,texParams.x);}}",Ci="#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(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 SPRITE_SHADER 1\nin vec4 vColor;in vec4 vTexCoord;in highp vec3 vParams;\n#ifdef ADJUST_LAYER\nuniform sampler2D uSamplerPre;vec4 filterMain(vec2 coord,sampler2D tex);in vec2 vFeatherCoord;uniform sampler2D uFeatherSampler;\n#endif\nuniform sampler2D uSampler0;uniform sampler2D uSampler1;uniform sampler2D uSampler2;uniform sampler2D uSampler3;uniform sampler2D uSampler4;uniform sampler2D uSampler5;uniform sampler2D uSampler6;uniform sampler2D uSampler7;\n#if MAX_FRAG_TEX == 16\nuniform sampler2D uSampler8;uniform sampler2D uSampler9;uniform sampler2D uSampler10;uniform sampler2D uSampler11;uniform sampler2D uSampler12;uniform sampler2D uSampler13;uniform sampler2D uSampler14;uniform sampler2D uSampler15;\n#endif\nvec4 texture2DbyIndex(float index,vec2 coord);\n#pragma FILTER_FRAG\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\nvoid main(){vec4 color=vec4(0.);\n#ifdef ADJUST_LAYER\nvec2 featherCoord=abs(vFeatherCoord-vec2(0.5))/0.5;float cc=sqrt(max(featherCoord.x,featherCoord.y));float blend=vColor.a*texture2D(uFeatherSampler,vec2(cc,0.)).r;if(blend>=1.){color=filterMain(vTexCoord.xy,uSamplerPre);}else if(blend<=0.){color=texture2D(uSamplerPre,vTexCoord.zw);}else{color=mix(texture2D(uSamplerPre,vTexCoord.zw),filterMain(vTexCoord.xy,uSamplerPre),blend);}\n#else\nvec4 texColor=texture2DbyIndex(round(vParams.x),vTexCoord.xy);color=blendColor(texColor,vColor,round(vParams.y));if(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);fragColor=color;}vec4 texture2DbyIndex(float index,vec2 coord){\n#ifndef ADJUST_LAYER\nif(index==0.){return texture2D(uSampler0,coord);}if(index==1.){return texture2D(uSampler1,coord);}if(index==2.){return texture2D(uSampler2,coord);}if(index==3.){return texture2D(uSampler3,coord);}if(index==4.){return texture2D(uSampler4,coord);}if(index==5.){return texture2D(uSampler5,coord);}if(index==6.){return texture2D(uSampler6,coord);}if(index==7.){return texture2D(uSampler7,coord);}\n#if MAX_FRAG_TEX == 16\nif(index==8.){return texture2D(uSampler8,coord);}if(index==9.){return texture2D(uSampler9,coord);}if(index==10.){return texture2D(uSampler10,coord);}if(index==11.){return texture2D(uSampler11,coord);}if(index==12.){return texture2D(uSampler12,coord);}if(index==13.){return texture2D(uSampler13,coord);}if(index==14.){return texture2D(uSampler14,coord);}if(index==15.){return texture2D(uSampler15,coord);}\n#endif\nreturn texture2D(uSampler0,coord);\n#else\nreturn vec4(0.);\n#endif\n}",Ri="#version 300 es\nprecision mediump float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(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\nin float vLife;in vec2 vTexCoord;in 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\nin vec4 vTexCoordBlend;\n#ifdef USE_FILTER\nuniform vec4 uFSprite;\n#endif\n#endif\nin 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(){fragColor=uPreviewColor;}\n#else\n#pragma FILTER_FRAG\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}\n#ifdef USE_FILTER\n#ifdef USE_SPRITE\ntexOffset=uTexOffset/uFSprite.xy;\n#endif\ncolor=filterMain(vTexCoord,uMaskTex);\n#else\nif(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#endif\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);fragColor=color;}\n#endif\n",Oi="#version 300 es\nprecision highp float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\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#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\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\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(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++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).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++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(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;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}float integrateCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;vec4 a=vec4(dt3*dt,dt3,dt2,dt)/vec4(4.*k*k*k,3.*k*k,2.*k,1.);vec4 b=vec4(m0+m1+2.*v0-2.*v1,2.*m0+m1+3.*v0-3.*v1,m0,-v0);return dot(a,b);}float integrateByTimeCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;float k2=k*k;float k3=k2*k;vec4 a=vec4(-30.*k3,10.*k2,5.*k,3.)*vec4(dt,dt2,dt3,dt3*dt);vec4 b=vec4(v0,m0,2.*m0+m1+3.*v0-3.*v1,m0+m1+2.*v0-2.*v1)*vec4(t0+t1,t0+2.*t1,t0+3.*t1,t0+4.*t1);return dot(a,b)/60./k3;}float integrateByTimeFromCurveFrames(float t1,float frameStart,float frameCount){if(t1==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 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(t1>k0.x&&t1<=k1.x){return ret+integrateByTimeCurveFrames(t1,k0,k1);}ret+=integrateByTimeCurveFrames(k1.x,k0,k1);}return ret;}float integrateFromCurveFrames(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 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(time>k0.x&&time<=k1.x){return ret+integrateCurveFrames(time,k0,k1);}ret+=integrateCurveFrames(k1.x,k0,k1);}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;}else 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==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateFromCurveFrames(t1,idx,ilen);return d*value.w+value.z*t1;}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}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==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateByTimeFromCurveFrames(t1,idx,ilen)-integrateByTimeFromCurveFrames(t0,idx,ilen);return d*value.w+value.z*pow(t1-t0,2.)*0.5;}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.;}return 0.;}const float d2r=3.141592653589793/180.;in vec3 aPos;in vec4 aOffset;in vec3 aVel;in vec3 aRot;in vec4 aColor;in vec3 aDirX;in vec3 aDirY;\n#ifdef USE_SPRITE\nin vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);out vec4 vTexCoordBlend;\n#endif\n#pragma EDITOR_VERT_DEFINE\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 uAcceleration;uniform vec4 uGravityModifierValue;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef ROT_X_LIFETIME\nuniform vec4 uRXByLifeTimeValue;\n#endif\n#ifdef ROT_Y_LIFETIME\nuniform vec4 uRYByLifeTimeValue;\n#endif\n#ifdef ROT_Z_LIFETIME\nuniform vec4 uRZByLifeTimeValue;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n#if LINEAR_VEL_X\nuniform vec4 uLinearXByLifetimeValue;\n#endif\n#if LINEAR_VEL_Y\nuniform vec4 uLinearYByLifetimeValue;\n#endif\n#if LINEAR_VEL_Z\nuniform vec4 uLinearZByLifetimeValue;\n#endif\n#endif\n#ifdef SPEED_OVER_LIFETIME\nuniform vec4 uSpeedLifetimeValue;\n#endif\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n#if ORB_VEL_X\nuniform vec4 uOrbXByLifetimeValue;\n#endif\n#if ORB_VEL_Y\nuniform vec4 uOrbYByLifetimeValue;\n#endif\n#if ORB_VEL_Z\nuniform vec4 uOrbZByLifetimeValue;\n#endif\nuniform vec3 uOrbCenter;\n#endif\nuniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nout float vLife;out vec4 vColor;out vec2 vTexCoord;\n#ifdef USE_FILTER\n#pragma FILTER_VERT\n#endif\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;}vec3 calLinearMov(float _life,float _dur){vec3 mov=vec3(0.0);\n#ifdef AS_LINEAR_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if LINEAR_VEL_X\nmov.x=FUNC(uLinearXByLifetimeValue);\n#endif\n#if LINEAR_VEL_Y\nmov.y=FUNC(uLinearYByLifetimeValue);\n#endif\n#if LINEAR_VEL_Z\nmov.z=FUNC(uLinearZByLifetimeValue);\n#endif\n#undef FUNC\nreturn mov;}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\nvec3 calculateTranslation(vec3 vel,float t0,float t1,float dur){float dt=t1-t0;float d=getIntegrateByTimeFromTime(0.,dt,uGravityModifierValue);vec3 acc=uAcceleration.xyz*d;\n#ifdef SPEED_OVER_LIFETIME\nreturn vel*getIntegrateFromTime0(dt/dur,uSpeedLifetimeValue)*dur+acc;\n#endif\nreturn vel*dt+acc;}mat3 transformFromRotation(vec3 rot,float _life,float _dur){vec3 rotation=rot;\n#ifdef ROT_LIFETIME_AS_MOVEMENT\n#define FUNC1(a) getValueFromTime(_life,a)\n#else\n#define FUNC1(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#ifdef ROT_X_LIFETIME\nrotation.x+=FUNC1(uRXByLifeTimeValue);\n#endif\n#ifdef ROT_Y_LIFETIME\nrotation.y+=FUNC1(uRYByLifeTimeValue);\n#endif\n#ifdef ROT_Z_LIFETIME\nrotation.z+=FUNC1(uRZByLifeTimeValue);\n#endif\nif(dot(rotation,rotation)==0.0){return mat3(1.0);}\n#undef FUNC1\nreturn mat3FromRotation(rotation);}void 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\nvec3 point=transformFromRotation(aRot,life,dur)*(aDirX*size.x+aDirY*size.y);vec3 pt=calculateTranslation(aVel,aOffset.z,uParams.x,dur);vec3 _pos=aPos+pt;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n_pos.xyz+=calLinearMov(life,dur);\n#endif\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 USE_FILTER\nfilterMain(life);\n#endif\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n#pragma EDITOR_VERT_TRANSFORM\n}}",wi="#version 300 es\nprecision mediump float;\n#define SHADER_VERTEX 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\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#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\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\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(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++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).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++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(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;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}in vec4 aPos;in vec3 aDir;in vec3 aInfo;in vec4 aColor;in float aTime;\n#ifdef ATTR_TRAIL_START\nin float aTrailStart;\n#else\nuniform float uTrailStart[64];in 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\nout float vLife;out vec2 vTexCoord;out 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}",Mi="uniform vec4 uTexRange;uniform vec2 uFilterSourceSize;\n#define INTERPOLATION 0\nvec4 filterMain(vec2 texCoord,sampler2D source){float x=uTexRange.x+texCoord.x*uTexRange.y;\n#if INTERPOLATION\nvec2 texInPixel=texCoord*uFilterSourceSize;vec2 coordMin=floor(texInPixel);vec2 pp=texInPixel-coordMin;vec4 fCoord=vec4(coordMin/uFilterSourceSize,(coordMin+vec2(1.))/uFilterSourceSize);vec4 cLT=texture2D(uFilterSource,vec2(fCoord.x,fCoord.w));vec4 cLB=texture2D(uFilterSource,vec2(fCoord.x,fCoord.y));vec4 cRT=texture2D(uFilterSource,vec2(fCoord.z,fCoord.w));vec4 cRB=texture2D(uFilterSource,vec2(fCoord.z,fCoord.y));vec4 color=mix(mix(cLB,cRB,pp.x),mix(cLT,cRT,pp.x),pp.y);\n#else\nvec4 color=texture2D(source,vec2(x,texCoord.y));\n#endif\nx=uTexRange.z+texCoord.x*uTexRange.w;vec4 opacity=texture2D(source,vec2(x,texCoord.y));return vec4(color.rgb,opacity.r);}",Li="uniform sampler2D uAlphaXSample;uniform sampler2D uAlphaYSample;vec4 filterMain(vec2 texCoord,sampler2D source){vec4 color=texture2D(source,texCoord);float x=texture2D(uAlphaXSample,vec2(vFeatherCoord.x,0.)).r;float y=texture2D(uAlphaYSample,vec2(vFeatherCoord.y,0.)).r;return vec4(color.rgb,color.a*min(x,y));}",Ii="uniform mat4 uMoveCameraViewPro;vec4 filterMain(float p,vec4 pos){return uMoveCameraViewPro*pos;}",Pi="uniform sampler2D uLastSource;uniform vec4 uParams;vec4 filterMain(vec2 coord,sampler2D tex){vec4 c1=texture2D(tex,coord);if(uParams.x<1.){return c1;}vec4 c2=texture2D(uLastSource,coord);return mix(c1,c2,uParams.y);}",Fi="uniform vec4 uWaveParams;\n#ifdef PATICLE_SHADER\nin vec4 vWaveParams;\n#else\nuniform vec4 vWaveParams;\n#endif\nvec4 filterMain(vec2 texCoord,sampler2D tex){vec2 vp=texCoord-uWaveParams.xy;float xx=dot(vp,uWaveParams.zw);float d=sin(vWaveParams.x*xx+vWaveParams.y)*vWaveParams.z;vec2 up=vec2(-uWaveParams.w,uWaveParams.z)*d;return texture2D(tex,clamp(texCoord+up,0.,1.));}",Ni="uniform vec4 uMovementValue;uniform vec4 uStrengthValue;uniform vec4 uPeriodValue;out vec4 vWaveParams;void filterMain(float lifetime){const float pi2=3.14159265;vWaveParams=vec4(getValueFromTime(lifetime,uPeriodValue)*pi2,getValueFromTime(lifetime,uMovementValue)*pi2,getValueFromTime(lifetime,uStrengthValue),0.);}",Vi="uniform sampler2D uBloomBlur;uniform vec4 uBloomParams;vec4 filterMain(vec2 coord,sampler2D tex){const vec3 gamma=vec3(1./2.2);vec4 c1=texture2D(tex,coord);vec4 bloomColor=texture2D(uBloomBlur,coord);float alpha=max(c1.a,bloomColor.a);vec3 color=max(c1.rgb*c1.a,bloomColor.rgb*bloomColor.a)/alpha*uBloomParams.y+bloomColor.rgb*uBloomParams.x;return vec4(color,alpha);}",Di="uniform vec4 uColorThreshold;vec4 filterMain(vec2 coord,sampler2D tex){vec4 c1=texture2D(tex,coord);vec3 color=c1.rgb*c1.a;vec3 s=step(uColorThreshold.xyz,color);float m=min(s.r+s.g+s.b,1.);return c1*m;}",zi="precision highp float;attribute vec2 aPos;varying vec2 uv;void main(){gl_Position=vec4(aPos,0.,1.0);uv=(aPos+vec2(1.0))/2.;}",Bi="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;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));}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;}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=ACESToneMapping(finalColor);}gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),1.0);}",Ui="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);}",ki="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);}",Gi="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);}",Xi="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainColor=texture2D(_MainTex,uv);mainColor.rgb=pow(mainColor.rgb,vec3(2.2));float brightness=max(mainColor.r,max(mainColor.g,mainColor.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainColor.rgb*=w;gl_FragColor=vec4(mainColor.rgb,1.0);}",Hi=function(e){function i(r,i){var n=e.call(this,r,i)||this,o=n.renderer.engine,s=li.create(o,{mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),a=qr.create(o,{shader:{vertex:zi,fragment:Xi,glslVersion:t.GLSLVersion.GLSL1}});return a.blending=!1,a.depthTest=!1,a.culling=!1,n.screenMesh=gi.create(o,{geometry:s,material:a,priority:0}),n.priority=5e3,n}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],this.sceneTextureHandle.texture=this.mainTexture,t.setFrameBuffer(this.frameBuffer)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture);var r=e.renderingData.currentFrame.globalVolume.threshold;this.screenMesh.material.setFloat("_Threshold",r),e.renderMeshes([this.screenMesh])},i}(bi),Yi=function(e){function i(r,i,n){var o=e.call(this,r,n)||this;o.type=i;var s=o.renderer.engine,a="PostProcess",u=li.create(s,{name:a,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),l={vertex:zi,fragment:"H"==i?Ui:ki,glslVersion:t.GLSLVersion.GLSL1},c=qr.create(s,{name:a,shader:l});return c.blending=!1,c.depthTest=!1,c.culling=!1,o.screenMesh=gi.create(s,{name:a,geometry:u,material:c,priority:0}),o.priority=5e3,o}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setVector2("_TextureSize",Ji(this.mainTexture)),e.renderMeshes([this.screenMesh]),"V"===this.type&&(this.gaussianResult.texture=e.getFrameBuffer().getColorTextures()[0])},i}(bi),ji=function(e){function i(t,r){var i=e.call(this,t,r)||this,n="PostProcess",o=i.renderer.engine,s=li.create(o,{name:n,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),a={vertex:zi,fragment:Gi},u=qr.create(o,{name:n,shader:a});return u.blending=!1,u.depthTest=!1,u.culling=!1,i.screenMesh=gi.create(o,{name:n,geometry:s,material:u,priority:0}),i.priority=5e3,i}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setTexture("_GaussianDownTex",this.gaussianDownSampleResult.texture),this.screenMesh.material.setVector2("_GaussianDownTextureSize",Ji(this.gaussianDownSampleResult.texture)),e.renderMeshes([this.screenMesh])},i}(bi),Wi=function(e){function i(r,i){var n=e.call(this,r,{})||this,o="PostProcess",s=n.renderer.engine;n.sceneTextureHandle=i||new Ei(s);var a=li.create(s,{name:o,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),u=qr.create(s,{name:o,shader:{vertex:zi,fragment:Bi,glslVersion:t.GLSLVersion.GLSL1}});return u.blending=!1,u.depthTest=!1,u.culling=!1,n.screenMesh=gi.create(s,{name:o,geometry:a,material:u,priority:0}),n.priority=5e3,n}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],this.sceneTextureHandle.texture||(this.sceneTextureHandle.texture=this.mainTexture),t.setFrameBuffer(null)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear});var r=e.renderingData.currentFrame.globalVolume,i=r.bloomIntensity,n=r.brightness,o=r.saturation,s=r.contrast,a=r.useBloom,u=r.useToneMapping;this.screenMesh.material.setTexture("_SceneTex",this.sceneTextureHandle.texture),this.screenMesh.material.setFloat("_Brightness",n),this.screenMesh.material.setFloat("_Saturation",o),this.screenMesh.material.setFloat("_Contrast",s),this.screenMesh.material.setInt("_UseBloom",a),a&&(this.screenMesh.material.setTexture("_GaussianTex",this.mainTexture),this.screenMesh.material.setFloat("_BloomIntensity",i)),this.screenMesh.material.setInt("_UseToneMapping",u),e.renderMeshes([this.screenMesh])},i}(bi),Zi={useHDR:!1,usePostProcessing:!1,useBloom:1,threshold:1,bloomIntensity:1,brightness:1,saturation:1,contrast:1,useToneMapping:1},qi="_effects_default_",Ki=1,Qi=function(){function e(e){var r;this.destroyed=!1,this.renderPassInfoMap=new WeakMap;var n=e.camera,o=e.keepColorBuffer,s=e.renderer,a=e.editorTransform,u=void 0===a?[1,1,0,0]:a,l=e.globalVolume,c=e.clearAction,h=void 0===c?{colorAction:t.TextureLoadAction.whatever,stencilAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.whatever}:c,f=s.engine;l&&(this.globalVolume=i(i({},Zi),l)),this.globalUniforms=new tn;var p,d=[],m={};if(this.renderer=s,this.globalVolume){var y=this.globalVolume.useHDR?v.HALF_FLOAT:v.UNSIGNED_BYTE;d=[{texture:{format:v.RGBA,type:y,magFilter:v.LINEAR,minFilter:v.LINEAR}}],p={storageType:t.RenderPassAttachmentStorageType.depth_stencil_opaque},m={colorAction:t.TextureLoadAction.clear,stencilAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.clear}}var g=[new bi(s,{name:qi,priority:xi,meshOrder:t.OrderType.ascending,depthStencilAttachment:p,attachments:d,clearAction:m})];if(this.setRenderPasses(g),this.globalVolume){var x=this.globalVolume.useBloom,T=new Ei(f);if(x){var E=[0,0,this.renderer.getWidth()/2,this.renderer.getHeight()/2],S=new Array(7),b=(y=this.globalVolume.useHDR?v.HALF_FLOAT:v.UNSIGNED_BYTE,new Hi(s,{name:"BloomThresholdPass",attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]}));b.sceneTextureHandle=T,this.addRenderPass(b);for(var A=0;A<7;A++){S[A]=new Ei(f);var _=new Yi(s,"H",{name:"GaussianDownPassH"+A,viewport:E,attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]}),C=new Yi(s,"V",{name:"GaussianDownPassV"+A,viewport:E,attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]});C.gaussianResult=S[A],this.addRenderPass(_),this.addRenderPass(C),E[2]/=2,E[3]/=2}E[2]*=4,E[3]*=4;for(A=0;A<6;A++){var R=new ji(s,{name:"GaussianUpPass"+A,viewport:E,attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]});R.gaussianDownSampleResult=S[5-A],this.addRenderPass(R),E[2]*=2,E[3]*=2}}var O=void 0;O=x?new Wi(s,T):new Wi(s),this.addRenderPass(O)}this.semantics=new ai(e.semantics),this.clearAction=h,this.name="RenderFrame".concat(Ki++);var w=g[0],M={type:v.UNSIGNED_BYTE,format:v.RGBA,internalFormat:v.RGBA,wrapS:v.MIRRORED_REPEAT,wrapT:v.MIRRORED_REPEAT,minFilter:v.NEAREST,magFilter:v.NEAREST};this.emptyTexture=Vr.create(f,i({data:{width:1,height:1,data:new Uint8Array([255,255,255,255])},sourceType:t.TextureSourceType.data},M)),this.transparentTexture=Vr.create(f,i({data:{width:1,height:1,data:new Uint8Array([0,0,0,0])},sourceType:t.TextureSourceType.data},M)),this.camera=n,this.keepColorBuffer=o,this.renderPassInfoMap.set(w,{listStart:0,listEnd:0,renderPass:w,intermedia:!1}),this.editorTransform=zt.fromArray(u),e.clearAction||this.resetClearActions(),this.passTextureCache=new si(f);var L=f.gpuCapability,I=L.detail,P=ri(L.level,I.readableDepthStencilTextures&&I.writableFragDepth);null===(r=this.renderer.getShaderLibrary())||void 0===r||r.addShader(P)}return Object.defineProperty(e.prototype,"renderPasses",{get:function(){return this._renderPasses.slice()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.addMeshToDefaultRenderPass=function(t){for(var e=this.renderPasses,r=this.renderPassInfoMap,i=t.priority,n=1;n<e.length;n++){var o=e[n-1],s=r.get(e[n]),a=r.get(o);if(s&&a&&(s.listStart>i&&(i>a.listEnd||1===n)))return this.addToRenderPass(o,t)}for(var u=e.length-1,l=e[u];u>=0&&!l.name.includes(qi);)l=e[--u];return this.addToRenderPass(l,t)},e.prototype.removeMeshFromDefaultRenderPass=function(e){for(var r,n,o,s=this,a=this.renderPasses,u=this.renderPassInfoMap,l=a.length-1;l>=0;l--){var c=a[l],h=u.get(c);if(h&&(h.listStart<=e.priority&&h.listEnd>=e.priority)){var f=c.meshes.indexOf(e);if(-1===f)return;var p=1===f&&c.meshes[0].name===Jr;if(c.removeMesh(e),p){var d=a[l+1],m=c.meshes;h.intermedia||null===(r=h.preRenderPass)||void 0===r||r.resetColorAttachments([]);for(var v=1;v<m.length;v++)null===(n=h.preRenderPass)||void 0===n||n.addMesh(m[v]);var y=null===(o=c.attachments[0])||void 0===o?void 0:o.texture,g=y===this.resource.color_a||y===this.resource.color_b;c.dispose({meshes:t.DestroyOptions.keep,colorAttachment:g?t.RenderPassDestroyAttachmentType.keep:t.RenderPassDestroyAttachmentType.destroy,depthStencilAttachment:t.RenderPassDestroyAttachmentType.keep}),B(a,c),this.removeRenderPass(c),u.delete(c),d&&this.updateRenderInfo(d),h.preRenderPass&&this.updateRenderInfo(h.preRenderPass),h.prePasses&&h.prePasses.forEach((function(e){if(s.removeRenderPass(e.pass),!1!==(null==e?void 0:e.destroyOptions)){e.pass.attachments.forEach((function(t){t.texture===s.resource.color_b&&t.texture===s.resource.color_a||t.texture.dispose()}));var r=i(i({},(null==e?void 0:e.destroyOptions)?e.destroyOptions:{}),{depthStencilAttachment:t.RenderPassDestroyAttachmentType.keep});e.pass.dispose(r)}})),this.resetRenderPassDefaultAttachment(a,Math.max(l-1,0)),1===a.length&&(a[0].resetColorAttachments([]),this.removeRenderPass(this.resource.finalCopyRP))}return this.resetClearActions()}}},e.prototype.splitDefaultRenderPassByMesh=function(e,r){var i,n,o,s=this.findMeshRenderPassIndex(e),l=this.renderPasses[s];this.createResource();var c=l.meshes.indexOf(e),h=l.meshes.slice(0,c),f=l.meshes.slice(c),p=this.renderPassInfoMap;if(!(null===(i=r.attachments)||void 0===i?void 0:i.length))throw Error("should include at least one color attachment");var d=this.renderPasses,m=d.indexOf(l);d[m-1],B(d,l);var y=p.get(l);p.delete(l);var g=2===this.renderer.engine.gpuCapability.level?v.LINEAR:v.NEAREST,x=new bi(this.renderer,{name:qi+m,priority:l.priority,attachments:[{texture:{sourceType:t.TextureSourceType.framebuffer,format:v.RGBA,name:"frame_a",minFilter:g,magFilter:g}}],clearAction:l.clearAction||{colorAction:t.TextureLoadAction.clear},storeAction:l.storeAction,depthStencilAttachment:this.resource.depthStencil,meshes:h,meshOrder:t.OrderType.ascending});f.unshift(this.createCopyMesh());var T=this.renderPasses;T[s]=x;var E=[],S=f.slice();r.prePasses&&(r.prePasses.forEach((function(t,e){t.priority=l.priority+1+e,t.setMeshes(f),E.push(t)})),T.splice.apply(T,u([s+1,0],a(E),!1)),S.splice(0,2));var b=this.resource.finalCopyRP;T.includes(b)||T.push(b);var A=E[E.length-1];A.initialize(this.renderer);var _=new bi(this.renderer,{name:qi+(m+1),priority:l.priority+1+((null===(n=r.prePasses)||void 0===n?void 0:n.length)||0),meshes:S,meshOrder:t.OrderType.ascending,depthStencilAttachment:this.resource.depthStencil,storeAction:r.storeAction,clearAction:{depthAction:t.TextureLoadAction.whatever,stencilAction:t.TextureLoadAction.whatever,colorAction:t.TextureLoadAction.whatever}});return T.splice(s+1+((null===(o=r.prePasses)||void 0===o?void 0:o.length)||0),0,_),this.setRenderPasses(T),this.updateRenderInfo(A),this.updateRenderInfo(x),this.updateRenderInfo(_),p.get(x).prePasses=y.prePasses,E.pop(),p.get(A).prePasses=E.map((function(t,e){return{pass:t,destroyOptions:!1}})),this.resetClearActions(),A},e.prototype.dispose=function(e){var r,i;(null==e?void 0:e.semantics)!==t.DestroyOptions.keep&&this.semantics.dispose();var n=(null==e?void 0:e.passes)?e.passes:void 0;n!==t.DestroyOptions.keep&&this._renderPasses.forEach((function(t){t.dispose(n)})),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=null===(r=this.resource.depthStencil)||void 0===r?void 0:r.texture)||void 0===i||i.dispose(),this.resource.finalCopyRP.dispose(),this.resource.resRP.dispose(),this.resource=null),this.destroyed=!0},e.prototype.resetRenderPassDefaultAttachment=function(t,e){for(var r,i,n,o=this.resource,s=o.color_a,a=o.color_b,u=e;u<t.length;u++){var l=t[u],c=null===(r=l.attachments[0])||void 0===r?void 0:r.texture;if(c&&n===c){var h=c===s?a:s;l.resetColorAttachments([h])}(c=null===(i=l.attachments[0])||void 0===i?void 0:i.texture)&&(n=c)}},e.prototype.findMeshRenderPassIndex=function(t){var e=-1;return this.renderPasses.every((function(r,i){return!r.name.startsWith(qi)||!r.meshes.includes(t)||(e=i,!1)})),e},e.prototype.addToRenderPass=function(t,e){var r=this.renderPassInfoMap.get(t),i=e.priority;0===t.meshes.length?r.listStart=r.listEnd=i:i<r.listStart?r.listStart=i:i>r.listEnd&&(r.listEnd=i),t.addMesh(e)},e.prototype.getRPAttachments=function(t,e){var r;if(1===(null==t?void 0:t.length)){var i=t[0],n=i.texture,o=i.persistent,s=n.format,a=null!==(r=null==e?void 0:e.getInitAttachments())&&void 0!==r?r:[];if(s===v.RGBA&&!o){var u=this.resource.color_a;return 0===a.length?[{texture:u}]:[{texture:a[0].texture===u?this.resource.color_b:u}]}}return t},e.prototype.resetClearActions=function(){var e=this.renderPasses.length>1?t.TextureLoadAction.clear:t.TextureLoadAction.whatever;this.clearAction.stencilAction=e,this.clearAction.depthAction=e,this.clearAction.colorAction=e,this.keepColorBuffer&&(this.clearAction.colorAction=t.TextureLoadAction.whatever)},e.prototype.updateRenderInfo=function(e){var r,i=this,n=this.renderPassInfoMap,o=this.renderPasses;n.has(e)?r=n.get(e):(r={intermedia:!1,renderPass:e,listStart:0,listEnd:0},n.set(e,r)),r.intermedia=e.attachments.length>0;var s=e.meshes;s[0]?(r.listStart=(s[0].name===Jr?s[1]:s[0]).priority,r.listEnd=s[s.length-1].priority):(r.listStart=0,r.listEnd=0);var a=o.indexOf(e),u=0===a?t.TextureLoadAction.clear:t.TextureLoadAction.whatever;return 0===a&&(e.clearAction.colorAction=t.TextureLoadAction.clear),e.clearAction.depthAction=u,e.clearAction.stencilAction=u,a>-1?e.semantics.setSemantic("EDITOR_TRANSFORM",(function(){return i.editorTransform})):e.semantics.setSemantic("EDITOR_TRANSFORM",void 0),r.preRenderPass=o[a-1],r},e.prototype.setRenderPasses=function(t){var e=this;void 0!==this.renderer&&t.forEach((function(t){return t.initialize(e.renderer)})),this._renderPasses=t.slice()},e.prototype.addRenderPass=function(t){void 0!==this.renderer&&t.initialize(this.renderer),this._renderPasses.push(t)},e.prototype.createResource=function(){var e,r=this.renderer.engine;if(!this.resource){var i=r.gpuCapability,n=i.detail,o=i.level,s=this.renderer.getWidth(),a=this.renderer.getHeight(),u=2===o?v.LINEAR:v.NEAREST,l=Vr.create(r,{sourceType:t.TextureSourceType.framebuffer,format:v.RGBA,name:"frame_a",minFilter:u,magFilter:u}),c=Vr.create(r,{sourceType:t.TextureSourceType.framebuffer,format:v.RGBA,data:{width:s,height:a},minFilter:u,magFilter:u,name:"frame_b"}),h=n.readableDepthStencilTextures&&n.writableFragDepth?t.RenderPassAttachmentStorageType.depth_24_stencil_8_texture:t.RenderPassAttachmentStorageType.depth_stencil_opaque,f=new bi(this.renderer,{depthStencilAttachment:{storageType:h},attachments:[{texture:l}]}).initialize(this.renderer),p=new $i(this.renderer,{name:"effects-final-copy",priority:1600,clearAction:{depthAction:t.TextureLoadAction.clear,stencilAction:t.TextureLoadAction.clear,colorAction:t.TextureLoadAction.clear},meshOrder:t.OrderType.ascending,meshes:[this.createCopyMesh({blend:!0,depthTexture:null===(e=f.getDepthAttachment())||void 0===e?void 0:e.texture})]});this.resource={color_a:f.attachments[0].texture,color_b:c,finalCopyRP:p,depthStencil:f.depthAttachment,resRP:f}}},e.prototype.createCopyMesh=function(t){var e=Jr,r=this.renderer.engine,i=li.create(r,{name:e,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),n=ri(r.gpuCapability.level,!!(null==t?void 0:t.depthTexture));this.renderer.getShaderLibrary().addShader(n);var o=qr.create(r,{uniformValues:{uDepth:null==t?void 0:t.depthTexture},name:e,shader:n});return o.blending=!1,o.depthTest=!1,o.culling=!1,(null==t?void 0:t.blend)&&(o.blending=!0,o.blendFunction=[v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA,v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA]),gi.create(r,{name:e,geometry:i,material:o,priority:0})},e.prototype.removeRenderPass=function(t){B(this._renderPasses,t)},e}();function Ji(t){return t?new wt(t.getWidth(),t.getHeight()):new wt}var $i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(null)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction)},e}(bi),tn=function(){this.floats={},this.ints={},this.matrices={},this.samplers=[],this.uniforms=[]},en=function(){function t(t){this.size=[0,0],this.multiSample=1,this.destroyed=!1;var e=t.storageType,r=t.format,i=t.attachment;this.storageType=e,this.format=r,this.attachment=i}return Object.defineProperty(t.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),t}(),rn="function"==typeof WebGL2RenderingContext,nn=function(){function t(t){this.setupCapability(t)}return t.prototype.setupCapability=function(t){var e,r=rn&&t instanceof WebGL2RenderingContext?2:1,i=2===r,n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),o=t.getExtension("WEBGL_depth_texture"),s=!!t.getExtension("OES_texture_half_float_linear"),a=!!t.getExtension("OES_texture_float_linear");this.level=r,this.type=i?"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"),o&&(this.UNSIGNED_INT_24_8=o.UNSIGNED_INT_24_8_WEBGL),i&&!s&&(s=on(t,t.HALF_FLOAT)),i&&!a&&(a=on(t,t.FLOAT)),this.internalFormatDepth16=i?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,this.internalFormatDepth24_stencil8=i?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL;var u=i||t.getExtension("OES_texture_float")?t.FLOAT:0,l=i?WebGL2RenderingContext.HALF_FLOAT:(null===(e=t.getExtension("OES_texture_half_float"))||void 0===e?void 0:e.HALF_FLOAT_OES)||0,c={floatTexture:u,halfFloatTexture:l,maxSample:i?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:i?!!t.getExtension("EXT_color_buffer_float"):u>0&&!!t.getExtension("WEBGL_color_buffer_float"),halfFloatColorAttachment:i?!!t.getExtension("EXT_color_buffer_float"):l>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:ln(t),halfFloatLinear:s,floatLinear:a,maxTextureAnisotropy:n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,shaderTextureLod:i||!!t.getExtension("EXT_shader_texture_lod"),instanceDraw:i||!!t.getExtension("ANGLE_instanced_arrays"),drawBuffers:i||!!this.drawBufferExtension,asyncShaderCompile:!!t.getExtension("KHR_parallel_shader_compile"),intIndexElementBuffer:!!t.getExtension("OES_element_index_uint"),standardDerivatives:i||!!t.getExtension("OES_standard_derivatives"),readableDepthStencilTextures:i||!!o,writableFragDepth:i||!!t.getExtension("EXT_frag_depth")};this.detail=c,n&&(this.textureMaxAnisotropyExt=n.TEXTURE_MAX_ANISOTROPY_EXT)},t.prototype.framebufferTexture2D=function(t,e,r,i,n){var o=this.drawBufferExtension;if(1===this.level&&!o&&r>0)throw new Error("draw multiple color buffers not available");var s=o?o["COLOR_ATTACHMENT".concat(r,"_WEBGL")]:t["COLOR_ATTACHMENT".concat(r)];s?t.framebufferTexture2D(e,s,i,n,0):console.error("invalid color attachment index: "+r)},t.prototype.drawBuffers=function(t,e){var r=this.drawBufferExtension;if(1!==this.level||r){var i=e.map((function(e,i){return e?r?r["COLOR_ATTACHMENT".concat(i,"_WEBGL")]:t["COLOR_ATTACHMENT".concat(i)]:t.NONE}));r?r.drawBuffersWEBGL(i):t.drawBuffers(i)}else if(e.length>1)throw Error("draw buffers not available")},t.prototype.setTextureAnisotropic=function(t,e,r){var i=this.detail.maxTextureAnisotropy;i&&t.texParameterf(e,this.textureMaxAnisotropyExt,Math.min(i,r||4))},t}();function on(t,e){var r=t.createTexture(),i=!1;return t.getError(),t.bindTexture(t.TEXTURE_2D,r),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()||(i=!0),t.deleteTexture(r),i}var sn,an,un={NONE:0,PVRTC:1,ASTC:2};function ln(t){return t.getExtension("WEBGL_compressed_texture_astc")?un.ASTC:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc")?un.PVRTC:un.NONE}t.FilterMode=void 0,(sn=t.FilterMode||(t.FilterMode={}))[sn.Nearest=0]="Nearest",sn[sn.Linear=1]="Linear",t.RenderTextureFormat=void 0,(an=t.RenderTextureFormat||(t.RenderTextureFormat={}))[an.RGBA32=0]="RGBA32",an[an.RGBAHalf=1]="RGBAHalf";var cn=function(){function t(){}return t.prototype.resize=function(t,e,r,i){},t.prototype.resetColorTextures=function(t){},t.prototype.unbind=function(){},t.prototype.bind=function(){},Object.defineProperty(t.prototype,"stencilStorage",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthStorage",{get:function(){},enumerable:!1,configurable:!0}),t.prototype.getDepthTexture=function(){},t.prototype.getStencilTexture=function(){},t.prototype.getColorTextures=function(){return[]},t.prototype.dispose=function(t){},t}(),hn=function(){function t(){}return t.prototype.setGlobalFloat=function(t,e){},t.prototype.setGlobalInt=function(t,e){},t.prototype.setGlobalMatrix=function(t,e){},t.prototype.getFrameBuffer=function(){return null},t.prototype.setFrameBuffer=function(t){},t.prototype.setViewport=function(t,e,r,i){},t.prototype.resize=function(t,e){},t.prototype.clear=function(t){},t.prototype.getWidth=function(){return 0},t.prototype.getHeight=function(){return 0},t.prototype.addLostHandler=function(t){},t.prototype.addRestoreHandler=function(t){},t.prototype.lost=function(t){},t.prototype.restore=function(){},t.prototype.getShaderLibrary=function(){},t.prototype.renderRenderFrame=function(t){},t.prototype.renderMeshes=function(t){},t.prototype.drawGeometry=function(t,e){},t.prototype.getTemporaryRT=function(t,e,r,i,n,o){return null},t.prototype.dispose=function(t){},t}(),fn=1,pn=function(){function e(t,e,r,i){this.transform=r,this.engine=i,this.color=t.options.previewColor;var n=this.createMaterial(e),o=this.createGeometry();this.mesh=this.createMesh(o,n),this.updateMesh()}return e.prototype.updateMesh=function(){var t=this.mesh.material,e=t.getVector2("uSize").clone(),r=t.getVector4("uPos").clone(),i=new Mt,n=new Lt,o=this.transform.scale.clone();this.transform.assignWorldTRS(i,n,o),e.x=o.x,e.y=o.y,r.x=i.x,r.y=i.y,r.z=i.z,t.setVector2("uSize",e),t.setVector4("uPos",r),t.setQuaternion("uQuat",n)},e.prototype.createMaterial=function(e){var r,i=[["ENV_EDITOR",(null===(r=this.engine.renderer)||void 0===r?void 0:r.env)===c]],n=be(this.color).getValue(0),o=this.engine.gpuCapability.level,s={shader:{vertex:br(i,"\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",t.ShaderType.vertex,o),fragment:br(i,"\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n",t.ShaderType.fragment,o),glslVersion:t.GLSLVersion.GLSL1,cacheId:"".concat(e.cachePrefix,"_effects_interact")},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},a=qr.create(this.engine,s);return a.depthTest=!1,a.setVector4("uPos",new zt(0,0,0,0)),a.setVector2("uSize",new wt(1,1)),a.setVector4("uColor",new zt(n[0]/255,n[1]/255,n[2]/255,n[3])),a.setQuaternion("uQuat",new Lt(0,0,0,0)),a},e.prototype.createGeometry=function(){var t=new Uint8Array([0,1,1,2,2,3,3,0]);return li.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:v.LINES,maxVertex:4})},e.prototype.createMesh=function(t,e){return gi.create(this.engine,{name:"Interact_preview"+fn++,priority:0,worldMatrix:Ft.fromIdentity(),geometry:t,material:e})},e}(),dn=function(e){function n(t,r){var i,n=e.call(this,t,r)||this;return n.engine=null===(i=n.composition)||void 0===i?void 0:i.getEngine(),n}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.interact},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){this.ui=t.content},n.prototype.onLifetimeBegin=function(t){var e,r,i,n=this.ui.options,o=(null!==(r=null===(e=this.engine)||void 0===e?void 0:e.renderer)&&void 0!==r?r:{}).env;null===(i=this.composition)||void 0===i||i.addInteractiveItem(this,n.type),n.type===R.DRAG&&(o!==c||n.enableInEditor)&&t.event&&this.beginDragTarget(n,t.event)},n.prototype.onItemUpdate=function(){var t;if(null===(t=this.previewContent)||void 0===t||t.updateMesh(),this.dragEvent&&this.bouncingArg){this.bouncingArg.vx*=.95,this.bouncingArg.vy*=.95,this.bouncingArg.dy+=this.bouncingArg.vy,this.bouncingArg.dx+=this.bouncingArg.vx,mn(this.bouncingArg)?(this.dragEvent=null,this.bouncingArg=null):this.handleDragMove(this.dragEvent,this.bouncingArg)}},n.prototype.onItemRemoved=function(t){var e;t.removeInteractiveItem(this,this.ui.options.type),this.clickable=!1,null===(e=this.previewContent)||void 0===e||e.mesh.dispose(),this.endDragTarget()},n.prototype.getBoundingBox=function(){var e=this.transform.getWorldMatrix(),r=le(Mt.ZERO,.5,.5);return r.forEach((function(t){e.transformPoint(t.p0),e.transformPoint(t.p1),e.transformPoint(t.p2)})),{type:t.HitTestType.triangle,area:r}},n.prototype.getHitTestParams=function(){if(this.clickable){var t=this.ui.options.behavior,e=this.getBoundingBox();return e?{type:e.type,triangles:e.area,behavior:t}:void 0}},n.prototype.doCreateContent=function(t){var e,r=this.ui.options,i=r.type,n=r.showPreview,o=this.engine,s=(null!==(e=null==o?void 0:o.renderer)&&void 0!==e?e:{}).env;if(rt(o),i===R.CLICK&&(this.clickable=!0,n&&s===c)){var a=t.getRendererOptions();this.previewContent=new pn(this.ui,a,this.transform,o)}return{}},n.prototype.beginDragTarget=function(t,e){var r=this;if("camera"===t.target){var n,o={touchstart:function(t){var e;r.dragEvent=null,r.bouncingArg=null;var i=null===(e=r.composition)||void 0===e?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){var e=r.bouncingArg;if(!mn(e,3)&&e){e.vx*=5,e.vy*=5,r.dragEvent=i({},n)}n=null}};Object.keys(o).forEach((function(t){e.addEventListener(t,o[t])})),o.touchmove({dx:0,dy:0,width:1,height:1}),this.endDragTarget=function(){Object.keys(o).forEach((function(t){e.removeEventListener(t,o[t])}))}}},n.prototype.endDragTarget=function(){},n.prototype.handleDragMove=function(t,e){var r,i;if(t&&t.cameraParam&&this.composition){var n=this.ui.options,o=t.cameraParam,s=o.position,u=o.fov,l=e.dy,c=e.dx*e.width/e.height,h=s[2],f=Math.tan(u*Math.PI/180/2)*Math.abs(h),p=l*f,d=c*f,m=s[0]-d,v=s[1]-p;if(n.dxRange){var y=a(n.dxRange,2);(m=Rt(m,g=y[0],x=y[1]))!==g&&m!==x&&g!==x&&(null===(r=e.origin)||void 0===r||r.preventDefault())}if(n.dyRange){var g,x,T=a(n.dyRange,2);(v=Rt(v,g=T[0],x=T[1]))!==g&&v!==x&&g!==x&&(null===(i=e.origin)||void 0===i||i.preventDefault())}this.composition.camera.position=new Mt(m,v,h)}},n}(Qe);function mn(t,e){var r=1e-5*(e||1);return t&&Math.abs(t.vx||0)<r&&Math.abs(t.vy||0)<r}var vn=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.mesh=[],e}return r(e,t),e.prototype.onCompositionItemLifeBegin=function(t,e){e instanceof dn&&e.previewContent&&this.addMesh(e.previewContent.mesh)},e.prototype.onCompositionItemRemoved=function(t,e){e instanceof dn&&e.previewContent&&this.removeMesh(e.previewContent.mesh,t.renderFrame)},e.prototype.prepareRenderFrame=function(t,e){return this.mesh&&this.mesh.forEach((function(t){return e.addMeshToDefaultRenderPass(t)})),this.mesh=[],!1},e.prototype.addMesh=function(t){this.mesh.push(t)},e.prototype.removeMesh=function(t,e){e.removeMeshFromDefaultRenderPass(t)},e}(sr),yn=function(){};t.maxSpriteMeshItemCount=8,t.maxSpriteTextureCount=8;var gn=1,xn=function(){function e(t,e,r){this.engine=t,this.composition=r,this.items=[],this.dirty=!1;var i=e.wireframe,n=this.createGeometry(i?v.LINES:v.TRIANGLES),o=this.createMaterial(e,2);this.wireframe=i,this.mesh=gi.create(t,{name:"MSprite"+gn++,priority:0,worldMatrix:Ft.fromIdentity(),geometry:n,material:o})}return e.prototype.setItems=function(e){var r,i,n,o,s,a=[],u=[],l=2,c=0,h=0,f=0;if(!e.length)return this.mesh.setVisible(!1),!0;for(var p=0;p<e.length;p++)if(e[p].renderInfo){s=e[p].renderInfo;break}if(!s)return!0;this.items=e.slice(),e.length>2&&(l=t.maxSpriteMeshItemCount),this.mtlSlotCount!==l&&this.mesh.setMaterial(this.createMaterial(s,l),{textures:t.DestroyOptions.keep});var d=null!==(o=null===(n=null===(i=null===(r=s.filter)||void 0===r?void 0:r.passSplitOptions)||void 0===i?void 0:i.attachments)||void 0===n?void 0:n.length)&&void 0!==o?o:0;this.splitLayer=d>0;for(p=0;p<e.length;p++){(C=null==(m=e[p])?void 0:m.renderer.texture)&&z(u,C),m.mesh=this}for(p=0;p<e.length;p++){var m,y=(C=null==(m=e[p])?void 0:m.renderer.texture)?u.indexOf(C):-1,g=this.getItemInitData(m,p,f,y);c+=g.aPoint.length,h+=g.index.length,a.push(g),f+=g.aPoint.length/6,this.updateItem(m,!0)}var x={aPoint:new Float32Array(c),index:new Uint16Array(h)},T={aPoint:0,index:0},E=function(t){var e=a[t];Object.keys(x).forEach((function(t){var r=x[t],i=e[t];r.set(i,T[t]),T[t]+=i.length}))};for(p=0;p<a.length;p++)E(p);var S=this.mesh,b=S.material,A=S.geometry,_=x.index;A.setIndexData(_),A.setAttributeData("aPoint",x.aPoint),A.setDrawCount(h),this.mesh.setVisible(!!A.getDrawCount()),this.mesh.priority=e[0].listIndex;for(p=0;p<u.length;p++){var C=u[p];b.setTexture("uSampler"+p,C)}for(var R=e[0].emptyTexture,O=u.length;O<t.maxSpriteMeshItemCount;O++)b.setTexture("uSampler"+O,R);if(this.splitLayer){var w=function(t,e){var r;if(e){for(var i=128,n=new Uint8Array(i),o=0,s=i-1;o<i;o++){var a=o/s,u=e.getValue(a);n[o]=Math.round(255*u)}r=Vr.createWithData(t,{width:i,height:1,data:n},{name:"feather",format:v.LUMINANCE,minFilter:v.LINEAR,magFilter:v.LINEAR,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE})}else r=Vr.createWithData(t);return r}(this.engine,e[0].feather);b.setTexture("uFeatherSampler",w)}},e.prototype.updateItem=function(t,e){var r=this.items.indexOf(t);if(!(r<=-1)){var i=this.mesh.material.getVector4Array("uTexParams"),n=4*r,o=t.getRenderData(t.time,e),s=this.mesh.material.getMatrixArray("uMainData"),l=16*r,c=l,h=l+4,f=l+8,p=l+12,d=new Mt,m=new Lt,v=new Mt,y=o.color||[s[p],s[p+1],s[p+2],s[p+3]];if(o.visible)o.transform.assignWorldTRS(d,m,v);else if(!e)return void(s[h+2]=-1);var g=u(u([],a(d.toArray()),!1),[0],!1),x=u(u([],a(v.toArray()),!1),[0],!1),T=m.toArray();isNaN(t.getCustomOpacity())||(y[3]=t.getCustomOpacity());for(var E=0;E<4;E++)s[c+E]=g[E],s[f+E]=T[E],s[h+E]=x[E],s[p+E]=y[E];if(x[2]=o.life,s[h+2]=o.life,e){var S=t.renderer;i[n]=S.occlusion?+S.transparentOcclusion:1,i[n+2]=S.renderMode,i[n+1]=+this.preMultiAlpha}if(o.texOffset){var b=this.mesh.material.getVector4Array("uTexOffset");for(E=0;E<4;E++)b[4*r+E]=o.texOffset[E]}}},e.prototype.applyChange=function(){this.dirty&&(this.setItems(this.items),this.dirty=!1)},e.prototype.getItemInitData=function(t,e,r,i){var n=t.geoData;this.lineMode?n=this.getItemGeometryData(t,e):n||(n=t.geoData=this.getItemGeometryData(t,e));var o=n.aPoint;if(o[4]!==e||o[5]!==i)for(var s=0;s<o.length;s+=6)o[s+4]=e,o[s+5]=i;var a=n.index,u=a.length,l=this.wireframe?new Uint8Array([0,1,1,3,2,3,2,0]):new a.constructor(u);if(!this.wireframe)for(s=0;s<u;s++)l[s]=r+a[s];return{aPoint:n.aPoint,index:l}},e.prototype.getItemRegionData=function(t){var e=this.items.indexOf(t);if(e>-1){var r=this.mesh.material.getMatrixArray("uMainData"),i=16*e;if(null===r)return;return{position:[r[i]||0,r[i+1]||0,r[i+2]||0],size:[r[i+4],r[i+5]],quat:[r[i+8],r[i+9],r[i+10],r[i+11]],color:[r[i+12],r[i+13],r[i+14],r[i+15]]}}},e.prototype.invalidMaterial=function(){this.mtlSlotCount=0},e.prototype.createGeometry=function(e){var r=Float32Array.BYTES_PER_ELEMENT;return li.create(this.engine,{attributes:{aPoint:{size:4,offset:0,stride:l*r,releasable:!0,type:v.FLOAT,data:new Float32Array(0)},aIndex:{size:2,offset:4*r,stride:l*r,dataSource:"aPoint",type:v.FLOAT}},indices:{data:new Uint16Array(0),releasable:!0},mode:e,maxVertex:4*t.maxSpriteMeshItemCount})},e.prototype.createMaterial=function(t,e){var r,n,o,a=t.filter,u=t.side,l=t.occlusion,c=t.blending,h=t.maskMode,f=t.mask,p=(null==a?void 0:a.mesh)||{},d=this.engine,m={shader:An(t,e,d.gpuCapability.level,null===(o=d.renderer)||void 0===o?void 0:o.env)};this.preMultiAlpha=xr(c),this.mtlSlotCount=e;var v=qr.create(d,m),y=i({side:u,blending:!0,blendMode:c,mask:f,maskMode:h,depthTest:!0,depthMask:l},p.materialStates);v.blending=y.blending,v.stencilRef=void 0!==y.mask?[y.mask,y.mask]:void 0,v.depthTest=y.depthTest,v.depthMask=y.depthMask,y.blending&&Ar(v,y.blendMode),v.blendFunction=y.blendFunction,Cr(v,y.maskMode),_r(v,y.side);var g=p.uniformValues;if(g)try{for(var x=s(Object.keys(g)),T=x.next();!T.done;T=x.next()){var E=T.value,S=g[E];S instanceof Vr?v.setTexture(E,S):"number"==typeof S?v.setFloat(E,S):2===S.length?v.setVector2(E,wt.fromArray(S)):4===S.length?v.setVector4(E,zt.fromArray(S)):v.setMatrix(E,Ft.fromArray(S))}}catch(t){r={error:t}}finally{try{T&&!T.done&&(n=x.return)&&n.call(x)}finally{if(r)throw r.error}}for(var b=[],A=[],_=[],C=0;C<e;C++)b.push(Ft.fromIdentity()),A.push(new zt),_.push(new zt);return v.hasUniform("uMainData")||v.setMatrixArray("uMainData",b),v.hasUniform("uTexParams")||v.setVector4Array("uTexParams",A),v.hasUniform("uTexOffset")||v.setVector4Array("uTexOffset",_),v},e.prototype.getItemGeometryData=function(t,e){var r=t.splits,i=t.renderer,n=t.textureSheetAnimation,o=t.startSize,s=o.x,a=o.y;if(i.shape){for(var u=i.shape,l=u.index,c=u.aPoint,h=new Float32Array(c),f=0;f<h.length;f+=6)h[f]*=s,h[f+1]*=a;return{index:l,aPoint:Array.from(h)}}var p=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],d=[],m=[],v=2,y=2;1===r.length&&(v=1,y=1);for(var g=0;g<v;g++)for(var x=0;x<y;x++){var T=4*(2*x+g),E=n?[0,0,1,1,r[0][4]]:r[2*x+g],S=E[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],b=((g+g+1)/v-1)/2,A=((x+x+1)/y-1)/2,_=E[0],C=E[1],R=E[4]?E[3]:E[2],O=E[4]?E[2]:E[3],w=[p[0]/v+b,p[1]/y+A,p[2]/v+b,p[3]/y+A,p[4]/v+b,p[5]/y+A,p[6]/v+b,p[7]/y+A];d.push(w[0]*s,w[1]*a,S[0]*R+_,S[1]*O+C,e,0,w[2]*s,w[3]*a,S[2]*R+_,S[3]*O+C,e,0,w[4]*s,w[5]*a,S[4]*R+_,S[5]*O+C,e,0,w[6]*s,w[7]*a,S[6]*R+_,S[7]*O+C,e,0),this.lineMode?m.push(T,1+T,1+T,3+T,3+T,2+T,2+T,T):m.push(T,1+T,2+T,2+T,1+T,3+T)}return{index:m,aPoint:d}},e}();function Tn(e){return t.maxSpriteTextureCount=Math.min(e.maxFragmentTextures,16),e.maxVertexUniforms>=256?t.maxSpriteMeshItemCount=32:e.maxVertexUniforms>=128?t.maxSpriteMeshItemCount=16:void(t.maxSpriteTextureCount=8)}function En(t){var e,r=t.renderer,i=t.filter,n=r.blending,o=r.side,s=r.occlusion,a=r.mask,u=r.maskMode,l=r.order,c=+n,h=t.cachePrefix||"-",f=(null===(e=null==i?void 0:i.mesh)||void 0===e?void 0:e.shaderCacheId)||"$F$";return{side:o,occlusion:s,blending:n,mask:a,maskMode:u,cachePrefix:h,filter:i,cacheId:"".concat(h,".").concat(f,".").concat(+o,"+").concat(+s,"+").concat(c,"+").concat(l,"+").concat(u,".").concat(a)}}function Sn(e,r,i){var n=null!=i?i:{},o=n.count,s=void 0===o?2:o,a=n.env,u=void 0===a?"":a,l=n.ignoreBlend,h=n.wireframe,f=[["MAX_ITEM_COUNT",s],["PRE_MULTIPLY_ALPHA",!1],["ENV_EDITOR",u===c],["ADJUST_LAYER",!!r],["USE_BLEND",!l],["MAX_FRAG_TEX",t.maxSpriteTextureCount>=16?16:8]],p=h?Ai:Ci.replace(/#pragma\s+FILTER_FRAG/,(null==r?void 0:r.fragment)||""),d=_i.replace(/#pragma\s+FILTER_VERT/,(null==r?void 0:r.vertex)||"vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}");return{fragment:br(f,p,t.ShaderType.fragment,e),vertex:br(f,d,t.ShaderType.vertex,e),glslVersion:1===e?t.GLSLVersion.GLSL1:t.GLSLVersion.GLSL3,marcos:f,shared:!0}}function bn(t,e){return t.filter?"".concat(t.filter.mesh.shaderCacheId,"_effects_filter"):"".concat(t.cachePrefix,"_effects_sprite_").concat(e)}function An(t,e,r,i){var n=t.filter,o=t.wireframe,s=Sn(r,null==n?void 0:n.mesh,{count:e,wireframe:o,env:i});return s.shared=!0,o||(s.cacheId=bn(t,e)),s}var _n="listIndex",Cn=function(){function e(t){this.composition=t,this.meshSplits=[],this.items=[],this.meshes=[],this.time=0,this.itemsToRemove=[],this.itemsToAdd=[],this.engine=t.getEngine()}return e.prototype.resetMeshSplits=function(){this.meshSplits.length=0,this.meshes.length=0,this.items.length=0,this.itemsToAdd.length=0,this.itemsToRemove.length=0},e.prototype.diffMeshSplits=function(){for(var e,r,i,n,o,s,l=this.meshSplits,c=this.itemsToRemove,h=this.itemsToAdd,f=[],p=[],d=[],m=[],v=this.items,y={layerToAdd:[]},g=[],x=0;x<c.length;x++){if(Rn(S=c[x]))f.push.apply(f,u([],a(this.removeMeshSplitsItem(v,S,l,c)),!1)),this.check();else{var T=v.indexOf(S);T>-1&&(v.splice(T,1),g.length=0,T>0&&(g=this.combineSplits(v,T-1,l),f.push.apply(f,u([],a(g),!1))),!g.length&&T<=v.length-1&&(g=this.combineSplits(v,T,l),f.push.apply(f,u([],a(g),!1))),this.check())}}var E=!1;for(x=0;x<h.length;x++)for(var S=h[x],b=this.addMeshSplitsItem(v,S,l),A=0;A<b.length;A++){var _=b[A];if(_.spriteMesh)throw new Error("no sprite mesh in neo split");var C=_.spriteMesh=new xn(this.engine,_.renderInfo,this.composition);p.push(C.mesh),C.setItems(_.items.map((function(t){return t.content}))),C.applyChange(),C.splitLayer&&(null===(e=y.layerToAdd)||void 0===e||e.push(C)),_.dirty=!1,this.check(),E=!0}if(E){var R,O=function(e){var a=l[e],u=l[e+1];if(u.cacheId===a.cacheId&&!(null===(r=u.spriteMesh)||void 0===r?void 0:r.splitLayer)&&!(null===(i=a.spriteMesh)||void 0===i?void 0:i.splitLayer)&&a.items.length+u.items.length<=t.maxSpriteMeshItemCount){var c=a.items[0],h=u.items[u.items.length-1],f=w.getMeshSplits(v,v.indexOf(c),v.indexOf(h));if(1===f.length){Object.keys(f[0]).forEach((function(t){a[t]=f[0][t]})),null===(n=a.spriteMesh)||void 0===n||n.setItems(a.items.map((function(t){return t.content}))),null===(o=a.spriteMesh)||void 0===o||o.applyChange();var m=null===(s=u.spriteMesh)||void 0===s?void 0:s.mesh;a.spriteMesh&&a.spriteMesh.mesh&&(a.spriteMesh.mesh.priority=u.indexEnd),p.includes(m)?B(p,m):z(d,m),l.splice(e+1,1),e--}}R=e},w=this;for(x=0;x<l.length-1;x++)O(x),x=R}c.length=0;for(x=0;x<l.length;x++){var M=(I=l[x]).spriteMesh;if(0===I.items.length)throw new Error("split not combined");if(I.dirty){var L=I.indexStart;M.mesh.priority!==L&&(M.mesh.priority=L,m.push(M.mesh)),M.setItems(I.items.map((function(t){return t.content})))}M.applyChange(),I.dirty=!1}if(f.length)for(x=0;x<f.length;x++){var I,P=(C=(I=f[x]).spriteMesh).mesh;P.dispose({material:{textures:t.DestroyOptions.keep}}),d.push(P)}if(this.itemsToRemove.length=0,this.itemsToAdd.length=0,p.length+d.length+m.length){var F=this.meshes;return this.meshSplits.forEach((function(t,e){return F[e]=t.spriteMesh.mesh})),F.length=this.meshSplits.length,{add:p.length?p:void 0,remove:d.length?d:void 0,modify:m.length?m:void 0,layer:y.layerToAdd.length>0?y:void 0}}},e.prototype.addItem=function(t){this.items.includes(t)?B(this.itemsToRemove,t):z(this.itemsToAdd,t)},e.prototype.removeItem=function(t){this.items.includes(t)?Rn(t)?this.itemsToRemove.unshift(t):this.itemsToRemove.push(t):B(this.itemsToAdd,t)},e.prototype.getSpriteMesh=function(t){for(var e=this.meshSplits,r=0;r<e.length;r++){var i=e[r].spriteMesh;if(i.items.indexOf(t)>-1)return i}},e.prototype.onUpdate=function(t){for(var e=this.meshSplits,r=0;r<e.length;r++){for(var i=e[r].spriteMesh,n=i.items,o=0;o<n.length;o++){var s=n[o];s.ended||i.updateItem(s)}i.applyChange()}},e.prototype.dispose=function(){this.meshSplits.forEach((function(t){var e;null===(e=t.spriteMesh)||void 0===e||e.mesh.dispose()}))},e.prototype.check=function(){},e.prototype.addMeshSplitsItem=function(t,e,r){if(-1!==t.indexOf(e))throw Error("item has been added");if(!r[0]){if(U(t,e,_n),Rn(e)){var i=e.createContent(),n={indexStart:e.listIndex,indexEnd:e.listIndex,items:[e],renderInfo:i.renderInfo,cacheId:i.renderInfo.cacheId,textures:[e.content.renderer.texture]};return r.unshift(n),[n]}return[]}for(var o=function(i){var n=r[i],o=e.listIndex;if(Rn(e)){if(o<=n.indexEnd){U(t,e,_n);var a=t.indexOf(e),u=Math.min(a,t.indexOf(n.items[0])),l=Math.max(a,t.indexOf(n.items[n.items.length-1])),c=s.getMeshSplits(t,u,l),h=c.findIndex((function(t){return t.items.includes(e)}));if(2===c.length)return r.splice(i+h,0,c[h]),Object.keys(c[1-h]).forEach((function(t){n[t]=c[1-h][t]})),{value:[c[h]]};if(3===c.length){if(Object.keys(c[0]).forEach((function(t){n[t]=c[0][t]})),r.splice(i+1,0,c[1],c[2]),1!==h)throw Error("neo split not in middle");return{value:[c[1],c[2]]}}if(1!==c.length)throw Error("invalid splits 1");return Object.keys(c[0]).forEach((function(t){n[t]=c[0][t]})),{value:[]}}}else{if(o<n.indexStart||o===n.indexEnd)return U(t,e,_n),{value:[]};if(o<n.indexEnd){U(t,e,_n);var f=n.items[n.items.length-1],p=t.indexOf(f),d=s.getMeshSplits(t,t.indexOf(n.items[0]),p);if(Object.keys(d[0]).forEach((function(t){n[t]=d[0][t]})),2===d.length)return r.splice(i+1,0,d[1]),{value:[d[1]]};if(1!==d.length)throw Error("invalid splits 2")}}},s=this,a=0;a<r.length;a++){var u=o(a);if("object"==typeof u)return u.value}if(U(t,e,_n),Rn(e)){var l=r[r.length-1],c=this.getMeshSplits(t,t.indexOf(l.items[0]),t.indexOf(e));if(Object.keys(c[0]).forEach((function(t){l[t]=c[0][t]})),2===c.length)return r.push(c[1]),[c[1]];if(1!==c.length)throw Error("invalid splits 3")}return[]},e.prototype.removeMeshSplitsItem=function(t,e,r,i){for(var n,o,s=null,a=-1,u=[],l=0;l<r.length;l++){var c=r[l];if(c.indexStart<=e.listIndex&&c.indexEnd>=e.listIndex){s=c,a=l;break}}if(s){var h=s.items.indexOf(e);if(h<0){if(null==i?void 0:i.includes(e))return[];throw Error("item not found")}if(s.items.splice(h,1),s.dirty=!0,B(t,e),0===s.items.length){if(B(r,s),u.push(s),s=r[a-=1],!r.length||a<0)return u}else s.indexEnd=s.items[s.items.length-1].listIndex,s.indexStart=s.items[0].listIndex;if(0===a||a===r.length-2){var f=r[a],p=r[a+1];if(f&&p){var d=f.items[0],m=p.items[p.items.length-1];1===(v=this.getMeshSplits(t,t.indexOf(d),t.indexOf(m))).length&&(v[0].spriteMesh=r[a].spriteMesh,null===(n=v[0].spriteMesh)||void 0===n||n.invalidMaterial(),r[a]=v[0],u.push(r.splice(a+1,1)[0]))}}else if(a===r.length-1)if(0===s.items.length)u.push(r.splice(a,1)[0]);else{f=r[a-1],p=r[a],d=f.items[0],m=p.items[p.items.length-1];1===(v=this.getMeshSplits(t,t.indexOf(d),t.indexOf(m))).length&&(v[0].spriteMesh=r[a-1].spriteMesh,null===(o=v[0].spriteMesh)||void 0===o||o.invalidMaterial(),r[a-1]=v[0],u.push(r.splice(a,1)[0]))}else{var v;f=r[a-1],p=r[a+1],d=f.items[0],m=p.items[p.items.length-1];2===(v=this.getMeshSplits(t,t.indexOf(d),t.indexOf(m))).length&&(v[0].spriteMesh=r[a].spriteMesh,v[1].spriteMesh=r[a+1].spriteMesh,r[a]=v[0],r[a+1]=v[1],u.push(r.splice(a-1,1)[0]))}}return u},e.prototype.combineSplits=function(t,e,r){var i=t[e],n=[];if(Rn(i)&&i.composition){for(var o=void 0,s=0;s<r.length;s++){if(r[s].items.includes(i)){o=s;break}}var a=void 0,u=void 0;if(0===o?(a=r[o],u=r[o+1]):(a=r[o-1],u=r[o]),a&&u){var l=t.indexOf(a.items[0]),c=t.indexOf(u.items[u.items.length-1]);if(Number.isInteger(l)&&Number.isInteger(c)){var h=this.getMeshSplits(t,l,c);1===h.length&&(h[0].spriteMesh=r[o].spriteMesh,0===o?(r[0]=h[0],n.push(r.splice(1,1)[0])):(n.push(r.splice(o-1,1)[0]),r[o-1]=h[0]))}}}return n},e.prototype.getMeshSplits=function(e,r,i,n){void 0===r&&(r=0),void 0===i&&(i=e.length-1);for(var o=null,s=[],a=r;a<=i;a++){var u=e[a];if(n||u.started&&!(u.lifetime<0))if(Rn(u)){var l=u.createContent().renderInfo.cacheId,c=u.content.renderer.texture,h=!0;if(o){var f=o.textures.includes(c)?0:1;o.cacheId===l&&Qe.isSprite(u)&&o.items.length<t.maxSpriteMeshItemCount&&f+o.textures.length<=t.maxSpriteTextureCount?(U(o.items,u,_n),z(o.textures,c),h=!1):s.push(o)}h&&(o={indexStart:u.listIndex,cacheId:l,renderInfo:u.content.renderInfo,items:[u],textures:[c]})}else{if(n&&!u.contentVisible)continue;o&&(s.push(o),o=null)}}return o&&s.push(o),s.forEach((function(t){t.indexEnd=t.items[t.items.length-1].listIndex,t.dirty=!0})),s},e}();function Rn(t){return Qe.isSprite(t)||Qe.isFilterSprite(t)}var On={blending:0,cacheId:"-",mask:0,maskMode:0,occlusion:!1,side:0,cachePrefix:"-"},wn=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="sprite",t}return r(i,e),i.precompile=function(e,r,i){var n,o=r.getShaderLibrary(),s=r.engine.gpuCapability,a=s.level,u=s.detail,l=(null!=i?i:{}).env;if(!o.shaderResults[bn(On,2)]){o.addShader(An(On,2,a,l)),o.addShader(An(On,t.maxSpriteMeshItemCount,a,l));var c=!1;null===(n=e[0])||void 0===n||n.items.forEach((function(e){t.Item.isFilter(e)&&e.content.filter&&(c=!0,V(e.content.filter).forEach((function(t){if(!t.isParticle){var e=Sn(a,t,t);t.shaderCacheId&&(e.cacheId="".concat(t.shaderCacheId,"_effects_filter")),o.addShader(e)}})))})),c&&o.addShader(ri(a,!1)),u.writableFragDepth&&o.addShader(ri(a,!0))}return Promise.resolve()},i.prototype.onCompositionDestroyed=function(t){t.loaderData.spriteGroup.dispose(),delete t.loaderData.spriteGroup},i.prototype.onCompositionReset=function(t,e){if(!t.loaderData.spriteGroup){var r=new Cn(t);t.loaderData.spriteGroup=r,r.resetMeshSplits()}},i.prototype.onCompositionItemLifeBegin=function(t,e){var r=t.loaderData.spriteGroup;e.type!==w.composition&&r.addItem(e)},i.prototype.onCompositionItemRemoved=function(t,e){t.loaderData.spriteGroup.removeItem(e)},i.prototype.onCompositionUpdate=function(t,e){t.loaderData.spriteGroup.onUpdate(e)},i.prototype.prepareRenderFrame=function(t,e){var r,i,n,o=t.loaderData.spriteGroup.diffMeshSplits();return!!o&&(null===(r=o.remove)||void 0===r||r.forEach((function(t){return e.removeMeshFromDefaultRenderPass(t)})),null===(i=o.add)||void 0===i||i.forEach((function(t){return e.addMeshToDefaultRenderPass(t)})),null===(n=o.modify)||void 0===n||n.forEach((function(t){e.removeMeshFromDefaultRenderPass(t),e.addMeshToDefaultRenderPass(t)})),!!(this.layerInfo=o.layer))},i.prototype.postProcessFrame=function(t,e){var r,i;null===(i=null===(r=this.layerInfo)||void 0===r?void 0:r.layerToAdd)||void 0===i||i.forEach((function(t){var r=t.items[0].filter;if(void 0!==r){var i=r.passSplitOptions,n=e.splitDefaultRenderPassByMesh(t.mesh,i);r.renderPassDelegate&&(n.delegate=r.renderPassDelegate),r.onRenderPassCreated&&r.onRenderPassCreated(n,e)}})),this.layerInfo=void 0},i}(sr),Mn=new Dt,Ln=new Mt(1,1,1);new Mt;var In=function(){function t(t,e){var r;this.vfxItem=e,this.active=!1,this.transform=e.transform;var i=this.transform.scale;this.basicTransform={position:this.transform.position.clone(),rotation:this.transform.getRotation(),scale:new Mt(i.x,i.y,i.x)};var n=t.rotationOverLifetime,o=t.sizeOverLifetime,s=t.positionOverLifetime,a=void 0===s?{}:s;if(a){a.path&&(this.basicTransform.path=be(a.path));var u=a.linearX||a.linearY||a.linearZ;u&&(this.linearVelOverLifetime={x:a.linearX&&be(a.linearX),y:a.linearY&&be(a.linearY),z:a.linearZ&&be(a.linearZ),asMovement:a.asMovement,enabled:!!u});var l=a.orbitalX||a.orbitalY||a.orbitalZ;l&&(this.orbitalVelOverLifetime={x:a.orbitalX&&be(a.orbitalX),y:a.orbitalY&&be(a.orbitalY),z:a.orbitalZ&&be(a.orbitalZ),center:$t(a.orbCenter),asRotation:a.asRotation,enabled:!!l}),this.speedOverLifetime=a.speedOverLifetime&&be(a.speedOverLifetime)}if(o&&(o.separateAxes?(this.sizeSeparateAxes=!0,this.sizeXOverLifetime=be(o.x||1),this.sizeYOverLifetime=be(o.y||1),this.sizeZOverLifetime=be(o.z||1)):this.sizeXOverLifetime=be(o.size||1)),n&&(this.rotationOverLifetime={asRotation:n.asRotation,separateAxes:n.separateAxes,z:be(n.z||0)},n.separateAxes)){var c=this.rotationOverLifetime;c.x=be(n.x||0),c.y=be(n.y||0)}this.options={reusable:!!e.reusable,delay:e.delay||0,startSpeed:a.startSpeed||0,startSize:i&&i.x||1,sizeAspect:i&&i.x/(i.y||1)||1,duration:e.duration||0,looping:e.endBehavior&&e.endBehavior===at.loop,endBehavior:e.endBehavior||0,gravity:Mt.fromArray(a.gravity||[]),gravityModifier:be(null!==(r=a.gravityOverLifetime)&&void 0!==r?r:0),direction:a.direction?Mt.fromArray(a.direction).normalize():new Mt},this.id=e.id,this.time=0,this.name=e.name,this.visible=e.getVisible()}return Object.defineProperty(t.prototype,"ended",{get:function(){return this.time>this.options.duration&&!this.options.looping&&!this.options.reusable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startSize",{get:function(){return this.basicTransform.scale},set:function(t){this.basicTransform.scale=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"velocity",{get:function(){return this._velocity||(this._velocity=this.options.direction.clone(),this._velocity.multiply(this.options.startSpeed)),this._velocity},enumerable:!1,configurable:!0}),t.prototype.getWillTranslate=function(){return!!(this.linearVelOverLifetime&&this.linearVelOverLifetime.enabled||this.orbitalVelOverLifetime&&this.orbitalVelOverLifetime.enabled||this.options.gravityModifier&&!this.options.gravity.isZero()||this.options.startSpeed&&!this.options.direction.isZero())},t.prototype.updateTime=function(t){var e=t-this.options.delay,r=this.options.duration;if(e>=r&&this.options.looping){for(var i=e-r;i>r;)i-=r;this.time=i}else{var n=4===this.options.endBehavior;this.time=n?Math.min(r,e):e}},t.prototype.getRenderData=function(t,e){var r=this.options,i=Ln.setFromNumber(1),n=Mn.set(0,0,0),o=!1,s=!1,a=t<0?t:Math.max(t,0),u=r.duration,l=a/u,c={life:l,transform:this.transform};l=l<0?0:l>1?1:l,this.sizeXOverLifetime&&(i.x=this.sizeXOverLifetime.getValue(l),this.sizeSeparateAxes?(i.y=this.sizeYOverLifetime.getValue(l),i.z=this.sizeZOverLifetime.getValue(l)):i.z=i.y=i.x,o=!0),this.calculateScaling(o,i,e);var h,f=this.rotationOverLifetime;if(f){var p=function(t){return f.asRotation?t.getValue(l):t.getIntegrateValue(0,l,u)},d=p(f.z),m=f.separateAxes;n.x=m?p(f.x):0,n.y=m?p(f.y):0,n.z=d,s=!0}if(s||e){var v=Mn.addEulers(this.basicTransform.rotation,n);c.transform.setRotation(v.x,v.y,v.z)}return(this.getWillTranslate()||e)&&Jt(h=new Mt,this,this.options.gravity,a,u,this.basicTransform.position,this.velocity),this.basicTransform.path&&(h||(h=this.basicTransform.position.clone()),h.add(this.basicTransform.path.getValue(l))),h&&this.transform.setPosition(h.x,h.y,h.z),c.active=this.active,c},t.prototype.calculateScaling=function(t,e,r){this.transform.setScale(e.x*this.startSize.x,e.y*this.startSize.y,e.z*this.startSize.z)},t}(),Pn=[[0,0,1,1,void 0]],Fn=[1,1,1,1],Nn=function(t){function e(e,r,n){var o,s,a,u,l,c,h,f,p=t.call(this,e,n)||this;p.startColor=[1,1,1,1];var d=e.interaction,m=e.renderer,v=e.options,y=e.listIndex,g=void 0===y?0:y,x=r.emptyTexture,T=n.transform.scale;p.options=i(i({},p.options),{startColor:v.startColor||[1,1,1,1]}),p.interaction=d,p.renderer={renderMode:null!==(o=m.renderMode)&&void 0!==o?o:M.BILLBOARD,blending:null!==(s=m.blending)&&void 0!==s?s:S.ALPHA,texture:p.initTexture(m.texture,x),occlusion:!!m.occlusion,transparentOcclusion:!!m.transparentOcclusion||m.maskMode===A.MASK,side:null!==(a=m.side)&&void 0!==a?a:b.DOUBLE,shape:m.shape,mask:null!==(u=m.mask)&&void 0!==u?u:0,maskMode:null!==(l=m.maskMode)&&void 0!==l?l:A.NONE,order:g};var E=se(m.anchor,m.particleOrigin);m.anchor||void 0===m.particleOrigin||p.basicTransform.position.add([-E[0]*T.x,-E[1]*T.y,0]),p.transform.setAnchor(E[0]*T.x,E[1]*T.y,0);var _=e.colorOverLifetime;return _&&(p.opacityOverLifetime=be(null!==(c=_.opacity)&&void 0!==c?c:1),_.color&&_.color[0]===ot.GRADIENT_COLOR&&(p.colorOverLifetime=H(_.color[1]))),(null===(h=e.filter)||void 0===h?void 0:h.feather)&&1!==(null===(f=e.filter)||void 0===f?void 0:f.feather)&&(p.feather=be(e.filter.feather)),p.emptyTexture=x,p.splits=e.splits||Pn,p.listIndex=n.listIndex||0,p.textureSheetAnimation=e.textureSheetAnimation,p.cachePrefix="-",p.parentId=n.parentId,p.reusable=n.reusable,p._renderInfo=En(p),p}return r(e,t),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){this._filter=t,this._renderInfo.filter=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderInfo",{get:function(){return this._renderInfo},enumerable:!1,configurable:!0}),e.prototype.initTexture=function(t,e){return null!=t?t:e},e.prototype.getTextures=function(){var t=[],e=this.renderer.texture;return e&&t.push(e),t},e.prototype.setColor=function(t,e,r,i){this.customColor=[t,e,r,i]},e.prototype.setOpacity=function(t){this.customOpacity=t},e.prototype.getCustomOpacity=function(){return this.customOpacity},e.prototype.getRenderData=function(e,r){var i,n=t.prototype.getRenderData.call(this,e,r),o=te(Fn,1),s=e<0?e:Math.max(e,0),a=this.options.duration,u=s/a<0?0:s/a>1?1:s/a;if(this.customColor)n.color=this.customColor;else{var l=this.opacityOverLifetime,c=this.colorOverLifetime;c&&(o=X(c,u,!0),i=!0),l&&(o[3]*=l.getValue(u),i=!0),(i||r)&&(n.color=ie(this.startColor,o,this.options.startColor))}var h=this.textureSheetAnimation;if(h){var f=h.total||h.row*h.col,p=0,d=0,m=1,v=1,y=void 0;if(this.splits){var g=this.splits[0];y=g[4],p=g[0],d=g[1],y?(m=g[3],v=g[2]):(m=g[2],v=g[3])}var x=void 0,T=void 0;y?(x=1/h.row*m,T=1/h.col*v):(x=1/h.col*m,T=1/h.row*v);var E=void 0;if(h.animate){var S=Math.round(u*(f-1)),b=Math.floor(S/h.col),A=S-b*h.col;E=y?[x*b,T*(h.col-A)]:[x*A,T*(1+b)]}else E=[0,T];n.texOffset=[p+E[0],v+d-E[1],x,T]}else r&&(n.texOffset=[0,0,1,1]);return n.visible=this.vfxItem.contentVisible,n.startSize=this.startSize,n},e.prototype.calculateScaling=function(t,e,r){(t||r)&&this.transform.setScale(e.x,e.y,e.z)},e}(In),Vn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.sprite},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){this.sprite=t.content},n.prototype.onLifetimeBegin=function(t,e){e.active=!0},n.prototype.onItemRemoved=function(t,e){e&&(delete e.mesh,t.destroyTextures(e.getTextures()))},n.prototype.onItemUpdate=function(t,e){var r;null===(r=this.content)||void 0===r||r.updateTime(this.time)},n.prototype.getCurrentPosition=function(){var t=new Mt;return this.transform.assignWorldTRS(t),t},n.prototype.setColor=function(t,e,r,i){this.content.setColor(t,e,r,i)},n.prototype.setOpacity=function(t){this.content.setOpacity(t)},n.prototype.getBoundingBox=function(){var e=this.content;if(e&&this.transform){var r=this.transform.getWorldMatrix(),i=e.startSize,n=le(Mt.ZERO,i.x/2,i.y/2);return n.forEach((function(t){r.transformPoint(t.p0),r.transformPoint(t.p1),r.transformPoint(t.p2)})),{type:t.HitTestType.triangle,area:n}}},n.prototype.getHitTestParams=function(t){var e,r,i=this.content,n=null===(e=this.composition)||void 0===e?void 0:e.loaderData.spriteGroup,o=i&&i.interaction;if((t||o)&&n&&i){var s=this.getBoundingBox();if(s)return{behavior:(null===(r=i.interaction)||void 0===r?void 0:r.behavior)||0,type:s.type,triangles:s.area,backfaceCulling:i.renderer.side===b.FRONT}}},n.prototype.getRenderData=function(){return this.content.getRenderData(this.content.time)},n.prototype.doCreateContent=function(t){var e=t.getRendererOptions().emptyTexture;return new Nn(this.sprite,{emptyTexture:e},this)},n.prototype.createWireframeMesh=function(t,e){var r=new xn(this.composition.getEngine(),i({wireframe:!0},t.renderInfo),this.composition);return r.setItems([t]),r.mesh.material.setVector3("uFrameColor",Mt.fromArray(e)),r.mesh.priority=999,r},n}(Qe),Dn=1,zn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return w.filter},enumerable:!1,configurable:!0}),e.prototype.onConstructed=function(e){t.prototype.onConstructed.call(this,e),this.filterOptions=e.content.filter,this.cachePrefix="filter:"+Dn++,this.sprite.renderer.texture=this.composition.renderFrame.transparentTexture},e.prototype.onItemUpdate=function(e,r){var i,n,o,a,u;t.prototype.onItemUpdate.call(this,e,r);var l=null===(o=this._content)||void 0===o?void 0:o.mesh;if(l){var c=this.filter.mesh.variables;if(c){var h=l.mesh.material;try{for(var f=s(Object.keys(c)),p=f.next();!p.done;p=f.next()){var d=p.value,m=c[d](r);m.length>4?h.setMatrix(d,Ft.fromArray(m)):h.setVector4(d,zt.fromArray(m))}}catch(t){i={error:t}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(i)throw i.error}}}}null===(u=(a=this.filter).onItemUpdate)||void 0===u||u.call(a,e,this)},e.prototype.onItemRemoved=function(e,r){var i,n;null===(n=(i=this.filter).onItemRemoved)||void 0===n||n.call(i,this),t.prototype.onItemRemoved.call(this,e,r)},e.prototype.doCreateContent=function(e){var r,i=t.prototype.doCreateContent.call(this,e),n=D(this.filterOptions,e);this.filter=n,i.renderInfo.filter=n,i.filter=n,i.renderInfo.cacheId=i.renderInfo.cacheId.replace("$F$",null!==(r=n.mesh.shaderCacheId)&&void 0!==r?r:"");var o=n.mesh.variables;return n.mesh.uniformValues||(n.mesh.uniformValues={}),o&&Object.keys(o).forEach((function(t){var e=o[t];n.mesh.uniformValues[t]=e(0)})),i},e}(Vn),Bn=function(){function e(e,r){var i,n,o,s;this.particleCount=0;var a,u,l=r.composition.getEngine(),f=(null!==(i=l.renderer)&&void 0!==i?i:{}).env,p=e.speedOverLifetime,d=e.colorOverLifetime,m=e.linearVelOverLifetime,v=e.orbitalVelOverLifetime,y=e.sizeOverLifetime,g=e.rotationOverLifetime,x=e.sprite,T=e.gravityModifier,E=e.maxCount,S=e.duration,b=e.textureFlip,A=e.useSprite,_=e.name,C=e.filter,R=e.gravity,O=e.forceTarget,w=e.side,M=e.occlusion,L=e.anchor,I=e.blending,P=e.maskMode,F=e.mask,N=e.transparentOcclusion,V=e.listIndex,z=e.meshSlots,B=e.renderMode,U=void 0===B?0:B,k=e.diffuse,G=void 0===k?Vr.createWithData(l):k,X=l.gpuCapability.detail,H=X.halfFloatTexture,Y=X.maxVertexUniforms,j=[["RENDER_MODE",+U],["PRE_MULTIPLY_ALPHA",!1],["ENV_EDITOR",f===c]],W=l.gpuCapability.level,Z={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},q={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},K=Y>0,J={},$=0,tt=0;if(this.useSprite=A,K&&j.push(["ENABLE_VERTEX_TEXTURE",!0]),p&&(j.push(["SPEED_OVER_LIFETIME",!0]),tt|=2,J.uSpeedLifetimeValue=p.toUniform(Z)),(null==x?void 0:x.animate)&&(j.push(["USE_SPRITE",!0]),tt|=4,J.uFSprite=J.uSprite=new Float32Array([x.col,x.row,x.total,x.blend?1:0]),this.useSprite=!0),C&&C.name!==h){j.push(["USE_FILTER",!0]),tt|=8;var et=D(C,r.composition);if(!et.particle)throw new Error("particle filter ".concat(C.name," not implement"));a=et.particle,Object.keys(null!==(n=a.uniforms)&&void 0!==n?n:{}).forEach((function(t){var e,r=null===(e=a.uniforms)||void 0===e?void 0:e[t];if(J[t])throw new Error("conflict uniform name:"+t);J[t]=null==r?void 0:r.toUniform(Z)})),Object.keys(null!==(o=a.uniformValues)&&void 0!==o?o:{}).forEach((function(t){var e,r=null===(e=a.uniformValues)||void 0===e?void 0:e[t];if(J[t])throw new Error("conflict uniform name:"+t);J[t]=r}))}(null==d?void 0:d.color)&&(j.push(["COLOR_OVER_LIFETIME",!0]),tt|=16,J.uColorOverLifetime=d.color instanceof Vr?d.color:Vr.createWithData(l,Q(d.color))),(null==d?void 0:d.opacity)?J.uOpacityOverLifetimeValue=d.opacity.toUniform(Z):J.uOpacityOverLifetimeValue=be(1).toUniform(Z),["x","y","z"].forEach((function(t,e){var r=0,i=0;(null==m?void 0:m[t])&&(J["uLinear".concat(t.toUpperCase(),"ByLifetimeValue")]=m[t].toUniform(Z),r=1,tt|=1<<7+e,m.enabled=!0),j.push(["LINEAR_VEL_".concat(t.toUpperCase()),r]),(null==v?void 0:v[t])&&(J["uOrb".concat(t.toUpperCase(),"ByLifetimeValue")]=v[t].toUniform(Z),i=1,tt|=1<<10+e,u=!0,v.enabled=!0),j.push(["ORB_VEL_".concat(t.toUpperCase()),i])})),(null==m?void 0:m.asMovement)&&(j.push(["AS_LINEAR_MOVEMENT",!0]),tt|=32),u&&((null==v?void 0:v.asRotation)&&(j.push(["AS_ORBITAL_MOVEMENT",!0]),tt|=64),J.uOrbCenter=new Float32Array((null==v?void 0:v.center)||[0,0,0])),J.uSizeByLifetimeValue=null==y?void 0:y.x.toUniform(Z),(null==y?void 0:y.separateAxes)&&(j.push(["SIZE_Y_BY_LIFE",1]),tt|=16384,J.uSizeYByLifetimeValue=null===(s=null==y?void 0:y.y)||void 0===s?void 0:s.toUniform(Z)),(null==g?void 0:g.z)&&(J.uRZByLifeTimeValue=g.z.toUniform(Z),tt|=32768,j.push(["ROT_Z_LIFETIME",1])),(null==g?void 0:g.x)&&(J.uRXByLifeTimeValue=g.x.toUniform(Z),tt|=65536,j.push(["ROT_X_LIFETIME",1])),(null==g?void 0:g.y)&&(J.uRYByLifeTimeValue=g.y.toUniform(Z),tt|=1<<17,j.push(["ROT_Y_LIFETIME",1])),(null==g?void 0:g.asRotation)&&(j.push(["ROT_LIFETIME_AS_MOVEMENT",1]),tt|=1<<18),J.uGravityModifierValue=T.toUniform(Z),O&&(j.push(["FINAL_TARGET",!0]),tt|=1<<19,J.uFinalTarget=new Float32Array(O.target||[0,0,0]),J.uForceCurve=O.curve.toUniform(Z)),H&&q.max?(tt|=1<<20,J.uFCurveValueTexture=Dr(l,ge.getAllData(q,!0),q.index,1)):J.uFCurveValues=ge.getAllData(q);var rt=Z.max+Z.curves.length-32>Y;if(2===W&&(Z.max=-1,Z.index=z?z[0]:kn(Z.index),q.index>0&&(q.max=-1,q.index=z?z[1]:kn(q.index))),rt&&H&&K){var it=Dr(l,ge.getAllData(Z,!0),Z.index,1);J.uVCurveValueTexture=it,$=1}else J.uVCurveValues=ge.getAllData(Z);var nt=["-p:",U,tt,Z.index,Z.max,q.index,q.max].join("+");j.push(["VERT_CURVE_VALUE_COUNT",Z.index],["FRAG_CURVE_VALUE_COUNT",q.index],["VERT_MAX_KEY_FRAME_COUNT",Z.max],["FRAG_MAX_KEY_FRAME_COUNT",q.max]);var ot=C?Ri.replace(/#pragma\s+FILTER_FRAG/,a.fragment):Ri,st="#define LOOKUP_TEXTURE_CURVE ".concat($,"\n").concat(Oi),at=C?st.replace(/#pragma\s+FILTER_VERT/,a.vertex||"void filterMain(float t){}\n"):st,ut={fragment:br(j,ot,t.ShaderType.fragment,W),vertex:br(j,at,t.ShaderType.vertex,W),glslVersion:1===W?t.GLSLVersion.GLSL1:t.GLSLVersion.GLSL3,shared:!0,cacheId:nt,marcos:j,name:"particle#".concat(_)};C&&(ut.cacheId+=C.name);var lt={shader:ut,uniformSemantics:{effects_MatrixV:"VIEW",effects_MatrixVP:"VIEWPROJECTION",uEditorTransform:"EDITOR_TRANSFORM",effects_ObjectToWorld:"MODEL"}},ct=xr(I);J.uTexOffset=new Float32Array(G?[1/G.getWidth(),1/G.getHeight()]:[0,0]),J.uMaskTex=G,J.uColorParams=new Float32Array([G?1:0,+ct,0,+(!!M&&!N)]),J.uParams=[0,S,0,0],J.uAcceleration=[(null==R?void 0:R[0])||0,(null==R?void 0:R[1])||0,(null==R?void 0:R[2])||0,0];var ht=qr.create(l,lt);ht.blending=!0,ht.depthTest=!0,ht.depthMask=!!M,ht.stencilRef=F?[F,F]:void 0,Cr(ht,P),Ar(ht,I),_r(ht,w);var ft={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"};Object.keys(J).map((function(t){var e=J[t];if(e instanceof Vr)ht.setTexture(t,e);else{var r=[];switch(ft[t]){case"vec4":ht.setVector4(t,zt.fromArray(e));break;case"vec3":ht.setVector3(t,Mt.fromArray(e));break;case"vec2":ht.setVector2(t,wt.fromArray(e));break;case"vec4Array":for(var i=0;i<e.length;i+=4){var n=new zt(e[i],e[i+1],e[i+2],e[i+3]);r.push(n)}ht.setVector4Array(t,r),r.length=0;break;default:console.warn("uniform ".concat(t,"'s type not in typeMap"))}}})),ht.setVector3("emissionColor",new Mt(0,0,0)),ht.setFloat("emissionIntensity",0);var pt=li.create(l,function(t,e,r){var i=Float32Array.BYTES_PER_ELEMENT,n=12*i,o={aPos:{size:3,offset:0,stride:n,data:new Float32Array(0)},aVel:{size:3,offset:3*i,stride:n,dataSource:"aPos"},aDirX:{size:3,offset:6*i,stride:n,dataSource:"aPos"},aDirY:{size:3,offset:9*i,stride:n,dataSource:"aPos"},aRot:{size:3,offset:0,stride:8*i,data:new Float32Array(0)},aSeed:{size:1,offset:3*i,stride:8*i,dataSource:"aRot"},aColor:{size:4,offset:4*i,stride:8*i,dataSource:"aRot"},aOffset:{size:4,stride:4*i,data:new Float32Array(0)}};e&&(o.aSprite={size:3,data:new Float32Array(0)});return{attributes:o,indices:{data:new Uint16Array(0)},name:r,maxVertex:t}}(4*E,this.useSprite,"particle#".concat(_))),dt=gi.create(l,{name:"MParticle_".concat(_),priority:V,material:ht,geometry:pt});this.anchor=L,this.mesh=dt,this.geometry=dt.firstGeometry(),this.forceTarget=O,this.sizeOverLifetime=y,this.speedOverLifetime=p,this.linearVelOverLifetime=m,this.orbitalVelOverLifetime=v,this.orbitalVelOverLifetime=v,this.gravityModifier=T,this.maxCount=E,this.duration=S,this.textureOffsets=b?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0]}return Object.defineProperty(e.prototype,"time",{get:function(){return this.mesh.material.getVector4("uParams").x},set:function(t){this.mesh.material.setVector4("uParams",new zt(+t,this.duration,0,0))},enumerable:!1,configurable:!0}),e.prototype.getPointColor=function(t){var e=this.geometry.getAttributeData("aRot"),r=32*t+4;return[e[r],e[r+1],e[r+2],e[r+3]]},e.prototype.getPointPosition=function(t){var e=this.geometry,r=48*t,i=e.getAttributeData("aPos"),n=e.getAttributeData("aOffset"),o=this.time-n[16*t+2],s=n[16*t+3],a=this.mesh.material,u=a.getVector4("uAcceleration").toVector3(),l=Mt.fromArray(i,r),c=Mt.fromArray(i,r+3),h=Jt(new Mt,this,u,o,s,l,c);if(this.forceTarget){var f=a.getVector3("uFinalTarget"),p=this.forceTarget.curve.getValue(o/s),d=1-p;h.x=h.x*d+f.x*p,h.y=h.y*d+f.y*p,h.z=h.z*d+f.z*p}return h},e.prototype.clearPoints=function(){this.resetGeometryData(this.geometry),this.particleCount=0,this.geometry.setDrawCount(0),this.maxParticleBufferCount=0},e.prototype.resetGeometryData=function(t){for(var e=t.getAttributeNames(),r=t.getIndexData(),i=0;i<e.length;i++){var n=e[i],o=t.getAttributeData(n);o&&t.setAttributeData(n,new o.constructor(0))}t.setIndexData(new r.constructor(0))},e.prototype.minusTime=function(t){for(var e=this.geometry.getAttributeData("aOffset"),r=0;r<e.length;r+=4)e[r+2]-=t;this.geometry.setAttributeData("aOffset",e),this.time-=t},e.prototype.removePoint=function(t){t<this.particleCount&&this.geometry.setAttributeSubData("aOffset",16*t,new Float32Array(16))},e.prototype.setPoint=function(t,e){var r=this.maxCount;if(e<r){var i=e+1,n=4*i,o=this.geometry,s=i>this.maxParticleBufferCount,a=1;this.particleCount>300?a=(this.particleCount+100)/this.particleCount:this.particleCount>100?a=1.4:this.particleCount>0&&(a=2);var u={aPos:new Float32Array(48),aRot:new Float32Array(32),aOffset:new Float32Array(16)},l=this.useSprite;l&&(u.aSprite=new Float32Array(12));var c=new Mt,h=new Lt,f=new Mt(1,1,1);t.transform.assignWorldTRS(c,h,f);var p=Ke.getRotation(h,new Dt),d=c.toArray(),m=p.toArray(),v=this.textureOffsets,y=[0,0,t.delay,t.lifetime],g=[0,0,1,1],x=t.vel,T=t.color,E=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],S=Math.random(),b=void 0;l&&(b=t.sprite);for(var A=0;A<4;A++){var _=2*A,C=3*A,R=4*A,O=12*A,w=8*A;u.aPos.set(d,O),x.fill(u.aPos,O+3),u.aRot.set(m,w),u.aRot[w+3]=S,u.aRot.set(T,w+4),l&&u.aSprite.set(b,C);var M=t.uv||g;if(M){var L=l?1-v[_+1]:v[_+1];y[0]=M[0]+v[_]*M[2],y[1]=M[1]+L*M[3]}u.aOffset.set(y,R);for(var I=A+A,P=(E[I]-this.anchor.x)*f.x,F=(E[I+1]-this.anchor.y)*f.y,N=0;N<3;N++)u.aPos[O+6+N]=t.dirX.getElement(N)*P,u.aPos[O+9+N]=t.dirY.getElement(N)*F}var V=new Uint16Array([0,1,2,2,1,3].map((function(t){return t+4*e})));if(s){var D=k(o.getIndexData(),6*i,a,6*r);D.set(V,6*e),o.setIndexData(D),this.maxParticleBufferCount=D.length/6}else o.setIndexSubData(6*e,V);Object.keys(u).forEach((function(t){var i=u[t],l=o.getAttributeStride(t)/Float32Array.BYTES_PER_ELEMENT;if(s){var c=k(o.getAttributeData(t),n*l,a,4*r*l);c.set(i,i.length*e),o.setAttributeData(t,c)}else o.setAttributeSubData(t,i.length*e,i)})),this.particleCount=Math.max(i,this.particleCount),o.setDrawCount(6*this.particleCount)}},e}(),Un=[10,32,64,160];function kn(t){for(var e=0;e<Un.length;e++){var r=Un[e];if(r>t)return r}return t||Un[0]}function Gn(t,e,r){var i,n,o,s,a;void 0===e&&(e="");var u=t.content,l=+((null===(i=u.renderer)||void 0===i?void 0:i.renderMode)||0),f=[["RENDER_MODE",l],["PRE_MULTIPLY_ALPHA",!1],["ENV_EDITOR",e===c]],p=r.level,d=r.detail,m={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},v={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},y=d.maxVertexUniforms>0,g=(null!==(n=u.positionOverLifetime)&&void 0!==n?n:{}).speedOverLifetime,x=0,T=0;y&&f.push(["ENABLE_VERTEX_TEXTURE",!0]),g&&(f.push(["SPEED_OVER_LIFETIME",!0]),T|=2,we(m,g));var E=u.textureSheetAnimation;E&&E.animate&&(f.push(["USE_SPRITE",!0]),T|=4);var S=void 0;if(u.filter&&u.filter.name!==h){f.push(["USE_FILTER",!0]),T|=8;var b=V(u.filter).find((function(t){return t.isParticle}));if(!b)throw Error("particle filter ".concat(u.filter.name," not implement"));S=b,null===(o=b.uniforms)||void 0===o||o.forEach((function(t){return we(m,t)}))}var A=u.colorOverLifetime;A&&A.color&&(f.push(["COLOR_OVER_LIFETIME",!0]),T|=16);var _=A&&A.opacity;_&&we(m,_);var C,R=u.positionOverLifetime;["x","y","z"].forEach((function(t,e){var r=0,i="linear"+t.toUpperCase(),n="orbital"+t.toUpperCase();(null==R?void 0:R[i])&&(we(m,R[i]),r=1,T|=1<<7+e),f.push(["LINEAR_VEL_".concat(t.toUpperCase()),r]);var o=0;(null==R?void 0:R[n])&&(we(m,R[n]),o=1,T|=1<<10+e,C=!0),f.push(["ORB_VEL_".concat(t.toUpperCase()),o])})),(null==R?void 0:R.asMovement)&&(f.push(["AS_LINEAR_MOVEMENT",!0]),T|=32),C&&(null==R?void 0:R.asRotation)&&(f.push(["AS_ORBITAL_MOVEMENT",!0]),T|=64);var O=u.sizeOverLifetime;we(m,null==O?void 0:O.x),(null==O?void 0:O.separateAxes)&&(f.push(["SIZE_Y_BY_LIFE",1]),T|=16384,we(m,null==O?void 0:O.y));var w=u.rotationOverLifetime;(null==w?void 0:w.z)&&(we(m,null==w?void 0:w.z),T|=32768,f.push(["ROT_Z_LIFETIME",1])),(null==w?void 0:w.separateAxes)&&(w.x&&(we(m,w.x),T|=65536,f.push(["ROT_X_LIFETIME",1])),w.y&&(we(m,w.y),T|=1<<17,f.push(["ROT_Y_LIFETIME",1]))),(null==w?void 0:w.asRotation)&&(f.push(["ROT_LIFETIME_AS_MOVEMENT",1]),T|=1<<18),we(m,null==R?void 0:R.gravityOverLifetime),(null==R?void 0:R.forceTarget)&&(f.push(["FINAL_TARGET",!0]),T|=1<<19,we(m,R.forceCurve));var M=d.halfFloatTexture;M&&v.max&&(T|=1<<20);var L=d.maxVertexUniforms,I=m.max+m.curves.length-32>L;di(hi)&&(I=!0),2===p&&(m.max=-1,v.index>0&&(v.max=-1)),I&&M&&y&&(x=1);var P=["-p:",l,T,m.index,m.max,v.index,v.max].join("+"),F={fragment:Ri,vertex:"#define LOOKUP_TEXTURE_CURVE ".concat(x,"\n").concat(Oi),shared:!0,cacheId:P,marcos:f,name:"particle#".concat(t.name)};return S&&(F.fragment=F.fragment.replace(/#pragma\s+FILTER_FRAG/,null!==(s=S.fragment)&&void 0!==s?s:""),F.vertex=F.vertex.replace(/#pragma\s+FILTER_VERT/,S.vertex||"void filterMain(float t){}\n"),F.cacheId+="+"+(null===(a=u.filter)||void 0===a?void 0:a.name)),f.push(["VERT_CURVE_VALUE_COUNT",m.index],["FRAG_CURVE_VALUE_COUNT",v.index],["VERT_MAX_KEY_FRAME_COUNT",m.max],["FRAG_MAX_KEY_FRAME_COUNT",v.max]),{shader:F,vertex:m.index,fragment:v.index}}function Xn(t,e,r){var i,n=null===(i=t.cacheId)||void 0===i?void 0:i.split("+");if(n[3]=e,n[5]=r,t.cacheId=n.join("+"),t.marcos)for(var o=0;o<t.marcos.length;o++){var s=t.marcos[o];if("VERT_CURVE_VALUE_COUNT"===s[0])s[1]=e;else if("FRAG_CURVE_VALUE_COUNT"===s[0]){s[1]=r;break}}}var Hn=function(t){this.content=t},Yn=function(){function t(t){this.sort=t,this.length=0}return t.prototype.findNodeByContent=function(t){var e=this.first;if(e)do{if(t(e.content))return e}while(e=e.next)},t.prototype.insertNode=function(t,e){var r=t.next;t.next=e,e.pre=t,e.next=r,r&&(r.pre=e)},t.prototype.shiftNode=function(t){var e=new Hn(t);if(this.length++,1===this.length)return this.first=this.last=e;for(var r=this.first;r;){if(!(this.sort(r.content,e.content)<=0))return r.pre?this.insertNode(r.pre,e):(this.first=e,e.next=r,r.pre=e),e;if(!r.next)return this.insertNode(r,e),this.last=e;r=r.next}},t.prototype.pushNode=function(t){var e=new Hn(t);if(this.length++,1===this.length)return this.last=this.first=e;for(var r=this.last;r;){if(!(this.sort(e.content,r.content)<=0))return this.insertNode(r,e),r===this.last&&(this.last=e),e;if(this.first===r)return r.pre=e,e.next=r,this.first=e;r=r.pre}},t.prototype.removeNode=function(t){var e=this.first;if(this.length--,e===t)(r=this.first=e.next)&&(r.pre=null);else if((e=this.last)===t){var r;(r=this.last=e.pre)&&(r.next=null)}else if(t){var i=t.pre,n=t.next;i.next=n,n&&(n.pre=i)}t.pre=null,t.next=null},t.prototype.forEach=function(t,e){var r=this.first,i=0;if(r)do{t.call(e||this,r.content,i++)}while(r=r.next)},t.prototype.forEachReverse=function(t,e){var r=this.last,i=this.length-1;if(r)do{t.call(e||this,r.content,i--)}while(r=r.pre)},t}(),jn=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.generate=function(t){var e=Wn(this.arc,this.arcMode,t)*St,r=Math.cos(e)*this.radius,i=Math.sin(e)*this.radius,n=new Mt(r,i,0),o=Math.tan(this.angle*St),s=n.clone().multiply(o);return s.z+=1,{position:n.multiply(Ye(0,1)),direction:s.normalize()}},t}();function Wn(t,e,r){if(e===ct.RANDOM)t=Ye(0,t);else if(e===ct.UNIDIRECTIONAL_CYCLE){var i=r.index%(r.total+1);t=t/r.total*i}else if(e===ct.BIDIRECTIONAL_CYCLE){var n=(i=r.index/(r.total+1))-Math.floor(i);t*=Math.floor(i)%2?1-n:n}else e===ct.UNIFORM_BURST&&(t=t*r.burstIndex/r.burstCount);return t}var Zn,qn=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.generate=function(t){var e=Wn(this.arc,this.arcMode,t)*St,r=new Mt(Math.cos(e),Math.sin(e),0),i=this.radius;return{direction:r,position:r.clone().multiply(i)}},t}(),Kn=function(){function t(t){this._d=(t.width||1)/2,this._h=(t.height||1)/2}return t.prototype.generate=function(t){var e=Ye(-this._d,this._d),r=Ye(-this._h,this._h);return{direction:new Mt(0,0,1),position:new Mt(e,r,0)}},t}(),Qn=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=Wn(this.arc,this.arcMode,t)*St,r=new Mt(Math.cos(e),Math.sin(e),0),i=this._d,n=this._h,o=Math.atan2(n,i),s=Math.tan(e),a=new Mt;return e<o?a.set(i,i*s,0):e>=o&&e<Math.PI-o?a.set(n/s,n,0):e<Math.PI+o?a.set(-i,-i*s,0):e<2*Math.PI-o?a.set(-n/s,-n,0):a.set(i,i*s,0),{direction:r,position:a}},t}(),Jn=function(){function t(t){this._d=t.width||1,this.arcMode=t.arcMode}return t.prototype.generate=function(t){var e=this.arcMode===ct.UNIFORM_BURST?t.burstIndex%t.burstCount/(t.burstCount-1):Ye(0,1);return{direction:new Mt(0,1,0),position:new Mt(this._d*(e-.5),0,0)}},t}(),$n=new Ft,to=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.generate=function(t){var e=this.donutRadius,r=this.radius-e,i=Ye(0,2*Math.PI),n=Wn(this.arc,this.arcMode,t)*St,o=$n.setFromRotationZ(n),s=new Mt(Math.cos(i),Math.sin(i),0),a=new Mt(r+Math.cos(i)*e,0,Math.sin(i)*e);return{direction:o.transformNormal(s),position:o.transformPoint(a)}},t}(),eo=new Ft,ro=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.getHorizontalAngle=function(){return Ye(-90,90)},t.prototype.generate=function(t){var e=Wn(this.arc,this.arcMode,t)*St,r=this.getHorizontalAngle()*St,i=this.radius,n=new Mt(Math.cos(r),0,Math.sin(r)),o=eo.setFromRotationZ(e).transformNormal(n);return{position:o.clone().multiply(i),direction:o}},t}(),io=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getHorizontalAngle=function(){return Ye(0,90)},e}(ro),no=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=Rt(t.random||0,0,1)}return t.prototype.generate=function(t){var e=this.anchors,r=e.length/2-1,i=Math.floor(Wn(r,this.arcMode,t)),n=(e[2*i]+this.block[0]*this.random*Math.random())%1-.5,o=(e[2*i+1]+this.block[1]*this.random*Math.random())%1-.5,s=new Mt(n,o,0);return{position:new Mt(n*this.width,o*this.height,0),direction:s.normalize()}},t}(),oo=function(){function t(){}return t.prototype.generate=function(){return{position:new Mt,direction:new Mt}},t}(),so=((Zn={})[_.NONE]=oo,Zn[_.CONE]=jn,Zn[_.SPHERE]=ro,Zn[_.HEMISPHERE]=io,Zn[_.CIRCLE]=qn,Zn[_.DONUT]=to,Zn[_.RECTANGLE]=Kn,Zn[_.EDGE]=Jn,Zn[_.RECTANGLE_EDGE]=Qn,Zn[_.TEXTURE]=no,Zn);function ao(t){if(!t)return new oo;var e=i({radius:1,arc:360,angle:0,arcMode:ct.RANDOM},t),r=t.type,n=so[r];if(!n)throw Error("invalid shape:"+r);var o=new n(e);if(r!==_.NONE){var s=t,a=s.alignSpeedDirection,u=s.upDirection,l=void 0===u?[0,0,1]:u;o.alignSpeedDirection=a,o.upDirection=Mt.fromArray(l).normalize()}return o}function uo(t,e,r,i,n){var o,s;if(n===function(t,e,r,i){for(var n=0,o=e,s=r-i;o<r;o+=i)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}(t,e,r,i)>0)for(o=e;o<r;o+=i)s=Ro(o,t[o],t[o+1],s);else for(o=r-i;o>=e;o-=i)s=Ro(o,t[o],t[o+1],s);return s&&Eo(s,s.next)&&(Oo(s),s=s.next),s}function lo(t,e){if(!t)return t;e||(e=t);var r,i=t;do{if(r=!1,i.steiner||!Eo(i,i.next)&&0!==To(i.prev,i,i.next))i=i.next;else{if(Oo(i),(i=e=i.prev)===i.next)break;r=!0}}while(r||i!==e);return e}function co(t){var e=t.prev,r=t,i=t.next;if(To(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(go(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&To(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function ho(t,e,r,i){var n=t.prev,o=t,s=t.next;if(To(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,u=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,l=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,h=vo(a,u,e,r,i),f=vo(l,c,e,r,i),p=t.prevZ,d=t.nextZ;p&&p.z>=h&&d&&d.z<=f;){if(p!==t.prev&&p!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&To(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,d!==t.prev&&d!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&To(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&To(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=f;){if(d!==t.prev&&d!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&To(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function fo(t,e){return t.x-e.x}function po(t,e){if(e=function(t,e){var r,i=e,n=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=n&&a>s){if(s=a,a===n){if(o===i.y)return i;if(o===i.next.y)return i.next}r=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!r)return null;if(n===s)return r;var u,l=r,c=r.x,h=r.y,f=1/0;i=r;do{n>=i.x&&i.x>=c&&n!==i.x&&go(o<h?n:s,o,c,h,o<h?s:n,o,i.x,i.y)&&(u=Math.abs(o-i.y)/(n-i.x),_o(i,t)&&(u<f||u===f&&(i.x>r.x||i.x===r.x&&mo(r,i)))&&(r=i,f=u)),i=i.next}while(i!==l);return r}(t,e),e){var r=Co(e,t);lo(e,e.next),lo(r,r.next)}}function mo(t,e){return To(t.prev,t,e.prev)<0&&To(e.next,t,t.next)<0}function vo(t,e,r,i,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function yo(t){var e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next}while(e!==t);return r}function go(t,e,r,i,n,o,s,a){return(n-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(i-a)-(r-s)*(e-a)>=0&&(r-s)*(o-a)-(n-s)*(i-a)>=0}function xo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&So(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(_o(t,e)&&_o(e,t)&&function(t,e){var r=t,i=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==t);return i}(t,e)&&(To(t.prev,t,e.prev)||To(t,e.prev,e))||Eo(t,e)&&To(t.prev,t,t.next)>0&&To(e.prev,e,e.next)>0)}function To(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Eo(t,e){return t.x===e.x&&t.y===e.y}function So(t,e,r,i){var n=Ao(To(t,e,r)),o=Ao(To(t,e,i)),s=Ao(To(r,i,t)),a=Ao(To(r,i,e));return n!==o&&s!==a||(!(0!==n||!bo(t,r,e))||(!(0!==o||!bo(t,i,e))||(!(0!==s||!bo(r,t,i))||!(0!==a||!bo(r,e,i)))))}function bo(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Ao(t){return t>0?1:t<0?-1:0}function _o(t,e){return To(t.prev,t,t.next)<0?To(t,e,t.next)>=0&&To(t,t.prev,e)>=0:To(t,e,t.prev)<0||To(t,t.next,e)<0}function Co(t,e){var r=new wo(t.i,t.x,t.y),i=new wo(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,o.next=i,i.prev=o,i}function Ro(t,e,r,i){var n=new wo(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Oo(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 wo(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Mo=0;function Lo(t,e,r,i){r=r||2,Mo=i||0;var n,o,s,a,u,l,c,h=e&&e.length,f=h?e[0]*r:t.length,p=uo(t,0,f,r,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,r,i){var n,o,s,a=[];for(n=0,o=e.length;n<o;n++)(s=uo(t,e[n]*i,n<o-1?e[n+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(yo(s));for(a.sort(fo),n=0;n<a.length;n++)po(a[n],r),r=lo(r,r.next);return r}(t,e,p,r)),t.length>80*r){n=s=t[0],o=a=t[1];for(var m=r;m<f;m+=r)(u=t[m])<n&&(n=u),(l=t[m+1])<o&&(o=l),u>s&&(s=u),l>a&&(a=l);c=0!==(c=Math.max(s-n,a-o))?1/c:0}return Io(p,d,r,n,o,c),d}function Io(t,e,r,i,n,o,s){if(t){!s&&o&&function(t,e,r,i){var n=t;do{null===n.z&&(n.z=vo(n.x,n.y,e,r,i)),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,r,i,n,o,s,a,u,l=1;do{for(r=t,t=null,o=null,s=0;r;){for(s++,i=r,a=0,e=0;e<l&&(a++,i=i.nextZ);e++);for(u=l;a>0||u>0&&i;)0!==a&&(0===u||!i||r.z<=i.z)?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,u--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;r=i}o.nextZ=null,l*=2}while(s>1)}(n)}(t,i,n,o);for(var a,u,l=t;t.prev!==t.next;)if(a=t.prev,u=t.next,o?ho(t,i,n,o):co(t))e.push(a.i/r+Mo),e.push(t.i/r+Mo),e.push(u.i/r+Mo),Oo(t),t=u.next,l=u.next;else if((t=u)===l){s?1===s?Io(t=Po(lo(t),e,r),e,r,i,n,o,2):2===s&&Fo(t,e,r,i,n,o):Io(lo(t),e,r,i,n,o,1);break}}}function Po(t,e,r){var i=t;do{var n=i.prev,o=i.next.next;!Eo(n,o)&&So(n,i,i.next,o)&&_o(n,o)&&_o(o,n)&&(e.push(n.i/r+Mo),e.push(i.i/r+Mo),e.push(o.i/r+Mo),Oo(i),Oo(i.next),i=t=o),i=i.next}while(i!==t);return lo(i)}function Fo(t,e,r,i,n,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&xo(s,a)){var u=Co(s,a);return s=lo(s,s.next),u=lo(u,u.next),Io(s,e,r,i,n,o),void Io(u,e,r,i,n,o)}a=a.next}s=s.next}while(s!==t)}var No=2;function Vo(t,e){for(var r=t.s,i=t.p,n=r[1],o=i[1],s=0,a=0;a<n.length;a++){s+=(E=n[a]).length-1}var u,c=new Float32Array(s*l),h=e.indexBase,f=void 0===h?0:h,p=e.uvTransform,d=0,m=0,v=0,y=1,g=1;p&&(m=p[0],v=p[1],u=p[4],y=u?p[3]:p[2],g=u?p[2]:p[3]);var x=[0,0],T=0===u?0:-Math.PI/2;for(a=0;a<n.length;a++)for(var E=n[a],S=o[a],b=o[a+1]||o[0],A=E,_=[0,0],C=0;C<A.length-1;C++){Bo(_,A[C],S,b,S[4],S[5],b[2],b[3]),O(_[0],_[1])}var R=Lo(Array.from(c),null,l,f);return{aPoint:c,index:new Uint16Array(R)};function O(t,e){c[d++]=t/2,c[d++]=e/2,p?(x[0]=t,x[1]=e,zo(x,x,T),c[d++]=m+(x[0]+1)/2*y,c[d++]=v+(x[1]+1)/2*g):(c[d++]=(t+1)/2,c[d++]=(e+1)/2),d+=No}}function Do(t,e){for(var r=[],i=function(t){var e=[];return t.gs?t.gs.forEach((function(t){e.push({p:[ot.SHAPE_POINTS,t.p],s:[ot.SHAPE_SPLITS,t.s]})})):t.g?e.push({p:[ot.SHAPE_POINTS,t.g.p],s:[ot.SHAPE_SPLITS,t.g.s]}):e.push(t),e}(t),n=0,o=0,s=0,a=0;a<i.length;a++){n+=(f=Vo(i[a],{indexBase:n,uvTransform:e})).aPoint.length/5,r.push(f),o+=f.aPoint.length,s+=f.index.length}if(1===r.length)return r[0];for(var u=new Float32Array(o),l=new Uint16Array(s),c=(a=0,0),h=0;a<r[a];a++){var f=r[a];u.set(f.aPoint,c),c+=f.aPoint.length,l.set(f.index,h),h+=f.index.length}return{aPoint:u,index:l}}function zo(t,e,r){var i=Math.cos(r),n=Math.sin(r),o=e[0],s=e[1];return t[0]=i*o+n*s,t[1]=-n*o+i*s,t}function Bo(t,e,r,i,n,o,s,a){var u=1-e,l=u*u*u,c=3*e*u*u,h=3*e*e*u,f=e*e*e;return t[0]=l*r[0]+c*n+h*s+f*i[0],t[1]=l*r[1]+c*o+h*a+f*i[1],t}var Uo=function(){function t(t){var e=t.time,r=t.interval,i=t.count,n=t.cycles,o=t.probability;this.time=+e||0,this.interval=+r||1,this.count=i instanceof he?i:be(i),this.cycles=+n||1/0,this.probability=isNaN(o)?1:+o,this.reset()}return t.prototype.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},t.prototype.reset=function(){this.internalCycles=this.cycles,this.index=0,this.now=0},t.prototype.clone=function(){return new t(this)},t}(),ko=new Mt,Go=new Mt,Xo=function(){function e(e,r){var i;this.pointStart=[];var n=e.colorOverLifetime,o=e.colorOverTrail,s=e.maxTrailCount,a=e.opacityOverLifetime,u=void 0===a?be(1):a,l=e.widthOverTrail,h=e.name,f=e.occlusion,p=e.blending,d=e.maskMode,m=e.order,y=e.textureMap,g=void 0===y?[0,0,1,1]:y,x=e.texture,T=e.transparentOcclusion,E=e.minimumVertexDistance,S=e.lifetime,b=e.matrix,A=r.gpuCapability,_=A.detail,C=A.level,R=Math.max(e.pointCountPerTrail,2),O={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},w=_.maxVertexTextures>0,M=(null!==(i=r.renderer)&&void 0!==i?i:{}).env,L={},I=[["ENABLE_VERTEX_TEXTURE",w],["LOOKUP_TEXTURE_CURVE",0],["ENV_EDITOR",M===c]],P=s>64,F=0;n&&(I.push(["COLOR_OVER_LIFETIME",!0]),F|=1,L.uColorOverLifetime=Vr.createWithData(r,Q(n))),o&&(I.push(["COLOR_OVER_TRAIL",!0]),F|=4,L.uColorOverTrail=Vr.createWithData(r,Q(o))),P?(I.push(["ATTR_TRAIL_START",1]),F|=8):L.uTrailStart=new Float32Array(s),L.uOpacityOverLifetimeValue=u.toUniform(O);var N=l.toUniform(O);I.push(["VERT_CURVE_VALUE_COUNT",O.index],["VERT_MAX_KEY_FRAME_COUNT",O.max]),L.uVCurveValues=ge.getAllData(O);var V={shader:{vertex:br(I,wi,t.ShaderType.vertex,C),fragment:br(I,Ri,t.ShaderType.fragment,C),marcos:I,glslVersion:1===C?t.GLSLVersion.GLSL1:t.GLSLVersion.GLSL3,shared:!0,name:"trail#".concat(h),cacheId:"-t:+".concat(F,"+").concat(O.index,"+").concat(O.max)},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},D=R*s*2,z=(R-1)*s,B=Float32Array.BYTES_PER_ELEMENT,U=12*B,k={attributes:{aColor:{size:4,stride:U,data:new Float32Array(12*D)},aSeed:{size:1,stride:U,offset:4*B,dataSource:"aColor"},aInfo:{size:3,stride:U,offset:5*B,dataSource:"aColor"},aPos:{size:4,stride:U,offset:8*B,dataSource:"aColor"},aTime:{size:1,data:new Float32Array(D)},aDir:{size:3,data:new Float32Array(3*D)}},indices:{data:new Uint16Array(6*D)},drawCount:6*z,name:"trail#".concat(h),bufferUsage:v.DYNAMIC_DRAW};if(P)k.attributes.aTrailStart={size:1,data:new Float32Array(D)};else{var G=new Float32Array(D);k.attributes.aTrailStartIndex={size:1,data:G};for(var X=0;X<s;X++)for(var H=2*R,Y=X*H,j=0;j<H;j++)G[Y+j]=X}var W=xr(p),Z=qr.create(r,V);Z.blending=!0,Z.depthMask=f,Z.depthTest=!0,Cr(Z,d),Ar(Z,p);var q=this.mesh=gi.create(r,{name:"MTrail_".concat(h),material:Z,geometry:li.create(r,k),priority:m}),K=null!=x?x:Vr.createWithData(r);Object.keys(L).map((function(t){var e=L[t];if(e instanceof Vr)Z.setTexture(t,e);else if("uTrailStart"===t)Z.setFloats("uTrailStart",e);else if("uVCurveValues"===t){var r=[];r.push(new zt(e[0],e[1],e[2],e[3])),r.push(new zt(e[4],e[5],e[6],e[7])),Z.setVector4Array(t,r)}else Z.setVector4(t,zt.fromArray(e))})),Z.setFloat("uTime",0),Z.setVector4("uWidthOverTrail",zt.fromArray(N)),Z.setVector2("uTexOffset",new wt(0,0)),Z.setVector4("uTextureMap",zt.fromArray(g)),Z.setVector4("uParams",new zt(0,R-1,0,0)),Z.setTexture("uMaskTex",K),Z.setVector4("uColorParams",new zt(x?1:0,+W,0,+(f&&!T))),this.maxTrailCount=s,this.pointCountPerTrail=R,this.checkVertexDistance=E>0,this.minimumVertexDistance=Math.pow(E||.001,2),this.useAttributeTrailStart=P,this.lifetime=S,b&&(this.mesh.worldMatrix=b),this.geometry=q.firstGeometry(),this.trailCursors=new Uint16Array(s)}return Object.defineProperty(e.prototype,"time",{get:function(){return this.mesh.material.getFloat("uTime")||0},set:function(t){this.mesh.material.setFloat("uTime",null!=t?t:0)},enumerable:!1,configurable:!0}),e.prototype.addPoint=function(t,e,r){r=r||{};var i=this.trailCursors[t],n=this.pointCountPerTrail,o=this.geometry,s=n-1,a=i%n,u=(i-1)%n,l=(i-2)%n,c=this.getTrailPosition(t,u,ko);if(!(c&&this.checkVertexDistance&&(null==c?void 0:c.distanceSquared(e))<this.minimumVertexDistance)){var h=t*n+a,f=Wo(c,e),p=r.time||this.time,d=[Math.random(),r.lifetime||this.lifetime,i],m=r.size||1,v=6*h,y=new Float32Array(6);y.set(f,0),y.set(f,3),o.setAttributeSubData("aDir",v,y),o.setAttributeSubData("aTime",2*h,new Float32Array([p,p]));var g=r.color||[1,1,1,1],x=new Float32Array(24),T=e.toArray();if(x.set(g,0),x.set(d,4),x[7]=0,x.set(T,8),x[11]=.5*m,x.set(g,12),x.set(d,16),x[19]=1,x.set(T,20),x[23]=-.5*m,o.setAttributeSubData("aColor",24*h,x),u>=0){var E=this.getTrailPosition(t,l,Go),S=new Float32Array(Wo(E,c,e)),b=6*(t*n+u);o.setAttributeSubData("aDir",b,S),o.setAttributeSubData("aDir",b+3,S);var A=t*n*2,_=new Uint16Array([2*u+A,2*u+1+A,2*a+A,2*a+A,2*u+1+A,2*a+1+A]),C=6*(t*s+(i-1)%s);o.setIndexSubData(C,_)}i=++this.trailCursors[t];var R=this.mesh.material,O=R.getVector4("uParams"),w=d[2];if(this.useAttributeTrailStart){for(var M=2*n,L=new Float32Array(M),I=0;I<M;I++)L[I]=w;o.setAttributeSubData("aTrailStart",t*L.length,L)}else{var P=R.getFloats("uTrailStart");null!=P&&(P[t]=w,R.setFloats("uTrailStart",P))}O&&(O.y=Math.max(O.y,i-1)-Math.max(0,i-n),R.setVector4("uParams",O))}},e.prototype.getTrailPosition=function(t,e,r){var i=this.pointCountPerTrail;if(e>=0&&e<i){var n=24*(t*i+e)+8,o=this.geometry.getAttributeData("aColor");return r.x=o[n],r.y=o[1+n],r.z=o[2+n],r}},e.prototype.clearAllTrails=function(){var t=this.geometry;this.trailCursors=new Uint16Array(this.trailCursors.length),t.setIndexData(new Uint16Array(t.getIndexData().length))},e.prototype.minusTime=function(t){for(var e=this.geometry.getAttributeData("aTime"),r=0;r<e.length;r++)e[r]-=t;this.geometry.setAttributeData("aTime",e),this.time-=t},e.prototype.clearTrail=function(t){if(0!==this.trailCursors[t]){var e=6*(this.pointCountPerTrail-1),r=this.geometry.getIndexData();null==r||r.set(new Uint16Array(e),t*e),this.geometry.setIndexData(r),this.trailCursors[t]=0}},e.prototype.getPointStartPos=function(t){return this.pointStart[t]},e.prototype.setPointStartPos=function(t,e){this.pointStart[t]=e},e.prototype.onUpdate=function(t){},e}(),Ho=new Mt,Yo=new Mt,jo=new Mt;function Wo(t,e,r){var i=Ho;return t||r?(t?r?(Yo.subtractVectors(e,t).normalize(),Yo.subtractVectors(r,e),jo.copyFrom(Yo).normalize(),i.addVectors(Yo,jo)):i.subtractVectors(e,t):i.subtractVectors(r,e),i.normalize().toArray()):[0,0,0]}var Zo=function(){function t(t,e,r){var i,n,o,s,a,u,l=r.composition,c=r.endBehavior,h=r.name;if(l){var f,p=l.getEngine(),d=e.cachePrefix,m=void 0===d?"":d,v=t.options,y=t.positionOverLifetime,g=t.shape,x=r.duration||1,T=y.gravityOverLifetime,E=$t(y.gravity),_=t.textureSheetAnimation,C=_?{animationDelay:be(_.animationDelay||0),animationDuration:be(_.animationDuration||1),cycles:be(_.cycles||1),animate:_.animate,col:_.col,row:_.row,total:_.total||_.col*_.row}:void 0,R=Ft.fromIdentity(),O=!!(g&&g.turbulenceX||g.turbulenceY||g.turbulenceZ);O&&(f=[be(null!==(i=g.turbulenceX)&&void 0!==i?i:0),be(null!==(n=g.turbulenceY)&&void 0!==n?n:0),be(null!==(o=g.turbulenceZ)&&void 0!==o?o:0)]),this.name=h,this.shape=ao(g),this.emission={rateOverTime:be(t.emission.rateOverTime),burstOffsets:ns(null!==(s=t.emission.burstOffsets)&&void 0!==s?s:[]),bursts:(t.emission.bursts||[]).map((function(t){return new Uo(t)}))},this.textureSheetAnimation=C;var w,L=t.renderer||{},I={},P=t.rotationOverLifetime;P&&(I.asRotation=!!P.asRotation,I.z=P.z?be(P.z):be(0),P.separateAxes&&(I.x=P.x&&be(P.x),I.y=P.y&&be(P.y))),y.forceTarget&&(w={target:y.target||[0,0,0],curve:be(y.forceCurve||[ot.LINE,[[0,0],[1,1]]])});var F={x:y.linearX&&be(y.linearX||0),y:y.linearY&&be(y.linearY||0),z:y.linearZ&&be(y.linearZ||0),asMovement:y.asMovement},N={x:y.orbitalX&&be(y.orbitalX),y:y.orbitalY&&be(y.orbitalY),z:y.orbitalZ&&be(y.orbitalZ),center:y.orbCenter,asRotation:y.asRotation},V=t.sizeOverLifetime||{},D=t.colorOverLifetime,z=r.listIndex,B=m,U=(null==V?void 0:V.separateAxes)?{separateAxes:!0,x:be(V.x),y:be(V.y)}:{separateAxes:!1,x:be(("size"in V?V.size:V.x)||1)},k=wt.fromArray(se(L.anchor,L.particleOrigin));this.options={particleFollowParent:!!v.particleFollowParent,startLifetime:be(v.startLifetime),startDelay:be(v.startDelay||0),startSpeed:be(y.startSpeed||0),startColor:be(v.startColor),endBehavior:c,duration:x,looping:c===at.loop,maxCount:null!==(a=v.maxCount)&&void 0!==a?a:0,gravityModifier:be(T||0).scaleXCoord(x),gravity:E,start3DSize:!!v.start3DSize,startTurbulence:O,turbulence:f,speedOverLifetime:y.speedOverLifetime&&be(y.speedOverLifetime),linearVelOverLifetime:F,orbitalVelOverLifetime:N,forceTarget:w},v.startRotationZ&&(this.options.startRotation=be(v.startRotationZ||0)),(v.startRotationX||v.startRotationY)&&(this.options.start3DRotation=!0,this.options.startRotationX=be(v.startRotationX||0),this.options.startRotationY=be(v.startRotationY||0),this.options.startRotationZ=be(v.startRotationZ||0)),v.start3DSize?(this.options.startSizeX=be(v.startSizeX),this.options.startSizeY=be(v.startSizeY)):(this.options.startSize=be(v.startSize),this.options.sizeAspect=be(v.sizeAspect||1));var G={listIndex:z,meshSlots:v.meshSlots,name:h,matrix:R,filter:t.filter,shaderCachePrefix:B,renderMode:L.renderMode||M.BILLBOARD,side:L.side||b.DOUBLE,gravity:E,duration:r.duration,blending:L.blending||S.ALPHA,rotationOverLifetime:I,gravityModifier:this.options.gravityModifier,linearVelOverLifetime:this.options.linearVelOverLifetime,orbitalVelOverLifetime:this.options.orbitalVelOverLifetime,speedOverLifetime:this.options.speedOverLifetime,sprite:C,occlusion:!!L.occlusion,transparentOcclusion:!!L.transparentOcclusion,maxCount:v.maxCount,mask:L.mask,maskMode:null!==(u=L.maskMode)&&void 0!==u?u:A.NONE,forceTarget:w,diffuse:L.texture,sizeOverLifetime:U,anchor:k};if(D){var X=D.color,H=D.opacity;G.colorOverLifetime={},H&&(G.colorOverLifetime.opacity=be(D.opacity)),X&&(X[0]===ot.GRADIENT_COLOR?G.colorOverLifetime.color=D.color[1]:X[0]===ot.RGBA_COLOR?G.colorOverLifetime.color=Vr.createWithData(p,{data:new Uint8Array(X[1]),width:1,height:1}):X instanceof Vr&&(G.colorOverLifetime.color=X))}var Y,j=[],W=[0,0,1,1];if(t.splits){var Z=t.splits[0];W=(Y=Z[4])?[Z[0],Z[1],Z[3],Z[2]]:[Z[0],Z[1],Z[2],Z[3]]}if(C&&!C.animate)for(var q=Y?C.row:C.col,K=Y?C.col:C.row,Q=C.total||q*K,J=0,$=0;$<q;$++)for(var tt=0;tt<K&&J<Q;tt++,J++)j.push([$*W[2]/q+W[0],tt*W[3]/K+W[1],W[2]/q,W[3]/K]);else j.push(W);G.textureFlip=Y,this.uvs=j,this.particleMesh=new Bn(G,{composition:l});var et=t.trails;if(et){this.trails={lifetime:be(et.lifetime),dieWithParticles:!1!==et.dieWithParticles,sizeAffectsWidth:!!et.sizeAffectsWidth,sizeAffectsLifetime:!!et.sizeAffectsLifetime,inheritParticleColor:!!et.inheritParticleColor,parentAffectsPosition:!!et.parentAffectsPosition};var rt={name:r.name+"_trail",matrix:R,minimumVertexDistance:et.minimumVertexDistance||.02,maxTrailCount:v.maxCount,pointCountPerTrail:Math.round(et.maxPointPerTrail)||32,blending:et.blending,texture:et.texture,opacityOverLifetime:be(et.opacityOverLifetime||1),widthOverTrail:be(et.widthOverTrail||1),order:z+(et.orderOffset||0),shaderCachePrefix:B,lifetime:this.trails.lifetime,occlusion:!!et.occlusion,transparentOcclusion:!!et.transparentOcclusion,textureMap:et.textureMap,mask:L.mask,maskMode:L.maskMode};et.colorOverLifetime&&et.colorOverLifetime[0]===ot.GRADIENT_COLOR&&(rt.colorOverLifetime=et.colorOverLifetime[1]),et.colorOverTrail&&et.colorOverTrail[0]===ot.GRADIENT_COLOR&&(rt.colorOverTrail=et.colorOverTrail[1]),this.trailMesh=new Xo(rt,p)}this.transform=r.transform;var it,nt=this.transform.position.clone(),st=this.transform.rotation.clone(),ut=t.emitterTransform&&t.emitterTransform.path;ut&&(ut[0]===ot.CONSTANT_VEC3?nt.add(ut[1]):it=be(ut)),this.basicTransform={position:nt,rotation:st,path:it},this.updateEmitterTransform(0);var lt=[this.particleMesh.mesh];this.trailMesh&<.push(this.trailMesh.mesh),this.meshes=lt,this.reusable=r.reusable,this.setVisible(r.contentVisible);var ct=t.interaction;ct&&(this.interaction={multiple:ct.multiple,radius:ct.radius,behavior:ct.behavior})}}return Object.defineProperty(t.prototype,"timePassed",{get:function(){return this.lastUpdate-this.loopStartTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lifetime",{get:function(){return this.timePassed/this.options.duration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"particleCount",{get:function(){return this.particleLink.length},enumerable:!1,configurable:!0}),t.prototype.updateEmitterTransform=function(t){var e=this.transform.parentTransform,r=this.basicTransform,i=r.path,n=r.position.clone();if(i){var o=this.options.duration;n.add(i.getValue(t/o))}if(this.transform.setPosition(n.x,n.y,n.z),this.options.particleFollowParent&&e){var s=e.getWorldMatrix();this.particleMesh.mesh.worldMatrix=s,this.trailMesh&&(this.trailMesh.mesh.worldMatrix=s)}},t.prototype.addParticle=function(t,e){var r,i=this.particleLink,n=[t.delay+t.lifetime,0,t.delay,t];if(i.length<e)r=n[1]=i.length;else{var o=i.first;i.removeNode(o),r=n[1]=o.content[1]}i.pushNode(n),this.particleMesh.setPoint(t,r),this.clearPointTrail(r),this.trailMesh&&this.trailMesh.setPointStartPos(r,this.transform.parentTransform.position.clone())},t.prototype.setVisible=function(t){this.particleMesh.mesh.setVisible(t),this.trailMesh&&this.trailMesh.mesh.setVisible(t)},t.prototype.setOpacity=function(t){var e,r=this.particleMesh.mesh.material,i=this.particleMesh.mesh.geometry,n=(null===(e=r.getVector4("uOpacityOverLifetimeValue"))||void 0===e?void 0:e.toArray())||[1,1,1,1];r.setVector4("uOpacityOverLifetimeValue",new zt(n[0],n[1],n[2],t));for(var o=i.getAttributeData("aColor")||[],s=0;s<o.length;s+=32)o[8*s+7]=t},t.prototype.setColor=function(t,e,r,i){var n,o=this.particleMesh.mesh.material,s=this.particleMesh.mesh.geometry,a=(null===(n=o.getVector4("uOpacityOverLifetimeValue"))||void 0===n?void 0:n.toArray())||[1,1,1,1];o.setVector4("uOpacityOverLifetimeValue",new zt(a[0],a[1],a[2],i));for(var u=s.getAttributeData("aColor")||[],l=0;l<u.length;l+=32)u[8*l+4]=t,u[8*l+5]=e,u[8*l+6]=r,u[8*l+7]=i},t.prototype.setParentTransform=function(t){},t.prototype.getTextures=function(){var t=[],e=this.particleMesh.mesh.material.textures;if(Object.keys(e).forEach((function(r){t.push(e[r])})),this.trailMesh){var r=this.trailMesh.mesh.material.textures;Object.keys(r).forEach((function(e){t.push(r[e])}))}return t},t.prototype.start=function(){this.started&&!this.ended||(this.reset(),this.started=!0,this.ended=!1)},t.prototype.stop=function(){this.ended=!0,this.started=!1},t.prototype.reset=function(){var t;this.particleMesh.clearPoints(),null===(t=this.trailMesh)||void 0===t||t.clearAllTrails(),this.lastUpdate=0,this.loopStartTime=0,this.lastEmitTime=-1/this.emission.rateOverTime.getValue(0),this.generatedCount=0,this.particleLink=new Yn((function(t,e){return t[0]-e[0]})),this.emission.bursts.forEach((function(t){return t.reset()})),this.frozen=!1},t.prototype.onUpdate=function(t){var e,r=this;if(this.started&&!this.frozen){var i=this.lastUpdate+t/1e3,n=this.particleMesh,o=this.trailMesh,s=this.options,l=this.loopStartTime,c=this.emission;this.lastUpdate=i,this.upDirectionWorld=null,n.time=i,o&&(o.time=i,o.onUpdate(t));var h=this.particleLink,f=(i-l)/s.duration,p=this.timePassed,d=!1,m=function(){r.trails&&!d&&(d=!0,h.forEach((function(t){var e=a(t,4),i=e[0],n=e[1],o=e[2],s=e[3];i<p?r.clearPointTrail(n):p>o&&r.updatePointTrail(n,f,s,o)})))};if(this.ended){if(!s.looping)if(this.reusable);else if(0===s.endBehavior){var v=h.last;v&&v.content[0]-l<p&&(this.onUpdate=function(){return r.onDestroy()})}}else{var y=s.duration,g=this.lifetime;if(p<y){var x=1/c.rateOverTime.getValue(g),T=Math.floor((p-this.lastEmitTime)/x),E=T,S=x/T,b=i,A=s.maxCount;this.updateEmitterTransform(p);for(var _=function(){var t=h.first;return r.emissionStopped||h.length===A&&t&&t.content[0]-l>p},C=0;C<E&&C<A&&!_();C++){(F=this.createPoint(g)).delay+=b+C*S,this.addParticle(F,A),this.lastEmitTime=p}for(var R=c.bursts,O=(null==R?void 0:R.length)-1,w=0;O>=0&&w<A&&!_();O--){var M=R[O],L=!M.disabled&&M.getGeneratorOptions(p,g);if(L){var I=c.burstOffsets[O],P=I&&I[L.cycleIndex]||[0,0,0];M.once&&this.removeBurst(O);for(C=0;C<L.count&&w<A&&!_();C++){var F;(F=this.initPoint(this.shape.generate({total:L.total,index:L.index,burstIndex:C,burstCount:L.count}))).delay+=b,w++,(e=F.transform).translate.apply(e,u([],a(P),!1)),this.addParticle(F,A)}}}}else if(s.looping)m(),this.loopStartTime=i-y,this.lastEmitTime-=y,this.lastUpdate-=y,c.bursts.forEach((function(t){return t.reset()})),this.particleLink.forEach((function(t){t[0]-=y,t[2]-=y,t[3].delay-=y})),n.minusTime(y),o&&o.minusTime(y),this.onIterate(this);else{this.ended=!0,this.onEnd(this),4===s.endBehavior&&(this.frozen=!0)}}m()}},t.prototype.onDestroy=function(){},t.prototype.getParticleBoxes=function(){var t=this.particleLink,e=this.particleMesh,r=[],i=this.particleCount,n=0;if(!t||!e)return r;for(var o=t.last,s=!1;!s;){var a=o.content[0],u=o.content[3];if(a>this.timePassed){var l=this.getPointPosition(u);r.push({center:l,size:u.transform.scale}),o.pre?o=o.pre:s=!0}++n>i&&(s=!0)}return r},t.prototype.raycast=function(t){var e=this.particleLink,r=this.particleMesh;if(e&&r){var i=e.last,n=[],o=new Mt,s=!1;if(i&&i.content)do{var u=a(i.content,4),l=u[0],c=u[1];u[2];var h=u[3];if(!(l>this.timePassed))break;var f=this.getPointPosition(h),p=t.ray,d=!1;p&&(d=!!p.intersectSphere({center:f,radius:t.radius},o)),d&&(t.removeParticle&&(r.removePoint(c),this.clearPointTrail(c),i.content[0]=0),n.push(f),t.multiple||(s=!0))}while((i=i.pre)&&!s);return n}},t.prototype.clearPointTrail=function(t){var e;this.trails&&this.trails.dieWithParticles&&(null===(e=this.trailMesh)||void 0===e||e.clearTrail(t))},t.prototype.updatePointTrail=function(t,e,r,i){if(this.trailMesh){var n=this.trails,o=this.particleMesh,s=this.getPointPosition(r),a=n.inheritParticleColor?o.getPointColor(t):[1,1,1,1],u=r.transform.getWorldScale().toArray(),l=1,c=n.lifetime.getValue(e);if(n.sizeAffectsWidth&&(l*=u[0]),n.sizeAffectsLifetime&&(c*=u[0]),n.parentAffectsPosition&&this.transform.parentTransform){s.add(this.transform.parentTransform.position);var h=this.trailMesh.getPointStartPos(t);h&&s.subtract(h)}this.trailMesh.addPoint(t,s,{color:a,lifetime:c,size:l,time:i})}},t.prototype.getPointPosition=function(t){var e=t.transform,r=t.vel,i=t.lifetime,n=t.delay,o=t.gravity,s=void 0===o?[]:o,a=this.options.forceTarget,u=this.lastUpdate-n,l=new Mt,c=Mt.fromArray(s);e.assignWorldTRS(l);var h=Jt(new Mt,this.options,c,u,i,l,r);if(a){var f=a.target||[0,0,0],p=a.curve.getValue(u/i),d=1-p;h.x=h.x*d+f[0]*p,h.y=h.y*d+f[1]*p,h.z=h.z*d+f[2]*p}return h},t.prototype.onEnd=function(t){},t.prototype.onIterate=function(t){},t.prototype.initPoint=function(t){var e=this.options,r=this.lifetime,i=this.shape,n=e.startSpeed.getValue(r),o=e.particleFollowParent?this.transform.getMatrix():this.transform.getWorldMatrix(),s=o.transformPoint(t.position,new Mt),a=new Ke({position:s,valid:!0}),u=t.direction;if(u=o.transformNormal(u,qo).normalize(),e.startTurbulence&&e.turbulence){for(var l=0;l<3;l++)ts.setElement(l,e.turbulence[l].getValue(r));es.setFromVector3(ts.negate()),is.setFromEuler(es).transformNormal(u).normalize()}var c,h=Jo,f=$o;i.alignSpeedDirection?(f.copyFrom(u),this.upDirectionWorld||(i.upDirection?this.upDirectionWorld=i.upDirection.clone():this.upDirectionWorld=Mt.Z.clone(),o.transformNormal(this.upDirectionWorld)),h.crossVectors(f,this.upDirectionWorld).normalize(),h.isZero()&&h.set(1,0,0)):(h.set(1,0,0),f.set(0,1,0));var p=this.textureSheetAnimation;p&&p.animate&&((c=rs)[0]=p.animationDelay.getValue(r),c[1]=p.animationDuration.getValue(r),c[2]=p.cycles.getValue(r));var d=Qo;e.start3DRotation?d.set(e.startRotationX.getValue(r),e.startRotationY.getValue(r),e.startRotationZ.getValue(r)):e.startRotation?d.set(0,0,e.startRotation.getValue(r)):d.set(0,0,0),a.setRotation(d.x,d.y,d.z);var m=e.startColor.getValue(r);3===m.length&&(m[3]=1);var v=Ko;if(e.start3DSize)v.x=e.startSizeX.getValue(r),v.y=e.startSizeY.getValue(r);else{var y=e.startSize.getValue(r),g=e.sizeAspect.getValue(r);v.x=y,v.y=0===g?0:y/g}var x=u.clone();if(x.multiply(n),!e.particleFollowParent){var T=new Mt;this.transform.assignWorldTRS(void 0,void 0,T),v.x*=T.x,v.y*=T.y}return a.setScale(v.x,v.y,1),{size:v,vel:x,color:m,delay:e.startDelay.getValue(r),lifetime:e.startLifetime.getValue(r),uv:os(this.uvs,!0),gravity:e.gravity,sprite:c,dirY:f,dirX:h,transform:a}},t.prototype.addBurst=function(t,e){var r=!1;if(this.emission.bursts.includes(t)||(this.emission.bursts.push(t),r=!0),r&&e instanceof Array){var i=this.emission.bursts.indexOf(t);return this.emission.burstOffsets[i]=e,i}return-1},t.prototype.removeBurst=function(t){t<this.emission.bursts.length&&(this.emission.burstOffsets[t]=null,this.emission.bursts.splice(t,1))},t.prototype.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))},t}(),qo=new Mt,Ko=new wt,Qo=new Dt,Jo=new Mt,$o=new Mt,ts=new Mt,es=new Dt,rs=[0,0,0],is=new Ft;function ns(t){var e={};return Array.isArray(t)&&t.forEach((function(t){var r=t instanceof Array,i=r?t[0]:t.index,n=e[i];n||(n=e[i]=[]),r?n.push(t.slice(1,4)):n.push([+t.x,+t.y,+t.z])})),e}function os(t,e){var r=Math.floor(Math.random()*t.length),i=t[r];return e||t.splice(r,1),i}var ss=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.destroyed=!1,t}return r(i,e),Object.defineProperty(i.prototype,"type",{get:function(){return w.particle},enumerable:!1,configurable:!0}),i.prototype.onConstructed=function(t){this.particle=t.content},i.prototype.onLifetimeBegin=function(t,e){var r=this;return e&&(e.name=this.name,e.start(),e.onDestroy=function(){r.destroyed=!0}),e},i.prototype.onItemUpdate=function(t,e){var r;if(this.content){var i=!this.visible,n=this.parentId&&(null===(r=this.composition)||void 0===r?void 0:r.getItemByID(this.parentId));if(!i&&n){var o=n.getRenderData();o&&(o.visible||(i=!1))}i?this.content.setVisible(!1):(this.content.setVisible(!0),this.content.onUpdate(t))}},i.prototype.onItemRemoved=function(e,r){r&&(e.destroyTextures(r.getTextures()),r.meshes.forEach((function(e){return e.dispose({material:{textures:t.DestroyOptions.keep}})})))},i.prototype.setColor=function(t,e,r,i){this.content.setColor(t,e,r,i)},i.prototype.setOpacity=function(t){this.content.setOpacity(t)},i.prototype.stopParticleEmission=function(){this.content&&(this.content.emissionStopped=!0)},i.prototype.resumeParticleEmission=function(){this.content&&(this.content.emissionStopped=!1)},i.prototype.doCreateContent=function(t){return rt(this.particle),new Zo(this.particle,t.getRendererOptions(),this)},i.prototype.isEnded=function(t){return e.prototype.isEnded.call(this,t)&&this.destroyed},i.prototype.getBoundingBox=function(){var e=this.content;if(e){var r=e.getParticleBoxes();return{type:t.HitTestType.sphere,area:r}}},i.prototype.getHitTestParams=function(e){var r,i=this,n=null===(r=this.content)||void 0===r?void 0:r.interaction;if(e||n)return{type:t.HitTestType.custom,collect:function(t){var e;return null===(e=i.content)||void 0===e?void 0:e.raycast({radius:(null==n?void 0:n.radius)||.4,multiple:!!(null==n?void 0:n.multiple),removeParticle:(null==n?void 0:n.behavior)===lt.removeParticle,ray:t})}}},i}(Qe),as=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[],t}return r(i,e),i.precompile=function(e,r,i){var n=e[0],o={rotationOverLifetime:{x:!1,y:!1,z:!1},positionOverLifetime:{speedOverLifetime:!1,linearX:!1,linearY:!1,linearZ:!1,orbitalX:!1,orbitalY:!1,orbitalZ:!1,forceCurve:!1},colorOverLifetime:{opacity:!1,color:!1},sizeOverLifetime:{x:!1,y:!1}},s={colorOverLifetime:{opacity:1,color:[ot.RGBA_COLOR,[255,255,255,255]]},positionOverLifetime:{speedOverLifetime:1},sizeOverLifetime:{x:1,y:1}},a=r.engine.gpuCapability,u=a.level,l=(null!=i?i:{}).env,h=r.getShaderLibrary(),f=[],p=[],d=[],m=0,v=0;return n.items.forEach((function(e){t.Item.isParticle(e)&&(p.push(e),function(e){if(t.Item.isParticle(e)){var r=e.content;r.rotationOverLifetime||(r.rotationOverLifetime={});var i=r.rotationOverLifetime;i.z||(i.z=[ot.CONSTANT,0]),i.separateAxes||(delete i.y,delete i.x),r.sizeOverLifetime||(r.sizeOverLifetime={});var n=r.sizeOverLifetime;n.separateAxes||delete n.y,n.size&&(n.x=n.size,delete n.size),n.x||(n.x=[ot.CONSTANT,1])}}(e),2===u&&Object.keys(o).forEach((function(t){var r=o[t],i=e.content[t];i&&Object.keys(r).forEach((function(e){i[e]&&(r[e]=!0,z(f,t))}))})))})),p.forEach((function(e){var r,i,n=e.content;2===u&&(f.forEach((function(t){var e=o[t],r=n[t]||(n[t]={});Object.keys(e).forEach((function(i){if(e[i]&&!r[i]){var n=s[t]&&s[t][i]||0;r[i]=isNaN(n)?n:[ot.CONSTANT,n]}}))})),o.positionOverLifetime.forceCurve&&(n.positionOverLifetime.forceTarget=!0),(o.rotationOverLifetime.x||o.rotationOverLifetime.y)&&(n.rotationOverLifetime.separateAxes=!0),o.sizeOverLifetime.y&&(n.sizeOverLifetime.separateAxes=!0));var p=Gn(e,l,a),y=p.shader,g=p.fragment,x=p.vertex;if(d.push(y),m=Math.max(m,g),v=Math.max(v,x),e.content.trails){var T=function(t,e,r,i,n){void 0===i&&(i="");var o=0,s=di(hi)?1:0,a=[["ENABLE_VERTEX_TEXTURE",n.detail.maxVertexTextures>0],["LOOKUP_TEXTURE_CURVE",s],["ENV_EDITOR",i===c]],u={curves:[],index:0,max:0,lineSegCount:0,curveCount:0};return t.colorOverLifetime&&(a.push(["COLOR_OVER_LIFETIME",!0]),o|=1),t.colorOverTrail&&(a.push(["COLOR_OVER_TRAIL",!0]),o|=4),e>64&&(a.push(["ATTR_TRAIL_START",1]),o|=8),we(u,t.opacityOverLifetime),we(u,t.widthOverTrail),a.push(["VERT_CURVE_VALUE_COUNT",u.index],["VERT_MAX_KEY_FRAME_COUNT",u.max]),{vertex:wi,fragment:Ri,marcos:a,shared:!0,name:"trail#"+r,cacheId:"-t:+".concat(o,"+").concat(u.index,"+").concat(u.max)}}(e.content.trails,e.content.options.maxCount,e.name,l,a);T.vertex=br(null!==(r=T.marcos)&&void 0!==r?r:[],T.vertex,t.ShaderType.vertex,u),T.fragment=br(null!==(i=T.marcos)&&void 0!==i?i:[],T.fragment,t.ShaderType.fragment,u),T.glslVersion=2===u?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1,h.addShader(T)}})),d.forEach((function(e){var r,i;2===u?(Xn(e,v,m),e.glslVersion=t.GLSLVersion.GLSL3):e.glslVersion=t.GLSLVersion.GLSL1,e.vertex=br(null!==(r=e.marcos)&&void 0!==r?r:[],e.vertex,t.ShaderType.vertex,u),e.fragment=br(null!==(i=e.marcos)&&void 0!==i?i:[],e.fragment,t.ShaderType.fragment,u),h.addShader(e)})),2===u&&p.forEach((function(t){t.content.options.meshSlots=[v,m]})),Promise.resolve()},i.prototype.onCompositionItemLifeBegin=function(t,e){e instanceof ss&&this.add(e.content)},i.prototype.onCompositionItemRemoved=function(t,e){e instanceof ss&&e.content&&this.remove(e.content,t.renderFrame)},i.prototype.prepareRenderFrame=function(t,e){return this.meshes.forEach((function(t){return e.addMeshToDefaultRenderPass(t)})),this.meshes.length=0,!1},i.prototype.add=function(t){var e=this;t.meshes.forEach((function(t){return z(e.meshes,t)}))},i.prototype.remove=function(t,e){var r=this;t.meshes.forEach((function(t){B(r.meshes,t),e.removeMeshFromDefaultRenderPass(t)}))},i}(sr);var us,ls=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(sr),cs=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._v_priority=1,e.childrenVisible=!0,e}return r(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return w.null},enumerable:!1,configurable:!0}),e.prototype.onConstructed=function(t){this.cal=t.content,this.relative=t.relative},e.prototype.onLifetimeBegin=function(t,e){e.active=!0},e.prototype.onItemRemoved=function(t,e){},e.prototype.onItemUpdate=function(t,e){this.content&&(this.content.updateTime(this.time),this.renderData=this.content.getRenderData(this.content.time))},e.prototype.setScale=function(t,e,r){this.content.startSize=new Mt(t,e,r)},e.prototype.scale=function(t,e,r){var i=this.content.startSize.clone();this.content.startSize=new Mt(t*i.x,e*i.y,r*i.z)},e.prototype.getHitTestParams=function(t){},e.prototype.getRenderData=function(){return this.renderData},e.prototype.getChildrenVisible=function(){return this.childrenVisible},e.prototype.setChildrenVisible=function(t){this.childrenVisible!==t&&(this.childrenVisible=!!t,this.handleVisibleChanged(this.visible))},e.prototype.doCreateContent=function(t){var e=new In(this.cal,this);return e.renderData=e.getRenderData(0,!0),e},e.prototype.handleVisibleChanged=function(t){this.content&&(this.content.visible=t||this.childrenVisible)},e}(Qe),hs=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getItemGeometryData=function(t,e){var r=t,i=r.splits,n=r.renderer,o=r.textureSheetAnimation,s=r.startSize;r.textLayout;var a=s.x,u=s.y;if(n.shape){for(var l=n.shape,c=l.index,h=l.aPoint,f=new Float32Array(h),p=0;p<f.length;p+=6)f[p]*=a,f[p+1]*=u;return{index:c,aPoint:Array.from(f)}}var d=.5,m=.5,v=[-d,m,-d,-m,d,m,d,-m],y=[],g=[],x=2,T=2;1===i.length&&(x=1,T=1);for(var E=0;E<x;E++)for(var S=0;S<T;S++){var b=4*(2*S+E),A=o?[0,0,1,1,i[0][4]]:i[2*S+E],_=A[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],C=((E+E+1)/x-1)/2,R=((S+S+1)/T-1)/2,O=A[0],w=A[1],M=A[4]?A[3]:A[2],L=A[4]?A[2]:A[3],I=[v[0]/x+C,v[1]/T+R,v[2]/x+C,v[3]/T+R,v[4]/x+C,v[5]/T+R,v[6]/x+C,v[7]/T+R];y.push(I[0]*a,I[1]*u,_[0]*M+O,_[1]*L+w,e,0,I[2]*a,I[3]*u,_[2]*M+O,_[3]*L+w,e,0,I[4]*a,I[5]*u,_[4]*M+O,_[5]*L+w,e,0,I[6]*a,I[7]*u,_[6]*M+O,_[7]*L+w,e,0),this.lineMode?g.push(b,1+b,1+b,3+b,3+b,2+b,2+b,b):g.push(b,1+b,2+b,2+b,1+b,3+b)}return{index:g,aPoint:y}},e}(xn),fs=function(t){var e,r,i,n,o,s;this.isUnderline=!1,this.underlineHeight=1,this.isOutlined=!1,this.outlineWidth=0,this.hasShadow=!1,this.fontDesc="",this.fontScale=2,this.fontOffset=0;var a=t.textColor,u=void 0===a?[1,1,1,1]:a,l=t.fontSize,c=void 0===l?40:l,h=t.outline,f=t.shadow,p=t.fontWeight,d=void 0===p?"normal":p,m=t.fontStyle,v=void 0===m?"normal":m,y=t.fontFamily,g=void 0===y?"sans-serif":y;this.textColor=u,this.textWeight=d,this.fontStyle=v,this.fontFamily=g,this.fontSize=c,h&&(this.isOutlined=!0,this.outlineColor=null!==(e=h.outlineColor)&&void 0!==e?e:[1,1,1,1],this.outlineWidth=null!==(r=h.outlineWidth)&&void 0!==r?r:1,this.fontOffset+=this.outlineWidth),f&&(this.hasShadow=!0,this.shadowBlur=null!==(i=f.shadowBlur)&&void 0!==i?i:2,this.shadowColor=null!==(n=f.shadowColor)&&void 0!==n?n:[0,0,0,1],this.shadowOffsetX=null!==(o=f.shadowOffsetX)&&void 0!==o?o:0,this.shadowOffsetY=null!==(s=f.shadowOffsetY)&&void 0!==s?s:0),this.fontStyle!==xt.normal&&(this.fontOffset+=this.fontSize*Math.tan(.20943951))},ps=function(){function t(){}return t.measureFont=function(e){if(t._fonts[e])return t._fonts[e];var r={ascent:0,descent:0,fontSize:0},i=t._canvas,n=i.getContext("2d",{willReadFrequently:!0});n.font=e;var o=t.METRICS_STRING+t.BASELINE_SYMBOL,s=Math.ceil(n.measureText(o).width),a=Math.ceil(n.measureText(t.BASELINE_SYMBOL).width),u=Math.ceil(t.HEIGHT_MULTIPLIER*a);a=a*t.BASELINE_MULTIPLIER|0,i.width=s,i.height=u,n.fillStyle="#f00",n.fillRect(0,0,s,u),n.font=e,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(o,0,a);var l=n.getImageData(0,0,s,u).data,c=l.length,h=4*s,f=0,p=0,d=!1;for(f=0;f<a;++f){for(var m=0;m<h;m+=4)if(255!==l[p+m]){d=!0;break}if(d)break;p+=h}for(r.ascent=a-f,p=c-h,d=!1,f=u;f>a;--f){for(m=0;m<h;m+=4)if(255!==l[p+m]){d=!0;break}if(d)break;p-=h}return r.descent=f-a,r.fontSize=r.ascent+r.descent,t._fonts[e]=r,r},Object.defineProperty(t,"_canvas",{get:function(){var e;return di(fi)?(e=window._createOffscreenCanvas(10,10),t.__canvas=e):t.__canvas||((e=document.createElement("canvas")).width=e.height=10,t.__canvas=e),t.__canvas},enumerable:!1,configurable:!0}),t._fonts={},t.METRICS_STRING="|ÉqÅ",t.BASELINE_SYMBOL="M",t.BASELINE_MULTIPLIER=1.4,t.HEIGHT_MULTIPLIER=2,t}(),ds=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];t.QTextWrapMode=void 0,(us=t.QTextWrapMode||(t.QTextWrapMode={}))[us.Default=0]="Default",us[us.Clip=1]="Clip",us[us.Ellipsis=2]="Ellipsis";var ms=function(){function e(e,r){var i,n,o,s,a,u,l,c,h,f;this.left=0,this.top=0,this.fontSize=48,this.fontFamily="Arial",this.color="black",this.letterSpacing=0,this.maxLineWidth=0,this.wrap=t.QTextWrapMode.Clip,this.scaleX=1,this.scaleY=1,this.angle=0,this.active=!0,this.padding=0,this.borderColor="#ffffffff",this.borderWidth=1,this.fontProperties={ascent:0,descent:0,fontSize:0},this.fontVariant="normal",this.originX="left",this.originY="top",this.ellipsis="…",this.text=e,this.left=null!==(i=r.left)&&void 0!==i?i:0,this.top=null!==(n=r.top)&&void 0!==n?n:0,this.maxLineWidth=null!==(o=r.maxWidth)&&void 0!==o?o:0,this.letterSpacing=null!==(s=r.letterSpacing)&&void 0!==s?s:0,this.originX="left",this.originY="top",this.color=null!==(a=r.color)&&void 0!==a?a:"black",this.fontFamily=null!==(u=r.fontFamily)&&void 0!==u?u:"Arial",this.fontSize=null!==(l=r.fontSize)&&void 0!==l?l:48,this.wrap=null!==(c=r.wrap)&&void 0!==c?c:t.QTextWrapMode.Clip,this.fontStyle=null!==(h=r.fontStyle)&&void 0!==h?h:"normal",this.textAlign="left",this.textBaseline="alphabetic",this.fontWeight="normal",this.angle=null!==(f=r.angle)&&void 0!==f?f:0,this.name=r.name||""}return e.prototype.update=function(){this.updateDimension()},e.prototype.render=function(){if(void 0!==this.viewer){var t=this.viewer.renderContext;void 0!==t&&(t.save(),this.setRenderTransform(t),this.renderText(t),this.active&&this.drawBorders(t),t.restore())}},e.prototype.init=function(t){this.viewer=t,this.updateDimension()},e.prototype.getLayout=function(){var t=this.viewer.scaleX,e=this.viewer.scaleY;return{x:this.left*t,y:this.top*e,width:this.width*t,height:this.height*e}},e.prototype.updateDimension=function(){var t=this.viewer.renderContext;this.configTextStyle(t),this.configTextLayout(t);var e=this.getFontDesc();this.fontProperties=ps.measureFont(e),0===this.fontProperties.fontSize&&(this.fontProperties.fontSize=this.fontSize,this.fontProperties.ascent=this.fontSize);var r=this.createCharsFromText(t,this.text),i=0;if(r.length>0){var n=r[r.length-1];i=n.left+n.width}this.chars=r,this.maxLineWidth=i,void 0===this.height&&(this.height=this.fontProperties.fontSize),void 0===this.width&&(this.width=this.maxLineWidth)},e.prototype.configTextStyle=function(t){t.font=this.getFontDesc(),t.fillStyle=this.color},e.prototype.getFontDesc=function(){for(var t="number"==typeof this.fontSize?"".concat(this.fontSize,"px"):this.fontSize,e=this.fontFamily.split(","),r=e.length-1;r>=0;r--){var i=e[r].trim();/([\"\'])[^\'\"]+\1/.test(i)||ds.includes(i)||(i='"'.concat(i,'"')),e[r]=i}return e.push("Arial, Helvetica, sans-serif"),"".concat(this.fontStyle," ").concat(this.fontVariant," ").concat(this.fontWeight," ").concat(t," ").concat(e.join(","))},e.prototype.configTextLayout=function(t){t.textBaseline=this.textBaseline,t.textAlign=this.textAlign},e.prototype.setRenderTransform=function(t){t.scale(this.scaleX,this.scaleY),t.translate(this.left,this.top)},e.prototype.renderText=function(t){this.drawCharsInTextBox(t,{min:[0,0],max:[0+this.width,0+this.height]})},e.prototype.drawCharsInTextBox=function(e,r){var i=this.chars,n=0;if(i.length>0){var o=i[i.length-1];n=o.left+o.width}var s=r.max[0]-r.min[0],a=0;"left"===this.textAlign?a=0:"center"===this.textAlign?a=.5*(s-n):"right"===this.textAlign&&(a=s-n),this.addOffsetToChars(i,a);var u=this.cloneChars(this.clipCharsWithTextBox(i,r)),l=u;this.wrap===t.QTextWrapMode.Ellipsis&&0===(l=this.replaceCharWithEllipsis(e,u,r)).length&&0!==i.length&&this.addEllipsisToChars(e,l,r),this.drawCharsFromLeft(e,l)},e.prototype.addEllipsisToChars=function(t,e,r){var i,n,o,s=t.measureText(this.ellipsis).width;if("left"===this.textAlign)e.push({char:this.ellipsis,left:r.min[0],top:0,width:s,heigh:null!==(i=this.height)&&void 0!==i?i:0,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!0,scale:1,index:0});else if("right"===this.textAlign)e.push({char:this.ellipsis,left:r.max[0]-s,top:0,width:s,heigh:null!==(n=this.height)&&void 0!==n?n:0,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!0,scale:1,index:0});else{var a=.5*(r.max[0]+r.min[0]);e.push({char:this.ellipsis,left:a-.5*s,top:0,width:s,heigh:null!==(o=this.height)&&void 0!==o?o:0,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!0,scale:1,index:0})}},e.prototype.createCharsFromText=function(t,e){var r=e.split(""),i=0,n=0;"top"===this.textBaseline?n=0:"middle"===this.textBaseline?n+=.5*this.fontProperties.ascent:"alphabetic"===this.textBaseline&&(n+=this.fontProperties.ascent);for(var o=[],s=0;s<r.length;++s){var a=r[s],u=Math.floor(t.measureText(a).width),l={left:i,top:n,width:u,heigh:this.fontSize,char:a,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!1,scale:1,index:s};o.push(l),i+=u+this.letterSpacing}return o},e.prototype.addOffsetToChars=function(t,e){return t.forEach((function(t){t.left+=e})),t},e.prototype.clipCharsWithTextBox=function(t,e){for(var r=[],i=0;i<t.length;++i){var n=t[i];n.left>=e.min[0]&&n.left+n.width<e.max[0]+.5&&r.push(n)}return r},e.prototype.cloneChars=function(t){return t.map((function(t){return i({},t)}))},e.prototype.replaceCharWithEllipsis=function(t,e,r){var n=t.measureText(this.ellipsis).width;if(e.length>0){if(0!==e[0].index)(o=i({},e[0])).char=this.ellipsis,o.isEllipsis=!0,o.width=n,e=this.findEllipsisPositionAndReplaceCharsFromLeft(e,o,r);var o,s=e.length-1,a=this.chars.length;if(e[s].index!==a-1)(o=i({},e[0])).char=this.ellipsis,o.isEllipsis=!0,o.width=n,e=this.findEllipsisPositionAndReplaceCharsFromRight(e,o,r)}return e},e.prototype.findEllipsisPositionAndReplaceCharsFromLeft=function(t,e,r){for(var i=0,n=0;n<t.length;++n){var o=t[n];if(i=n,o.left+o.width-e.width>=r.min[0])break}var s=t[i];e.left=s.left+s.width-e.width;for(n=0;n<i+1;++n)t.shift();return[e].concat(t)},e.prototype.findEllipsisPositionAndReplaceCharsFromRight=function(t,e,r){for(var i=t.length-1,n=i;n>=0;--n){if(i=n,t[n].left+e.width<=r.max[0])break}e.left=t[i].left;for(n=t.length-1;n>=i;--n)t.pop();return t.concat([e])},e.prototype.drawCharsFromLeft=function(t,e){var r=t.textAlign||"left";t.textAlign="left";for(var i=0;i<e.length;++i){var n=e[i];t.fillText(n.char,n.left,n.top)}t.textAlign=r},e.prototype.drawBorders=function(t){this.padding;var e=this.borderWidth;t.strokeStyle=this.borderColor,t.lineWidth=e;var r=this.width,i=this.height,n=0,o=0;"center"===this.originX?n-=this.width/2:"right"===this.originX&&(n-=this.width),"center"===this.originY?o-=this.height/2:"bottom"===this.originY&&(o-=this.height),t.strokeRect(n+e/2,o+e/2,r-e,i-e)},e}(),vs=function(){function t(t,e,r,i,n,o){var s;this.textList=[],s="string"==typeof t?document.getElementById(t):t,this.scaleX=null!=i?i:1,this.scaleY=null!=n?n:1,this.flipY=null!=o&&o,this.width=e,this.height=r,s.style.width="".concat(e*this.scaleX,"px"),s.style.height="".concat(r*this.scaleY,"px");this.devicePixelRatio=1,s.width=1*e*this.scaleX,s.height=1*r*this.scaleY,s.className="lower-canvas",this.renderCanvas=s,this.renderContext=this.renderCanvas.getContext("2d"),this.renderContext.scale(1*this.scaleX,1*this.scaleY)}return t.prototype.initDimension=function(t,e,r,i){this.width=t,this.height=e,this.scaleX=null!=r?r:1,this.scaleY=null!=i?i:1,this.renderCanvas.style.width="".concat(t*this.scaleX,"px"),this.renderCanvas.style.height="".concat(e*this.scaleY,"px");var n=this.devicePixelRatio;this.renderCanvas.width=n*t*this.scaleX,this.renderCanvas.height=n*e*this.scaleY,this.flipY&&(this.renderContext.translate(0,this.height),this.renderContext.scale(1,-1)),this.renderContext.scale(n*this.scaleX,n*this.scaleY)},t.prototype.clearText=function(){this.textList=[]},t.prototype.clearCanvasWithContext=function(t){t.clearRect(0,0,this.width,this.height)},t.prototype.clearCanvas=function(){this.clearCanvasWithContext(this.renderContext)},t.prototype.addObject=function(t){t.init(this),this.textList.push(t)},t.prototype.render=function(){this.clearCanvasWithContext(this.renderContext),this.renderContext.fillStyle="rgba(255, 255, 255, 0.0039)",this.renderContext.fillRect(0,0,this.width,this.height);var t=this.background;t&&void 0!==t.width&&void 0!==t.height&&this.renderContext.drawImage(t,0,0,t.width,t.height,0,0,this.width,this.height);for(var e=0;e<this.textList.length;++e){this.renderContext.save();var r=this.textList[e];r.update(),r.render(),this.renderContext.restore()}},t}();function ys(t,e){return e=e||{},new Promise((function(r,i){var n=new XMLHttpRequest;n.responseType=(null==e?void 0:e.responseType)||"json",n.addEventListener("load",(function(){return r(n.response)})),n.addEventListener("error",(function(){return i(Error("load ".concat(t," fail")))})),n.open((null==e?void 0:e.method)||"get",t),n.send(null==e?void 0:e.data)}))}function gs(t,e,r,i,s){return n(this,void 0,void 0,(function(){var n,a,u,l,c,h,f,p,d,m;return o(this,(function(o){switch(o.label){case 0:return n={},a=[],i=i||{},r=r||{},e.asImage?(u=e.content.replace(/\$/g,""),l=r[u]||e.variables[u],c=function(t){var r=(null==i?void 0:i.canvas)||document.createElement("canvas"),n=r.width=e.backgroundWidth,o=r.height=e.backgroundHeight,a=r.getContext("2d");return null==a||a.clearRect(0,0,n,o),s&&(null==a||a.translate(0,o),null==a||a.scale(1,-1)),null==a||a.drawImage(t,0,0,t.width,t.height,0,0,n,o),r},l?[2,Mr(l).then(c)]:[2,xs(t).then(c)]):(h=i.templateScale||1,Object.keys(e.variables).forEach((function(t){var i=e.variables[t];if(r.hasOwnProperty(t)&&(i=r[t]),/^image_/.test(t)){var o=i instanceof Array,s=o?i[0]:i;a.push(function(t,e){return r(t,(function(i){return e?r(e,(function(){return t})):t}));function r(t,e){return/^(https?:)?\/\//.test(t)?ys(t,{responseType:"blob"}).then(Ts,e):Promise.resolve(t)}}(s,o&&i[1]).then((function(e){return n[t]=e})))}else n[t]=i})),[4,Promise.all(a)]);case 1:return o.sent(),[4,Mr(t)];case 2:return f=o.sent(),p=e.content.replace(/\$([\w_]+)\$/g,(function(t,e){return n[e]})).replace('width="'.concat(e.width,'px"'),'width="'.concat(e.width*h,'px"')).replace('height="'.concat(e.height,'px"'),'height="'.concat(e.height*h,'px"')),[4,Mr("data:image/svg+xml,".concat(encodeURIComponent(p)))];case 3:return d=o.sent(),(m=(null==i?void 0:i.canvas)||document.createElement("canvas")).width=f.width*h,m.height=f.height*h,[2,new Promise((function(t,r){var i=m.getContext("2d");i.clearRect(0,0,m.width,m.height),s&&(i.translate(0,m.height),i.scale(1,-1)),i.drawImage(f,0,0,f.width,f.height,0,0,m.width,m.height),i.drawImage(d,0,0,d.width,d.height,(e.x||0)*h,(e.y||0)*h,e.width*h/e.backgroundWidth*f.width,e.height*h/e.backgroundHeight*f.height),t(m)}))]}}))}))}function xs(t){return ke(t)?Mr(t):Promise.resolve(t)}function Ts(t){return new Promise((function(e,r){var i=new FileReader;i.readAsDataURL(t),i.onload=function(){e(i.result)},i.onerror=r}))}var Es=["serif","sans-serif","monospace","courier"],Ss=800,bs=600,As=new Map,_s=new(function(){function t(){this.elements=[]}return t.prototype.dispose=function(){this.elements.forEach((function(t){return t.remove()})),this.elements=[]},t.prototype.getCanvas=function(){if(this.elements.length)return this.elements.shift();if(di(fi))return window._createOffscreenCanvas(10,10);var t=document.createElement("canvas");return t.getContext("2d",{willReadFrequently:!0}),t},t.prototype.saveCanvas=function(t){t.width=t.height=1,this.elements.length<3?z(this.elements,t):t.remove()},t}());function Cs(t,e){var r,i,n;if(null===(r=null==t?void 0:t.background)||void 0===r?void 0:r.name){var o=t.background.name;e&&e[o]?n=e[o]:(null===(i=t.background)||void 0===i?void 0:i.url)&&(n=t.background.url)}return n}function Rs(e,r,s,a,u){var l;return n(this,void 0,void 0,(function(){var n,c,h,f,p,d,m,v,y,g,x;return o(this,(function(o){switch(o.label){case 0:if(!r)throw Error("image not provided");return n=(null==u?void 0:u.templateScale)||1,c=n,h=n,f=r,p=r.width,d=r.height,s?(p=s.width,d=s.height,r.width===p&&r.height===d||(c*=r.width/s.width,h*=r.height/s.height),(m=Cs(s,a))&&m!==r.src?ke(m)?[4,Mr(m)]:[3,2]:[3,4]):[3,5];case 1:return v=o.sent(),[3,3];case 2:v=m,o.label=3;case 3:f=v,o.label=4;case 4:(y=s.content)&&(g=function(e,r,i){var n=e.fonts,o=[];return e.texts.forEach((function(s){var a,u=s.t,l=s.x,c=s.y,h={weight:400,family:"serif",size:48,style:xt.normal};void 0!==s.f&&(h=n[s.f]);var f=s.n;f&&r&&r.hasOwnProperty(f)&&(u="".concat(r[f]));var p=new ms(u,{left:l,top:c,fontSize:h.size,fontFamily:h.family,fontWeight:"".concat(h.weight),fontStyle:"normal",name:f});if(void 0!==s.r&&(p.angle=s.r*Math.PI/180),p.active=null!==(a=null==i?void 0:i.debug)&&void 0!==a&&a,void 0!==s.w&&(p.width=s.w),void 0!==h.letterSpace&&(p.letterSpacing=h.letterSpace),s.of===mt.display?p.wrap=t.QTextWrapMode.Default:s.of===mt.clip?p.wrap=t.QTextWrapMode.Clip:s.of===mt.ellipsis&&(p.wrap=t.QTextWrapMode.Ellipsis),void 0!==s.c){var d=e.colors[s.c][1],m=1;void 0!==d[3]&&(m=d[3]/255),p.color="rgba(".concat(d[0],", ").concat(d[1],", ").concat(d[2],", ").concat(m,")")}s.a===yt.left?p.textAlign="left":s.a===yt.middle?p.textAlign="center":s.a===yt.right&&(p.textAlign="right"),h.style===xt.normal?p.fontStyle="normal":h.style===xt.italic?p.fontStyle="italic":h.style===xt.oblique&&(p.fontStyle="oblique"),void 0!==h.weight&&(p.fontWeight=String(h.weight)),(null==i?void 0:i.borderColor)&&(p.borderColor=i.borderColor),void 0!==(null==i?void 0:i.borderWidth)&&(p.borderWidth=i.borderWidth),o.push(p)})),o}(y,a,i(i({},u),{scaleX:c,scaleY:h})),g.forEach((function(t){e.addObject(t)}))),o.label=5;case 5:return e.flipY=null!==(l=null==u?void 0:u.flipY)&&void 0!==l&&l,e.initDimension(p,d,c,h),e.background=f,e.render(),(x=null==u?void 0:u.textLayouts)&&(x.length=0,e.textList.forEach((function(t){var e=t.getLayout(),r={x:e.x,y:e.y,width:e.width,height:e.height};x.push(r)}))),[2]}}))}))}function Os(t){return n(this,void 0,void 0,(function(){var e,r,i;return o(this,(function(n){switch(n.label){case 0:if(!t.content||!t.content.fonts)return[3,4];e=t.content.fonts,r=function(t){var r,i,n,s,a;return o(this,(function(o){switch(o.label){case 0:return r=e[t].family,i=e[t].url,n=!1,Es.includes(r)?n=!0:void 0!==document.fonts&&document.fonts.forEach((function(t){t.family===r&&(n=!0)})),n||void 0===i||""===i?[3,2]:(s="url(".concat(i,")"),void 0===document.fonts?[3,2]:[4,(a=new FontFace("".concat(r),s)).load()]);case 1:o.sent(),document.fonts.add(a),o.label=2;case 2:return[2]}}))},i=0,n.label=1;case 1:return i<e.length?[5,r(i)]:[3,4];case 2:n.sent(),n.label=3;case 3:return++i,[3,1];case 4:return[2]}}))}))}function ws(t,e,r,s,a){return n(this,void 0,void 0,(function(){var n,u,l;return o(this,(function(o){switch(o.label){case 0:return n=i(i({},s),{flipY:a}),u=function(t,e,r){var i,n=(null==r?void 0:r.templateScale)||1,o=(null==r?void 0:r.flipY)||!1;if(null==r?void 0:r.canvas){if(!(i=As.get(r.canvas))){var s=new vs(r.canvas,t,e,n,n,o);As.set(r.canvas,s),i=s}}else{var a=_s.getCanvas();i=new vs(a,Ss,bs,n,n,o)}return i}(Ss,Ss,n),void 0===e?[3,2]:[4,Os(e)];case 1:o.sent(),o.label=2;case 2:return u.clearText(),"string"!=typeof t?[3,5]:[4,Mr(t)];case 3:return l=o.sent(),[4,Rs(u,l,e,r,n)];case 4:return o.sent(),[2,u.renderCanvas];case 5:return[4,Rs(u,t,e,r,n)];case 6:return o.sent(),[2,u.renderCanvas]}}))}))}function Ms(t,e,r,i,s){return n(this,void 0,void 0,(function(){return o(this,(function(n){return 2===e.v?[2,ws(t,e,r,{templateScale:null==i?void 0:i.templateScale,toData:!0},s)]:[2,gs(t,e,r,i,s)]}))}))}var Ls=function(){function t(t){this.width=0,this.height=0;var e=t.textHeight,r=void 0===e?100:e,i=t.textWidth,n=void 0===i?100:i,o=t.textOverflow,s=void 0===o?mt.display:o,a=t.textBaseline,u=void 0===a?vt.top:a,l=t.textAlign,c=void 0===l?yt.left:l,h=t.text,f=t.letterSpace,p=void 0===f?0:f,d=t.autoWidth,m=void 0!==d&&d,v=t.fontSize,y=t.lineHeight,g=void 0===y?v:y,x=v+p;this.autoWidth=m,this.maxTextWidth=h.length*x,this.width=n,this.height=r,this.letterSpace=p,this.overFlow=s,this.textBaseline=u,this.textAlign=c,this.lineHeight=g}return t.prototype.getOffsetY=function(t){var e=0,r=(t.fontSize+t.outlineWidth)*t.fontScale;switch(this.textBaseline){case 0:e=r;break;case 1:e=(this.height+r)/2;break;case 2:e=this.height-r/2}return e},t.prototype.getOffsetX=function(t,e){var r=0;switch(this.textAlign){case 0:r=t.outlineWidth*t.fontScale;break;case 1:r=(this.width*t.fontScale-e)/2;break;case 2:r=this.width*t.fontScale-e}return r},t.prototype.setSize=function(t,e){this.width=t,this.height=e},t}(),Is=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;n.isDirty=!0;var o=e.options;return n.canvas=_s.getCanvas(),_s.saveCanvas(n.canvas),n.context=n.canvas.getContext("2d",{willReadFrequently:!0}),n.engine=i.composition.getEngine(),n.textStyle=new fs(o),n.textLayout=new Ls(o),n.text=o.text,n.mesh=new hs(n.engine,n.renderInfo,i.composition),n}return r(e,t),e.prototype.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.prototype.setFontWeight=function(t){this.textStyle.textWeight!==t&&(this.textStyle.textWeight=t,this.isDirty=!0)},e.prototype.setFontStyle=function(t){this.textStyle.fontStyle!==t&&(this.textStyle.fontStyle=t,this.isDirty=!0)},e.prototype.setText=function(t){this.text!==t&&(this.text=t,this.isDirty=!0)},e.prototype.setTextAlign=function(t){this.textLayout.textAlign!==t&&(this.textLayout.textAlign=t,this.isDirty=!0)},e.prototype.setTextBaseline=function(t){this.textLayout.textBaseline!==t&&(this.textLayout.textBaseline=t,this.isDirty=!0)},e.prototype.setTextColor=function(t){this.textStyle.textColor!==t&&(this.textStyle.textColor=t,this.isDirty=!0)},e.prototype.setFontFamily=function(t){this.textStyle.fontFamily!==t&&(this.textStyle.fontFamily=t,this.isDirty=!0)},e.prototype.setOutlineColor=function(t){this.textStyle.outlineColor!==t&&(this.textStyle.outlineColor=t,this.isDirty=!0)},e.prototype.setOutlineWidth=function(t){this.textStyle.outlineWidth!==t&&(this.textStyle.outlineWidth=t,this.isDirty=!0)},e.prototype.setShadowBlur=function(t){this.textStyle.shadowBlur!==t&&(this.textStyle.shadowBlur=t,this.isDirty=!0)},e.prototype.setShadowColor=function(t){this.textStyle.shadowColor!==t&&(this.textStyle.shadowColor=t,this.isDirty=!0)},e.prototype.setShadowOffsetX=function(t){this.textStyle.shadowOffsetX!==t&&(this.textStyle.shadowOffsetX=t,this.isDirty=!0)},e.prototype.setShadowOffsetY=function(t){this.textStyle.shadowOffsetY!==t&&(this.textStyle.shadowOffsetY=t,this.isDirty=!0)},e.prototype.setFontScale=function(t){this.textStyle.fontScale!==t&&(this.textStyle.fontScale=t,this.isDirty=!0)},e.prototype.updateTexture=function(){var t;if(this.isDirty&&this.context&&this.canvas){var e=this.context,r=this.textStyle,i=this.textLayout,n=r.fontScale,o=(i.width+r.fontOffset)*n,s=i.height*n,a=r.fontSize*n,u=i.lineHeight*n;this.char=(this.text||"").split(""),this.canvas.width=o,this.canvas.height=s,e.clearRect(0,0,o,this.canvas.height),e.fillStyle="rgba(255, 255, 255, 0.0039)",e.fillRect(0,0,o,this.canvas.height),r.fontDesc=this.getFontDesc(),e.font=r.fontDesc,r.hasShadow&&this.setupShadow(),r.isOutlined&&this.setupOutline(),e.fillStyle="rgba(".concat(r.textColor[0],", ").concat(r.textColor[1],", ").concat(r.textColor[2],", ").concat(r.textColor[3],")");for(var l=[],c=(u-a)/3,h=0,f=i.getOffsetY(r)+c,p=[],d=[],m=0;m<this.char.length;m++){var y=this.char[m],g=e.measureText(y);((h+=i.letterSpace*n)+g.width>o&&m>0||"\n"===y)&&(l.push({y:f,width:h,chars:p,charOffsetX:d}),h=0,f+=u,p=[],d=[]),"\n"!==y&&(p.push(y),d.push(h),h+=g.width)}l.push({y:f,width:h,chars:p,charOffsetX:d}),l.forEach((function(t){var n=i.getOffsetX(r,t.width);t.chars.forEach((function(i,o){r.isOutlined&&e.strokeText(i,n+t.charOffsetX[o],t.y),e.fillText(i,n+t.charOffsetX[o],t.y)}))})),r.hasShadow&&(e.shadowColor="transparent");var x=e.getImageData(0,0,this.canvas.width,this.canvas.height);null===(t=this.mesh)||void 0===t||t.mesh.material.setTexture("uSampler0",Vr.createWithData(this.engine,{data:new Uint8Array(x.data),width:x.width,height:x.height},{flipY:!0,magFilter:v.LINEAR,minFilter:v.LINEAR,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE})),this.isDirty=!1}},e.prototype.getFontDesc=function(){var t=this.textStyle,e="".concat((t.fontSize*t.fontScale).toString(),"px ");return Es.includes(t.fontFamily)?e+=t.fontFamily:e+='"'.concat(t.fontFamily,'"'),t.textWeight!==gt.normal&&(e="".concat(t.textWeight," ").concat(e)),t.fontStyle!==xt.normal&&(e="".concat(t.fontStyle," ").concat(e)),e},e.prototype.setupOutline=function(){var t=this.context,e=this.textStyle;t.strokeStyle="rgba(".concat(255*e.outlineColor[0],", ").concat(255*e.outlineColor[1],", ").concat(255*e.outlineColor[2],", ").concat(e.outlineColor[3],")"),t.lineWidth=2*e.outlineWidth},e.prototype.setupShadow=function(){var t=this.context,e=this.textStyle;t.shadowColor="rgba(".concat(255*e.shadowColor[0],", ").concat(255*e.shadowColor[1],", ").concat(255*e.shadowColor[2],", ").concat(e.shadowColor[3],")"),t.shadowBlur=e.shadowBlur,t.shadowOffsetX=e.shadowOffsetX,t.shadowOffsetY=-e.shadowOffsetY},e}(Nn),Ps=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.text},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){this.textContext=t.content},n.prototype.onLifetimeBegin=function(t,e){var r,i;e.active=!0,null===(i=null===(r=this.content)||void 0===r?void 0:r.mesh)||void 0===i||i.setItems([this.content]),this.content.updateTexture()},n.prototype.onItemRemoved=function(t,e){e&&(delete e.mesh,t.destroyTextures(e.getTextures()))},n.prototype.onItemUpdate=function(t,e){var r;this.content&&(null===(r=this.content)||void 0===r||r.updateTime(this.time))},n.prototype.getCurrentPosition=function(){var t=new Mt;return this.transform.assignWorldTRS(t),t},n.prototype.getBoundingBox=function(){var e=this.content;if(e&&this.transform){var r=this.transform.getWorldMatrix(),i=e.startSize,n=le(Mt.ZERO,i.x/2,i.y/2);return n.forEach((function(t){r.transformPoint(t.p0),r.transformPoint(t.p1),r.transformPoint(t.p2)})),{type:t.HitTestType.triangle,area:n}}},n.prototype.getHitTestParams=function(t){var e,r,i=this.content,n=i&&i.interaction;if((t||n)&&(null===(e=i.mesh)||void 0===e?void 0:e.mesh)&&i){var o=this.getBoundingBox();if(o)return{behavior:(null===(r=i.interaction)||void 0===r?void 0:r.behavior)||0,type:o.type,triangles:o.area,backfaceCulling:i.renderer.side===b.FRONT}}},n.prototype.getRenderData=function(){return this.content.getRenderData(this.content.time)},n.prototype.doCreateContent=function(t){var e=t.getRendererOptions().emptyTexture;return new Is(this.textContext,{emptyTexture:e},this)},n.prototype.createWireframeMesh=function(t,e){var r=new hs(this.composition.getEngine(),i({wireframe:!0},t.renderInfo),this.composition);return r.mesh.setVisible(!0),r.setItems([t]),r.mesh.material.setVector3("uFrameColor",Mt.fromArray(e)),r.mesh.priority=999,r},n}(Qe),Fs=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="text",t.addItems=[],t.removeItems=[],t.meshes=[],t}return r(i,e),i.prototype.onCompositionDestroyed=function(e){e.reusable?this.addItems.forEach((function(e){var r;null===(r=e.content.mesh)||void 0===r||r.mesh.dispose({material:{textures:t.DestroyOptions.keep}})})):this.addItems.forEach((function(t){var e;null===(e=t.content.mesh)||void 0===e||e.mesh.dispose()}))},i.prototype.onCompositionUpdate=function(t,e){this.addItems.forEach((function(t){var e,r,i;t.contentVisible?(null===(r=t.content.mesh)||void 0===r||r.mesh.setVisible(!0),t.content.updateTexture(),!t.content.ended&&t.content.mesh&&(t.content.mesh.updateItem(t.content),null===(i=t.content.mesh)||void 0===i||i.applyChange())):null===(e=t.content.mesh)||void 0===e||e.mesh.setVisible(!1)}))},i.prototype.onCompositionItemLifeBegin=function(t,e){var r;e instanceof Ps&&e.content&&(this.addItems.includes(e)||(z(this.addItems,e),!e.content.ended&&e.content.mesh&&e.content.mesh.updateItem(e.content),null===(r=e.content.mesh)||void 0===r||r.applyChange()))},i.prototype.onCompositionReset=function(t,e){},i.prototype.onCompositionItemRemoved=function(e,r){var i;r instanceof Ps&&r&&(z(this.removeItems,r),this.addItems.includes(r)&&(null===(i=r.content)||void 0===i?void 0:i.mesh)&&(B(this.addItems,r),r.content.mesh.mesh.dispose({material:{textures:t.DestroyOptions.keep}}),r.dispose()))},i.prototype.prepareRenderFrame=function(e,r){var i=this;return this.removeItems.map((function(e){var n,o;(null===(n=e.content)||void 0===n?void 0:n.mesh)&&(r.removeMeshFromDefaultRenderPass(null===(o=e.content.mesh)||void 0===o?void 0:o.mesh),B(i.addItems,e),e.content.mesh.mesh.dispose({material:{textures:t.DestroyOptions.keep}}),e.dispose())})),this.addItems.forEach((function(t){var e;t.content.mesh&&r.addMeshToDefaultRenderPass(null===(e=t.content.mesh)||void 0===e?void 0:e.mesh)})),this.removeItems.length=0,!1},i}(sr);function Ns(t,e,r){return function(t,e,r){var n=i(i({},e.material.props),{shader:r}),o=e.material.clone(n);return o.blending=!1,o.depthTest=!1,o.culling=!1,gi.create(t,{geometry:e.geometry,material:o})}(t,e,Sn(t.gpuCapability.level,{fragment:r.fragment},{ignoreBlend:!0}))}var Vs=function(e){function i(t,r,i,n,o,s){var a=e.call(this,t,s)||this;return a.uTexStep=i,a.pluginSystem=n,a.fragShader=o,a.type=r,a}return r(i,e),i.prototype.configure=function(e){if(this.prePassTexture=e.getFrameBuffer().getColorTextures()[0]?e.getFrameBuffer().getColorTextures()[0]:e.renderingData.currentFrame.transparentTexture,"H"===this.type&&(this.preDefaultPassAttachment.texture=this.prePassTexture),this.preDefaultPassTexture=this.preDefaultPassAttachment.texture,!this.mframeBuffer){var r=Vr.create(e.engine,{sourceType:t.TextureSourceType.framebuffer,minFilter:v.LINEAR,magFilter:v.LINEAR,name:this.type,internalFormat:v.RGBA,format:v.RGBA,type:v.UNSIGNED_BYTE});this.mframeBuffer=cn.create({name:this.type,storeAction:{},viewport:this.viewport,viewportScale:1,isCustomViewport:!0,attachments:[r],depthStencilAttachment:{storageType:t.RenderPassAttachmentStorageType.none}},e)}e.setFrameBuffer(this.mframeBuffer)},i.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.preDefaultPassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.preDefaultPassTexture)),this.meshes[1].material.setVector2("uTexStep",this.uTexStep),this.meshes[1].material.setTexture("uBlurSource",this.uBlurSource?this.uBlurSource:this.prePassTexture),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassTexture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture));var e=[this.meshes[0],Ns(t.engine,this.meshes[1],{fragment:this.fragShader})];t.renderMeshes(e)},i.prototype.dispose=function(t){e.prototype.dispose.call(this,t);var r=this.mframeBuffer;r&&r.dispose(t)},i}(bi),Ds=function(t){function e(e,r,i){var n=t.call(this,e,r)||this;return i&&(n.preDefaultPassAttachment=i),n}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],this.preDefaultPassAttachment||(this.preDefaultPassAttachment=new Ei(t.engine,{}),this.preDefaultPassAttachment.texture=this.prePassTexture),t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.preDefaultPassAttachment.texture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.preDefaultPassAttachment.texture)),this.meshes[1].material.setTexture("uFrameSource",this.prePassTexture),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassAttachment.texture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture));var e=[this.meshes[0],this.meshes[1]];t.renderMeshes(e)},e}(bi);function zs(t){for(var e=t.radius<=3?1:2,r=t.radius/e,i=t.maxStep||4;r>10&&e<i;)e*=2,r=t.radius/e;for(var n=1+t.radius%e/e/e,o=function(t){for(var e=(t+1)/3.329,r=[],i=-t;i<=t;i++)r.push(Bs(i,e));return r}(r=Math.floor(r)),s=[],a=-r;a<=r;a++){var u=o[a+r];s.push("color += texture2D(uBlurSource,getTexCoord(".concat(a.toFixed(1),")) * ").concat(u,";"))}return{shader:"\n uniform sampler2D uBlurSource;\n uniform vec2 uTexSize;\n uniform vec2 uTexStep;\n #define getTexCoord(i) coord + uTexStep/uTexSize * i\n vec4 filterMain(vec2 coord,sampler2D tex){\n vec4 color = vec4(0.);\n vec2 texCoord;\n ".concat(s.join("\n"),"\n\n return color;\n }\n "),step:n,downSample:e,radius:r}}function Bs(t,e){return Math.exp(-t*t/(2*e*e))/Math.sqrt(2*Math.PI)/e}var Us=function(t){function e(e,r){return t.call(this,e,r)||this}return r(e,t),e.prototype.configure=function(t){var e=t.getFrameBuffer();this.preDefaultPassAttachment.texture=e?e.getColorTextures()[0]:t.renderingData.currentFrame.transparentTexture,t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassAttachment.texture),this.meshes[1].material.setVector2("uTexSize",Ji(this.preDefaultPassAttachment.texture));var e=[Ns(t.engine,this.meshes[1],{fragment:this.fragShader})];t.renderMeshes(e)},e}(bi),ks=function(t){function e(e,r,i,n,o,s,a){var u=t.call(this,e,s)||this;return u.uTexStep=i,u.pluginSystem=n,u.fragShader=o,u.type=r,a&&(u.uBlurSource=a),u}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],this.preDefaultPassTexture=this.preDefaultPassAttachment.texture,t.setFrameBuffer(this.frameBuffer),this.uBlurSource||(this.uBlurSource=this.prePassTexture)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[1].material.setVector2("uTexStep",this.uTexStep),this.meshes[1].material.setTexture("uBlurSource",this.uBlurSource),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassTexture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),this.meshes[1].material.setVector2("uTexSize",Ji(this.uBlurSource));var e=[Ns(t.engine,this.meshes[1],{fragment:this.fragShader})];t.renderMeshes(e)},e}(bi),Gs=function(t){function e(e,r,i){var n=t.call(this,e,r)||this;return n.preDefaultPassAttachment=i,n}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.preDefaultPassAttachment.texture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.preDefaultPassAttachment.texture)),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassAttachment.texture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),this.meshes[1].material.setVector2("uTexSize",Ji(this.preDefaultPassAttachment.texture));var e=[this.meshes[0],this.meshes[1]];t.renderMeshes(e)},e}(bi),Xs=function(t){function e(e,r){return t.call(this,e,r)||this}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.prePassTexture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture));var e=[this.meshes[0],this.meshes[1]];t.renderMeshes(e)},e}(bi);function Hs(t,e,r){for(var i=be(e||1),n=e?256:1,o=new Uint8Array(n),s=0;s<n;s++){var a=s/(n-1);o[s]=Math.round(255*i.getValue(r?1-a:a))}return Vr.createWithData(t,{width:n,height:1,data:o},{format:v.LUMINANCE})}var Ys=new Mt(1,1,1),js=function(){function t(t,e){void 0===e&&(e={}),this.name=t,this.viewMatrix=Ft.fromIdentity(),this.projectionMatrix=Ft.fromIdentity(),this.viewProjectionMatrix=Ft.fromIdentity(),this.inverseViewMatrix=Ft.fromIdentity(),this.dirty=!0;var r=e.near,i=void 0===r?.1:r,n=e.far,o=void 0===n?20:n,s=e.fov,a=void 0===s?60:s,u=e.aspect,l=void 0===u?1:u,c=e.clipMode,h=void 0===c?it.portrait:c,f=e.position,p=void 0===f?[0,0,8]:f,d=e.rotation,m=void 0===d?[0,0,0]:d;this.options={near:i,far:o,fov:a,aspect:l,clipMode:h,position:Mt.fromArray(p),rotation:Dt.fromArray(m)},this.dirty=!0,this.updateMatrix()}return Object.defineProperty(t.prototype,"near",{get:function(){return this.options.near},set:function(t){this.options.near!==t&&(this.options.near=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"far",{get:function(){return this.options.far},set:function(t){this.options.far!==t&&(this.options.far=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fov",{get:function(){return this.options.fov},set:function(t){this.options.fov!==t&&(this.options.fov=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"aspect",{get:function(){return this.options.aspect},set:function(t){this.options.aspect!==t&&(this.options.aspect=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clipMode",{get:function(){return this.options.clipMode},set:function(t){void 0!==t&&this.options.clipMode!==t&&(this.options.clipMode=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this.options.position.clone()},set:function(t){this.options.position.equals(t)||(this.options.position.copyFrom(t),this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.options.rotation.clone()},set:function(t){this.options.rotation.equals(t)||(this.options.rotation.copyFrom(t),this.dirty=!0,this.options.quat=void 0)},enumerable:!1,configurable:!0}),t.prototype.getViewMatrix=function(){return this.updateMatrix(),this.viewMatrix.clone()},t.prototype.getInverseViewMatrix=function(){return this.updateMatrix(),this.inverseViewMatrix.clone()},t.prototype.getProjectionMatrix=function(){return this.updateMatrix(),this.projectionMatrix.clone()},t.prototype.getInverseProjectionMatrix=function(){var t;return this.updateMatrix(),null===(t=this.inverseProjectionMatrix)||void 0===t?void 0:t.clone()},t.prototype.getViewProjectionMatrix=function(){return this.updateMatrix(),this.viewProjectionMatrix.clone()},t.prototype.getInverseViewProjectionMatrix=function(){return this.updateMatrix(),this.inverseViewProjectionMatrix||(this.inverseViewProjectionMatrix=this.viewProjectionMatrix.clone(),this.inverseViewProjectionMatrix.invert()),this.inverseViewProjectionMatrix.clone()},t.prototype.getModelViewProjection=function(t,e){return t.multiplyMatrices(this.viewProjectionMatrix,e)},t.prototype.getInverseVPRatio=function(t){var e=new Mt(0,0,t),r=this.getViewProjectionMatrix(),i=e.applyMatrix(r).z;return new Mt(1,1,i).applyMatrix(r)},t.prototype.setQuat=function(t){void 0===this.options.quat?(this.options.quat=t.clone(),this.dirty=!0):(this.options.quat,this.options.quat.equals(t)||(this.options.quat.copyFrom(t),this.dirty=!0)),this.dirty&&this.setRotationByQuat(t)},t.prototype.getQuat=function(){var t=this.options.quat;if(void 0===t){t=new Lt;var e=this.options.rotation;e&&t.setFromEuler(e),this.options.quat=t}return t},t.prototype.getOptions=function(){return this.options},t.prototype.copy=function(t){var e=t.near,r=t.far,i=t.fov,n=t.clipMode,o=t.aspect,s=t.position,a=t.rotation;this.near=e,this.far=r,this.fov=i,this.clipMode=n,this.aspect=o,this.position=s,this.rotation=a,this.updateMatrix()},t.prototype.updateMatrix=function(){if(this.dirty){var t=this.options,e=t.fov,r=t.aspect,i=t.near,n=t.far,o=t.clipMode,s=t.position;this.projectionMatrix.perspective(e*St,r,i,n,o===it.portrait),this.inverseViewMatrix.compose(s,this.getQuat(),Ys),this.viewMatrix.copyFrom(this.inverseViewMatrix).invert(),this.viewProjectionMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),this.inverseViewProjectionMatrix=null,this.dirty=!1}},t.prototype.setRotationByQuat=function(t){Ke.getRotation(t,this.options.rotation)},t}();var Ws,Zs,qs,Ks,Qs,Js,$s,ta,ea,ra,ia,na={lum:[function(e,r){var i=r.renderer,n=2===i.engine.gpuCapability.level?v.LINEAR:v.NEAREST,o=new Ds(i,{name:"lumCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:n,magFilter:n}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{fragment:Kr,uniformValues:{uFilterParams:[1,0,0,0]},materialStates:{blending:!1,depthTest:!1,culling:!1}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}]},prePasses:[o],renderPassDelegate:{}}},function(){return[{fragment:Kr}]}],alphaFrame:[function(e,r){var i=e,n=i.colorRange,o=void 0===n?[.5,1]:n,s=i.alphaRange,a=void 0===s?[0,.5]:s,u=[a[0],a[1]-a[0],o[0],o[1]-o[0]],l=r.renderer,c=2===l.engine.gpuCapability.level?v.LINEAR:v.NEAREST,h=new Ds(l,{name:"alphaFrameCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:c,magFilter:c}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{particle:{fragment:Mi,uniformValues:{uTexRange:u}},mesh:{fragment:Mi,shaderCacheId:"alpha-frame",materialStates:{blending:!1},uniformValues:{uTexRange:u}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[h]}}},function(){return[{fragment:Mi,shaderCacheId:"alpha-frame"},{fragment:Mi,isParticle:!0}]}],cameraMove:[function(e,r){var i=e.position,n=void 0===i?[0,0,0]:i,o=n;Number.isFinite(n[0])&&Number.isFinite(n[1])&&(o=[ot.CONSTANT_VEC3,n]);var s=be(o),a=new js("camera_move"),u=new Mt,l=r.renderer,c=2===l.engine.gpuCapability.level?v.LINEAR:v.NEAREST,h=new Ds(l,{name:"cameraCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:c,magFilter:c}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{vertex:Ii,fragment:Kr,shaderCacheId:"camera-move",materialStates:{blending:!1,depthTest:!1,culling:!1},variables:{uMoveCameraViewPro:function(t){a.copy(r.camera);var e=s.getValue(t);return u.addVectors(r.camera.position,new Mt(-e[0],-e[1],-e[2])),a.position=u,a.getViewProjectionMatrix().toArray()}}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[h]}}},function(){return[{vertex:Ii,fragment:Kr,shaderCacheId:"camera-move"}]}],alphaMask:[function(e,r){var i=e,n=i.xOpacity,o=i.yOpacity,s=r.renderer.engine,a=r.renderer,u=Hs(s,n),l=Hs(s,o,!0),c=2===s.gpuCapability.level?v.LINEAR:v.NEAREST,h=new Ds(a,{name:"alphaMaskCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:c,magFilter:c}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{fragment:Li,shaderCacheId:"alpha-mask",materialStates:{blending:!1,depthTest:!1,culling:!1},uniformValues:{uAlphaXSample:u,uAlphaYSample:l}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[h]}}},function(){return[{fragment:Li,shaderCacheId:"alpha-mask"}]}],distortion:[function(e,r){var i=e,n=i.center,o=void 0===n?[.5,.5]:n,s=i.direction,a=void 0===s?[1,0]:s,u=i.period,l=i.waveMovement,c=i.strength,h=re(a),f=[o[0],o[1],h[0],h[1]],p=be(u),d=be(l),m=be(c),y=2*Math.PI,g=r.renderer,x=2===g.engine.gpuCapability.level?v.LINEAR:v.NEAREST,T=new Ds(g,{name:"distortionCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:x,magFilter:x}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{particle:{fragment:Fi,vertex:Ni,uniforms:{uPeriodValue:p,uMovementValue:d,uStrengthValue:m},uniformValues:{uWaveParams:f}},mesh:{shaderCacheId:"distortion",fragment:Fi,materialStates:{blending:!1,culling:!1},variables:{vWaveParams:function(t){return[p.getValue(t)*y,d.getValue(t)*y,m.getValue(t),0]}},uniformValues:{uWaveParams:f}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[T]}}},function(t){var e=t,r=e.period,i=e.waveMovement,n=e.strength;return[{fragment:Fi,shaderCacheId:"distortion"},{fragment:Fi,vertex:Ni,isParticle:!0,uniforms:[r,i,n]}]}],bloom:[function(e,r){var i=e,n=i.radius,o=void 0===n?30:n,s=i.bloomAddon,a=void 0===s?.4:s,u=i.colorAddon,l=void 0===u?1:u,c=i.colorThreshold,h=void 0===c?[255,255,255]:c,f=r.getEngine().gpuCapability.level,p=zs({radius:o}),d=r.renderer.engine,m=r.renderer,y=Math.round(r.width/p.downSample),g=Math.round(r.width/p.downSample);1===f&&(y=ae(y),g=ae(g));var x=[0,0,y,g],T=r.renderFrame.passTextureCache.requestColorAttachmentTexture({format:v.RGBA,magFilter:v.LINEAR,minFilter:v.LINEAR,name:"gaussianV",width:y,height:g}),E=r.renderFrame.passTextureCache.requestColorAttachmentTexture({format:v.RGBA,magFilter:v.LINEAR,minFilter:v.LINEAR,name:"gaussianH",width:y,height:g}),S=be(a),b=be(l),A=new Ei(d),_=new Us(m,{name:"threshold",attachments:[{texture:T}],viewport:x,clearAction:{colorAction:t.TextureLoadAction.clear}});_.pluginSystem=r.pluginSystem,_.fragShader=Di,_.preDefaultPassAttachment=A;var C=new ks(m,"H",new wt(p.step,0),r.pluginSystem,p.shader,{name:"gaussianH",viewport:x,attachments:[{texture:E}],clearAction:{colorAction:t.TextureLoadAction.clear}},T);C.preDefaultPassAttachment=A;var R=new ks(m,"V",new wt(0,p.step),r.pluginSystem,p.shader,{name:"gaussianV",viewport:x,attachments:[{texture:T}]},E);R.preDefaultPassAttachment=A;var O=2===f?v.LINEAR:v.NEAREST,w=new Gs(m,{name:"bloomCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:O,magFilter:O}}],clearAction:{colorAction:t.TextureLoadAction.clear}},A);return{mesh:{name:"bloom-".concat(p.step),fragment:Vi,shaderCacheId:"bloom-".concat(p.step),variables:{uBloomParams:function(t){return[S.getValue(t),b.getValue(t),0,1]}},uniformValues:{uColorThreshold:[h[0]/255||1.1,h[1]/255||1.1,h[2]/255||1.1,0],uBloomBlur:T},materialStates:{blending:!1,culling:!1}},onItemRemoved:function(){T.dispose(),E.dispose()},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[_,C,R,w]}}},function(t){var e=t.radius,r=zs({radius:void 0===e?30:e});return[{fragment:Vi,shaderCacheId:"bloom-".concat(r.step)},{fragment:Di,ignoreBlend:!0},{fragment:r.shader,ignoreBlend:!0}]}],gaussian:[function(e,r){var i=e.radius,n=r.getEngine().gpuCapability.level,o=r.renderer.engine,s=r.renderer,a=zs({radius:i}),u=a.downSample,l=a.step,c=a.shader,h=Math.round(r.width/u),f=Math.round(r.height/u);1===n&&(f=ae(f),h=ae(h));var p=[0,0,h,f],d=r.renderFrame.passTextureCache.requestColorAttachmentTexture({minFilter:v.LINEAR,magFilter:v.LINEAR,name:"gaussianV",width:h,height:f}),m=r.renderFrame.passTextureCache.requestColorAttachmentTexture({minFilter:v.LINEAR,magFilter:v.LINEAR,name:"gaussianH",width:h,height:f}),y=new Ei(o,{}),g=new Vs(s,"H",new wt(0,l),r.pluginSystem,c,{name:"gaussianH",viewport:p,attachments:[{texture:m}],clearAction:{colorAction:t.TextureLoadAction.clear}});g.preDefaultPassAttachment=y;var x=new Vs(s,"V",new wt(l,0),r.pluginSystem,c,{name:"gaussianV",viewport:p,attachments:[{texture:d}],clearAction:{colorAction:t.TextureLoadAction.clear}});x.preDefaultPassAttachment=y;var T=2===n?v.LINEAR:v.NEAREST,E=new Ds(s,{name:"gaussianCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:T,magFilter:T}}],clearAction:{colorAction:t.TextureLoadAction.clear}},y);return E.preDefaultPassAttachment=y,{mesh:{fragment:Kr,shaderCacheId:"gaussian-".concat(l),uniformValues:{uTexSize:[h,f]},materialStates:{blending:!1,culling:!1}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[g,x,E]}}},function(t){var e=zs({radius:t.radius});return[{fragment:Kr,shaderCacheId:"gaussian-".concat(e.step)},{fragment:e.shader,ignoreBlend:!0}]}],delay:[function(e,r){var i=r.renderer,n=Vr.create(i.engine,{sourceType:t.TextureSourceType.framebuffer}),o=[0,.96,0,0],s=2===i.engine.gpuCapability.level?v.LINEAR:v.NEAREST,a=new Xs(i,{name:"delayCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:s,magFilter:s}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{fragment:Pi,shaderCacheId:"delay",uniformValues:{uLastSource:n},variables:{uParams:function(){return o}},materialStates:{blending:!0,blendFunction:[v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA,v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA],depthTest:!1,culling:!1}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[a]},onItemRemoved:function(){n.dispose()},renderPassDelegate:{didEndRenderPass:function(t){i.extension.copyTexture(t.attachments[0].texture,n),o[0]=2}}}},function(){return[{fragment:Pi,shaderCacheId:"delay"}]}]};
|
|
8
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ge={})}(this,(function(t){"use strict";var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},e(t,r)};function r(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}var i=function(){return i=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},i.apply(this,arguments)};function n(t,e,r,i){return new(r||(r=Promise))((function(n,o){function s(t){try{u(i.next(t))}catch(t){o(t)}}function a(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){t.done?n(t.value):function(t){return t instanceof r?t:new r((function(e){e(t)}))}(t.value).then(s,a)}u((i=i.apply(t,e||[])).next())}))}function o(t,e){var r,i,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){s.label=a[1];break}if(6===a[0]&&s.label<n[1]){s.label=n[1],n=a;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(a);break}n[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],i=0}finally{r=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}function u(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var l=6,c="editor",h="none",f={"Filter not imported":"https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg","Item duration can't be less than 0":"https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg"};function p(t,e,r){var i;if(void 0===e&&(e="webgl"),"webgl2"===e&&((i=t.getContext("webgl2",r))||console.debug("WebGL2 context retrieval failed, falling back to WebGL context.")),i&&"webgl"!==e||(i=t.getContext("webgl",r)),!i)throw new Error("This browser does not support WebGL or the WebGL version is incorrect. Please check your WebGL version.");return i}function d(t){var e=this,r=t.getExtension("EXT_disjoint_timer_query_webgl2");if(r){var i=t.createQuery(),s=function(){return n(e,void 0,void 0,(function(){return o(this,(function(e){return[2,new Promise((function(e,n){if(i){var o=t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE),a=t.getParameter(r.GPU_DISJOINT_EXT);if(o&&!a){var u=t.getQueryParameter(i,t.QUERY_RESULT);e(u/1e3/1e3)}(o||a)&&(t.deleteQuery(i),i=null),null!==o&&i&&window.setTimeout((function(){s().then(e).catch}),1)}}))]}))}))};if(!i)return;return{begin:function(){i&&t.beginQuery(r.TIME_ELAPSED_EXT,i)},end:function(){t.endQuery(r.TIME_ELAPSED_EXT)},getTime:s}}}var m=[],v={};function y(){"function"==typeof WebGL2RenderingContext?x(WebGL2RenderingContext):"undefined"!=typeof WebGLRenderingContext?(x(WebGLRenderingContext),x(WebGLRenderingContext.prototype)):m.push("iOS16 lockdown mode, WebGL Constants not in global"),m.length||"HALF_FLOAT"in v||(v.HALF_FLOAT=5131)}function g(t){return"undefined"!=typeof WebGL2RenderingContext&&"WebGL2RenderingContext"===t.constructor.name}function x(t){for(var e in t)/^[A-Z_]/.test(e)&&(v[e]=t[e])}m.length||y();var T,E,S,b,A,_,C,R,O,w,M,L,I={},P={};function F(t,e,r){t in I&&console.error("Filter ".concat(t," registered twice.")),I[t]=e,P[t]=r}function N(t){Object.keys(t).forEach((function(e){var r=a(t[e],2);F(e,r[0],r[1])}))}function V(t){var e=P[t.name];if(!e)throw Error("Filter ".concat(t.name," not imported, see ").concat(f["Filter not imported"]));return e(t)}function D(t,e){var r=I[t.name];if(!r)throw Error("Filter ".concat(t.name," not imported, see ").concat(f["Filter not imported"]));var i=r(t,e);return i.passSplitOptions||(i.passSplitOptions={attachments:[{texture:{format:v.RGBA}}]}),i}function z(t,e){return t.includes(e)||t.push(e),t}function B(t,e){var r=t.indexOf(e);return r>-1&&t.splice(r,1),t}function U(t,e,r,i){if(void 0===i&&(i=!1),!t.includes(e)&&(t.push(e),1!==t.length)){var n=t.length-1;if(n){var o=t[n];if(i)for(;t[n-1][r]<o[r]&&(t[n]=t[n-1],0!=--n););else for(;t[n-1][r]>o[r]&&(t[n]=t[n-1],0!=--n););t[n]=o}}}function k(t,e,r,i){if(void 0===r&&(r=1),t.buffer.byteLength<t.BYTES_PER_ELEMENT*e){var n=Math.ceil(e*r);isNaN(i)||(n=Math.min(n,i));var o=new ArrayBuffer(t.BYTES_PER_ELEMENT*n),s=new t.constructor(o);return s.set(t),s}return t}function G(t,e){var r=[0,0,0,0];if(ke(t)){t=t.replace(/[\s\t\r\n]/g,"");var i=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(i){var n=+i[4];r=[+i[1],+i[2],+i[3],isNaN(n)?255:255*n]}else/^#[a-f\d]{3}$/i.test(t)?r=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(r=[parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16),255]||[0,0,0,255])}else t instanceof Array&&(r=[t[0],t[1],t[2],isNaN(t[3])?255:t[3]]);if(e)for(var o=0;o<4;o++)r[o]/=255;return r}function X(t,e,r){if(t.length){for(var i=void 0,n=1;n<=t.length-1;n++){var o=t[n-1],s=t[n];if(o.stop<=e&&e<=s.stop){i=Y(o.color,s.color,(e-o.stop)/(s.stop-o.stop));break}}return i||(i=t[t.length-1].color),r?i.map((function(t){return t/255})):i}return[0,0,0,0]}function H(t){var e=[];if(t instanceof Array?t.forEach((function(t){var r=a(t,5),i=r[0],n=r[1],o=r[2],s=r[3],u=r[4];e.push({stop:j(i),color:[n,o,s,u]})})):Object.keys(t).forEach((function(r){var i=G(t[r]);e.push({stop:j(r),color:i})})),(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 r=e[e.length-1];1!==r.stop&&e.push({stop:1,color:r.color.slice()})}return e}function Y(t,e,r,i){var n=[],o=1-r;if(i)for(var s=0;s<4;s++)n[s]=t[s]*o+e[s]*r;else{for(s=0;s<3;s++)n[s]=Math.round(Math.sqrt(t[s]*t[s]*o+e[s]*e[s]*r));n[3]=Math.round(t[3]*o+e[3]*r)}return n}function j(t){var e=/^(-)?([\d+.]+)%$/.exec(t);return e?+e[2]/100*(e[1]?-1:1):+t}function W(){if("object"==typeof screen&&"object"==typeof document){var t=Math.max(document.documentElement.clientWidth,window.innerWidth||0),e=screen.width/t;return Math.min(2*e,2)}return 1}function Z(){return/\b[Aa]ndroid\b/.test(navigator.userAgent)}function q(){return Z()||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent)}function K(t){ke(t)&&(t=G(t));for(var e=t,r={width:1,height:1,data:new Uint8Array(4)},i=r.data,n=0;n<4;n++)i[n]=e[n];return r}function Q(t){var e=128,r={width:e,height:1,data:new Uint8Array(512)},i=r.data,n=H(t);if(n.length){i.set(n[0].color,0);for(var o=1;o<127;o++){for(var s=o/e,a=void 0,u=void 0,l=0;l<n.length&&(a=n[l],u=n[l+1],!(a.stop<=s&&u.stop>s));l++);var c=Y(a.color,u.color,(s-a.stop)/(u.stop-a.stop));i.set(c,4*o)}i.set(n[n.length-1].color,508)}return r}function J(e,r){void 0===r&&(r=t.OrderType.ascending);var i=e.length;if(i<=1||r===t.OrderType.none)return e;if(i<=30){for(var n=1;n<i;n++)tt(e,n,r);return e}return et(e,r)}function $(e,r,i){return void 0===i&&(i=t.OrderType.ascending),e.includes(r)?e:(e.push(r),1===e.length||i!==t.OrderType.none&&tt(e,e.length-1,i),e)}function tt(e,r,i){var n=e[r];if(i!==t.OrderType.ascending)for(;r>=1&&e[r-1].priority<n.priority&&(e[r]=e[r-1],0!=--r););else for(;r>=1&&e[r-1].priority>n.priority&&(e[r]=e[r-1],0!=--r););e[r]=n}function et(e,r,i,n){var o,s;if(void 0===i&&(i=0),void 0===n&&(n=e.length-1),i>=n)return e;for(var u=e[i],l=i,c=n;l<c;){if(r===t.OrderType.ascending){for(;e[c].priority>u.priority&&c>=l;)c--;for(;e[l].priority<=u.priority&&l<c;)l++}else{for(;e[c].priority<u.priority&&c>=l;)c--;for(;e[l].priority>=u.priority&&l<c;)l++}o=a([e[c],e[l]],2),e[l]=o[0],e[c]=o[1]}return s=a([e[l],e[i]],2),e[i]=s[0],e[l]=s[1],et(e,r,i,l-1),et(e,r,c+1,n),e}function rt(t,e){if(void 0===e&&(e="item doesn't exist"),null==t)throw new Error(e)}t.OrderType=void 0,(T=t.OrderType||(t.OrderType={}))[T.none=1]="none",T[T.ascending=2]="ascending",T[T.descending=3]="descending",function(t){t.S="S",t.APlus="A+",t.A="A",t.BPlus="B+",t.B="B"}(E||(E={})),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"}(S||(S={})),function(t){t[t.DOUBLE=1032]="DOUBLE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK"}(b||(b={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(A||(A={})),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"}(_||(_={})),function(t){t[t.GYROSCOPE=0]="GYROSCOPE",t[t.SPINE=1]="SPINE"}(C||(C={})),function(t){t[t.CLICK=0]="CLICK",t[t.MESSAGE=1]="MESSAGE",t[t.DRAG=2]="DRAG"}(R||(R={})),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"}(O||(O={})),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.filter="8",t.spine="spine",t.mesh="mesh",t.tree="tree",t.text="text",t.light="light",t.skybox="skybox"}(w||(w={})),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"}(M||(M={})),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"}(L||(L={}));var it,nt,ot,st,at,ut,lt,ct;!function(t){t[t.portrait=1]="portrait",t[t.landscape=0]="landscape"}(it||(it={})),function(t){t[t.destroy=0]="destroy",t[t.pause=1]="pause",t[t.restart=5]="restart",t[t.forward=2]="forward",t[t.pause_destroy=3]="pause_destroy"}(nt||(nt={})),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"}(ot||(ot={})),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"}(st||(st={})),function(t){t[t.destroy=0]="destroy",t[t.loop=5]="loop",t[t.freeze=4]="freeze"}(at||(at={})),function(t){t[t.destroyChildren=6]="destroyChildren"}(ut||(ut={})),function(t){t[t.none=0]="none",t[t.removeParticle=1]="removeParticle"}(lt||(lt={})),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"}(ct||(ct={}));var ht,ft,pt,dt,mt,vt,yt,gt,xt;!function(t){t[t.box=2]="box",t[t.sphere=3]="sphere"}(ht||(ht={})),function(t){t.unlit="unlit",t.pbr="pbr",t.hair="hair"}(ft||(ft={})),function(t){t[t.opaque=100]="opaque",t[t.masked=101]="masked",t[t.translucent=102]="translucent",t[t.additive=103]="additive"}(pt||(pt={})),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"}(dt||(dt={})),function(t){t[t.display=0]="display",t[t.clip=1]="clip",t[t.ellipsis=2]="ellipsis"}(mt||(mt={})),function(t){t[t.top=0]="top",t[t.middle=1]="middle",t[t.bottom=2]="bottom"}(vt||(vt={})),function(t){t[t.left=0]="left",t[t.middle=1]="middle",t[t.right=2]="right"}(yt||(yt={})),function(t){t.normal="normal",t.bold="bold",t.lighter="lighter"}(gt||(gt={})),function(t){t.normal="normal",t.italic="italic",t.oblique="oblique"}(xt||(xt={}));var Tt=Object.freeze({__proto__:null,get BezierKeyframeType(){return st},get BlendingMode(){return S},BloomFilterThresholdAvgColor:0,CAMERA_CLIP_MODE_NORMAL:0,CAMERA_CLIP_MODE_VERTICAL:1,get CameraClipMode(){return it},get CompositionEndBehavior(){return nt},END_BEHAVIOR_DESTROY:0,END_BEHAVIOR_DESTROY_CHILDREN:6,END_BEHAVIOR_FORWARD:2,END_BEHAVIOR_FREEZE:4,END_BEHAVIOR_PAUSE:1,END_BEHAVIOR_PAUSE_AND_DESTROY:3,END_BEHAVIOR_RESTART:5,get FontStyle(){return xt},get InteractBehavior(){return O},get InteractType(){return R},get ItemEndBehavior(){return at},get ItemType(){return w},MESSAGE_ITEM_PHRASE_BEGIN:2,MESSAGE_ITEM_PHRASE_END:1,get MaskMode(){return A},get MaterialBlending(){return pt},get MaterialType(){return ft},get ModelBoundingType(){return ht},get ParentItemEndBehavior(){return ut},get ParticleInteractionBehavior(){return lt},get ParticleOrigin(){return L},get PluginType(){return C},get RenderLevel(){return E},get RenderMode(){return M},get RenderMode3D(){return dt},get ShapeArcMode(){return ct},get ShapeType(){return _},get SideMode(){return b},get TextAlignment(){return yt},get TextBaseline(){return vt},get TextOverflow(){return mt},get TextWeight(){return gt},get ValueType(){return ot}}),Et=2*Math.PI,St=Math.PI/180,bt=180/Math.PI,At=1e-6;function _t(t,e){return Math.abs(t-e)<At||t===1/0&&e===1/0||t===-1/0&&e===-1/0}var Ct=function(t,e,r){return(1-r)*t+r*e};function Rt(t,e,r){var i=isNaN(e)?-1/0:e,n=isNaN(r)?1/0:r,o=Math.min(i,n),s=Math.max(i,n);return Math.min(Math.max(t,o),s)}var Ot,wt=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.set=function(t,e){return this.x=t,this.y=e,this},t.prototype.setZero=function(){return this.x=0,this.y=0,this},t.prototype.setFromNumber=function(t){return this.x=t,this.y=t,this},t.prototype.setFromArray=function(t,e){var r,i;return void 0===e&&(e=0),this.x=null!==(r=t[e])&&void 0!==r?r:0,this.y=null!==(i=t[e+1])&&void 0!==i?i:0,this},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t):t instanceof Array?(this.x+=t[0],this.y+=t[1]):(this.x+=t.x,this.y+=t.y),this},t.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},t.prototype.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t):t instanceof Array?(this.x-=t[0],this.y-=t[1]):(this.x-=t.x,this.y-=t.y),this},t.prototype.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},t.prototype.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t):t instanceof Array?(this.x*=t[0],this.y*=t[1]):(this.x*=t.x,this.y*=t.y),this},t.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this},t.prototype.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t):t instanceof Array?(this.x/=t[0],this.y/=t[1]):(this.x/=t.x,this.y/=t.y),this},t.prototype.scale=function(t){return this.x*=t,this.y*=t,this},t.prototype.sum=function(){return this.x+this.y},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},t.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},t.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},t.prototype.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},t.prototype.normalize=function(){return this.divide(this.length()||1)},t.prototype.setLength=function(t){return this.normalize().multiply(t)},t.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},t.prototype.lerpVectors=function(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y},t.prototype.cross=function(t){return this.x*t.y-this.y*t.x},t.prototype.distance=function(t){var e=this.x-t.x,r=this.y-t.y;return Math.sqrt(e*e+r*r)},t.prototype.distanceSquared=function(t){var e=this.x-t.x,r=this.y-t.y;return e*e+r*r},t.prototype.equals=function(t){return this.x===t.x&&this.y===t.y},t.prototype.isZero=function(){var t=At,e=(this,this.x),r=this.y;return Math.abs(e)<=t&&Math.abs(r)<=t},t.prototype.toArray=function(){return[this.x,this.y]},t.prototype.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y},t.prototype.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,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.ONE=new t(1,1),t.ZERO=new t(0,0),t}(),Mt=function(){function t(t,e,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),this.x=t,this.y=e,this.z=r}return t.prototype.set=function(t,e,r){return this.x=t,this.y=e,this.z=r,this},t.prototype.setZero=function(){return this.x=0,this.y=0,this.z=0,this},t.prototype.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this},t.prototype.setFromArray=function(t,e){var r,i,n;return void 0===e&&(e=0),this.x=null!==(r=t[e])&&void 0!==r?r:0,this.y=null!==(i=t[e+1])&&void 0!==i?i:0,this.z=null!==(n=t[e+2])&&void 0!==n?n:0,this},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t):t instanceof 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},t.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},t.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},t.prototype.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t):t instanceof 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},t.prototype.subtractVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},t.prototype.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t):t instanceof 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},t.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},t.prototype.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t):t instanceof 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},t.prototype.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this},t.prototype.sum=function(){return this.x+this.y+this.z},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},t.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},t.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},t.prototype.abs=function(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},t.prototype.normalize=function(){return this.divide(this.length()||1)},t.prototype.setLength=function(t){return this.normalize().multiply(t)},t.prototype.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},t.prototype.lerpVectors=function(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},t.prototype.cross=function(t){return this.crossVectors(this,t)},t.prototype.crossVectors=function(t,e){var r=t.x,i=t.y,n=t.z,o=e.x,s=e.y,a=e.z;return this.x=i*a-n*s,this.y=n*o-r*a,this.z=r*s-i*o,this},t.prototype.reflect=function(t){return this.subtract(t.clone().multiply(2*this.dot(t)))},t.prototype.distance=function(t){return Math.sqrt(this.distanceSquared(t))},t.prototype.distanceSquared=function(t){var e=this.x-t.x,r=this.y-t.y,i=this.z-t.z;return e*e+r*r+i*i},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},t.prototype.isZero=function(){var t,e=At,r=(t=this).x,i=t.y,n=t.z;return Math.abs(r)<=e&&Math.abs(i)<=e&&Math.abs(n)<=e},t.prototype.toArray=function(){return[this.x,this.y,this.z]},t.prototype.toVector2=function(){return new wt(this.x,this.y)},t.prototype.fill=function(t,e){void 0===e&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z},t.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},t.prototype.applyEuler=function(t,e){return t.rotateVector3(this,e)},t.prototype.applyQuaternion=function(t,e){return t.rotateVector3(this,e)},t.prototype.applyMatrix=function(t,e){return t.transformPoint(this,e)},t.prototype.applyNormalMatrix=function(t,e){return t.transformNormal(this,e)},t.prototype.applyProjectionMatrix=function(t,e){return t.projectPoint(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.X=new t(1,0,0),t.Y=new t(0,1,0),t.Z=new t(0,0,1),t.ONE=new t(1,1,1),t.ZERO=new t(0,0,0),t}(),Lt=function(){function t(t,e,r,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=1),this.x=t,this.y=e,this.z=r,this.w=i}return t.prototype.set=function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},t.prototype.setFromEuler=function(t){return t.toQuaternion(this),this},t.prototype.setFromAxisAngle=function(e,r){var i=r/2,n=Math.sin(i),o=t.tempVec0;return o.copyFrom(e).normalize(),this.x=o.x*n,this.y=o.y*n,this.z=o.z*n,this.w=Math.cos(i),this},t.prototype.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},t.prototype.setFromRotationMatrix=function(t){var e=t.elements,r=e[0],i=e[4],n=e[8],o=e[1],s=e[5],a=e[9],u=e[2],l=e[6],c=e[10],h=r+s+c;if(h>0){var f=.5/Math.sqrt(h+1);this.w=.25/f,this.x=(l-a)*f,this.y=(n-u)*f,this.z=(o-i)*f}else if(r>s&&r>c){f=2*Math.sqrt(1+r-s-c);this.w=(l-a)/f,this.x=.25*f,this.y=(i+o)/f,this.z=(n+u)/f,this.negate()}else if(s>c){f=2*Math.sqrt(1+s-r-c);this.w=(n-u)/f,this.x=(i+o)/f,this.y=.25*f,this.z=(a+l)/f,this.negate()}else{f=2*Math.sqrt(1+c-r-s);this.w=(o-i)/f,this.x=(n+u)/f,this.y=(a+l)/f,this.z=.25*f,this.negate()}return this},t.prototype.setFromUnitVectors=function(t,e){var r=t.dot(e)+1;return r<Number.EPSILON?(r=0,Math.abs(t.x)>Math.abs(t.z)?(this.x=-t.y,this.y=t.x,this.z=0,this.w=r):(this.x=0,this.y=-t.z,this.z=t.y,this.w=r)):(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=r),this.normalize()},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.angleTo=function(t){return 2*Math.acos(Math.abs(Rt(this.dot(t),-1,1)))},t.prototype.rotateTowards=function(t,e){var r=this.angleTo(t);if(0===r)return this;var i=Math.min(1,e/r);return this.slerp(t,i),this},t.prototype.identity=function(){return this.set(0,0,0,1)},t.prototype.invert=function(){return this.conjugate()},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},t.prototype.conjugate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.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},t.prototype.multiply=function(t){return this.multiplyQuaternions(this,t)},t.prototype.premultiply=function(t){return this.multiplyQuaternions(t,this)},t.prototype.multiplyQuaternions=function(t,e){var r=t.x,i=t.y,n=t.z,o=t.w,s=e.x,a=e.y,u=e.z,l=e.w;return this.x=r*l+o*s+i*u-n*a,this.y=i*l+o*a+n*s-r*u,this.z=n*l+o*u+r*a-i*s,this.w=o*l-r*s-i*a-n*u,this},t.prototype.slerp=function(t,e){var r;if(0===e)return this;if(1===e)return this.copyFrom(t);var i=(r=this).x,n=r.y,o=r.z,s=r.w,a=s*t.w+i*t.x+n*t.y+o*t.z;if(a<0?(this.w=-t.w,this.x=-t.x,this.y=-t.y,this.z=-t.z,a=-a):this.copyFrom(t),a>=1)return this.w=s,this.x=i,this.y=n,this.z=o,this;var u=1-a*a;if(u<=Number.EPSILON){var l=1-e;return this.w=l*s+e*this.w,this.x=l*i+e*this.x,this.y=l*n+e*this.y,this.z=l*o+e*this.z,this.normalize(),this}var c=Math.sqrt(u),h=Math.atan2(c,a),f=Math.sin((1-e)*h)/c,p=Math.sin(e*h)/c;return this.w=s*f+this.w*p,this.x=i*f+this.x*p,this.y=n*f+this.y*p,this.z=o*f+this.z*p,this},t.prototype.slerpQuaternions=function(t,e,r){this.copyFrom(t).slerp(e,r)},t.prototype.rotateVector3=function(t,e){var r,i=(r=this).x,n=r.y,o=r.z,s=r.w,a=t.x,u=t.y,l=t.z,c=s*a+n*l-o*u,h=s*u+o*a-i*l,f=s*l+i*u-n*a,p=-i*a-n*u-o*l,d=null!=e?e:t;return d.x=c*s+p*-i+h*-o-f*-n,d.y=h*s+p*-n+f*-i-c*-o,d.z=f*s+p*-o+c*-n-h*-i,d},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},t.prototype.toArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.toVector4=function(t){return t.set(this.x,this.y,this.z,this.w)},t.prototype.toEuler=function(t){return t.setFromQuaternion(this)},t.prototype.toMatrix4=function(t){return t.compose(Mt.ZERO,this,Mt.ONE)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromAxisAngle=function(e,r){return(new t).setFromAxisAngle(e,r)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromRotationMatrix=function(e){return(new t).setFromRotationMatrix(e)},t.fromUnitVectors=function(e,r){return(new t).setFromUnitVectors(e,r)},t.tempVec0=new Mt,t}(),It=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},Pt=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},Ft=function(){function t(t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m){void 0===t&&(t=1),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=1),void 0===s&&(s=0),void 0===a&&(a=0),void 0===u&&(u=0),void 0===l&&(l=0),void 0===c&&(c=1),void 0===h&&(h=0),void 0===f&&(f=0),void 0===p&&(p=0),void 0===d&&(d=0),void 0===m&&(m=1),this.elements=[t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m]}return t.prototype.set=function(t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m){var v=this.elements;return v[0]=t,v[1]=e,v[2]=r,v[3]=i,v[4]=n,v[5]=o,v[6]=s,v[7]=a,v[8]=u,v[9]=l,v[10]=c,v[11]=h,v[12]=f,v[13]=p,v[14]=d,v[15]=m,this},t.prototype.setFromRowMajorData=function(t,e,r,i,n,o,s,a,u,l,c,h,f,p,d,m){var v=this.elements;return v[0]=t,v[4]=e,v[8]=r,v[12]=i,v[1]=n,v[5]=o,v[9]=s,v[13]=a,v[2]=u,v[6]=l,v[10]=c,v[14]=h,v[3]=f,v[7]=p,v[11]=d,v[15]=m,this},t.prototype.setFromColumnVectors=function(t,e,r,i){return this.set(t.x,t.y,t.z,t.w,e.x,e.y,e.z,e.w,r.x,r.y,r.z,r.w,i.x,i.y,i.z,i.w)},t.prototype.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},t.prototype.setFromArray=function(t,e){void 0===e&&(e=0);for(var r=0;r<16;r++)this.elements[r]=t[e+r];return this},t.prototype.setFromScale=function(t,e,r){return this.set(t,0,0,0,0,e,0,0,0,0,r,0,0,0,0,1)},t.prototype.setFromTranslation=function(t,e,r){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,t,e,r,1)},t.prototype.setFromRotationX=function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(1,0,0,0,0,e,r,0,0,-r,e,0,0,0,0,1)},t.prototype.setFromRotationY=function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,0,-r,0,0,1,0,0,r,0,e,0,0,0,0,1)},t.prototype.setFromRotationZ=function(t){var e=Math.cos(t),r=Math.sin(t);return this.set(e,r,0,0,-r,e,0,0,0,0,1,0,0,0,0,1)},t.prototype.setFromRotationAxis=function(e,r){var i=t.tempVec0;i.copyFrom(e).normalize();var n=Math.cos(r),o=Math.sin(r),s=1-n,a=i.x,u=i.y,l=i.z,c=s*a,h=s*u;return this.set(c*a+n,c*u+o*l,c*l-o*u,0,c*u-o*l,h*u+n,h*l+o*a,0,c*l+o*u,h*l-o*a,s*l*l+n,0,0,0,0,1)},t.prototype.setFromEuler=function(t){return t.toMatrix4(this),this},t.prototype.setFromQuaternion=function(t){return this.compose(Mt.ZERO,t,Mt.ONE)},t.prototype.setFromShear=function(t,e,r){return this.set(1,t,t,0,e,1,e,0,r,r,1,0,0,0,0,1)},t.prototype.setFromBasis=function(t,e,r){return this.set(t.x,t.y,t.z,0,e.x,e.y,e.z,0,r.x,r.y,r.z,0,0,0,0,1)},t.prototype.setZero=function(){for(var t=0;t<16;t++)this.elements[t]=0;return this},t.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.prototype.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]},t.prototype.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])},t.prototype.copyFrom=function(t){return this.elements=Pt([],It(t.elements),!1),this},t.prototype.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])},t.prototype.lookAt=function(e,r,i){var n=t.tempVec0,o=t.tempVec1,s=t.tempVec2;s.subtractVectors(e,r),s.normalize(),n.crossVectors(i,s),n.normalize(),o.crossVectors(s,n);var a=this.elements;return a[0]=n.x,a[1]=o.x,a[2]=s.x,a[3]=0,a[4]=n.y,a[5]=o.y,a[6]=s.y,a[7]=0,a[8]=n.z,a[9]=o.z,a[10]=s.z,a[11]=0,a[12]=-n.dot(e),a[13]=-o.dot(e),a[14]=-s.dot(e),a[15]=1,this},t.prototype.addScaledMatrix=function(t,e){for(var r=this.elements,i=t.elements,n=0;n<16;n++)r[n]+=i[n]*e;return this},t.prototype.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)},t.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},t.prototype.multiplyMatrices=function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],s=r[4],a=r[8],u=r[12],l=r[1],c=r[5],h=r[9],f=r[13],p=r[2],d=r[6],m=r[10],v=r[14],y=r[3],g=r[7],x=r[11],T=r[15],E=i[0],S=i[4],b=i[8],A=i[12],_=i[1],C=i[5],R=i[9],O=i[13],w=i[2],M=i[6],L=i[10],I=i[14],P=i[3],F=i[7],N=i[11],V=i[15];return n[0]=o*E+s*_+a*w+u*P,n[4]=o*S+s*C+a*M+u*F,n[8]=o*b+s*R+a*L+u*N,n[12]=o*A+s*O+a*I+u*V,n[1]=l*E+c*_+h*w+f*P,n[5]=l*S+c*C+h*M+f*F,n[9]=l*b+c*R+h*L+f*N,n[13]=l*A+c*O+h*I+f*V,n[2]=p*E+d*_+m*w+v*P,n[6]=p*S+d*C+m*M+v*F,n[10]=p*b+d*R+m*L+v*N,n[14]=p*A+d*O+m*I+v*V,n[3]=y*E+g*_+x*w+T*P,n[7]=y*S+g*C+x*M+T*F,n[11]=y*b+g*R+x*L+T*N,n[15]=y*A+g*O+x*I+T*V,this},t.prototype.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},t.prototype.determinant=function(){var t=this.elements,e=t[0],r=t[4],i=t[8],n=t[12],o=t[1],s=t[5],a=t[9],u=t[13],l=t[2],c=t[6],h=t[10],f=t[14];return t[3]*(+n*a*c-i*u*c-n*s*h+r*u*h+i*s*f-r*a*f)+t[7]*(+e*a*f-e*u*h+n*o*h-i*o*f+i*u*l-n*a*l)+t[11]*(+e*u*c-e*s*f-n*o*c+r*o*f+n*s*l-r*u*l)+t[15]*(-i*s*l-e*a*c+e*s*h+i*o*c-r*o*h+r*a*l)},t.prototype.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},t.prototype.invert=function(){var t=this.elements,e=t[0],r=t[1],i=t[2],n=t[3],o=t[4],s=t[5],a=t[6],u=t[7],l=t[8],c=t[9],h=t[10],f=t[11],p=t[12],d=t[13],m=t[14],v=t[15],y=c*m*u-d*h*u+d*a*f-s*m*f-c*a*v+s*h*v,g=p*h*u-l*m*u-p*a*f+o*m*f+l*a*v-o*h*v,x=l*d*u-p*c*u+p*s*f-o*d*f-l*s*v+o*c*v,T=p*c*a-l*d*a-p*s*h+o*d*h+l*s*m-o*c*m,E=e*y+r*g+i*x+n*T;if(0===E)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var S=1/E;return t[0]=y*S,t[1]=(d*h*n-c*m*n-d*i*f+r*m*f+c*i*v-r*h*v)*S,t[2]=(s*m*n-d*a*n+d*i*u-r*m*u-s*i*v+r*a*v)*S,t[3]=(c*a*n-s*h*n-c*i*u+r*h*u+s*i*f-r*a*f)*S,t[4]=g*S,t[5]=(l*m*n-p*h*n+p*i*f-e*m*f-l*i*v+e*h*v)*S,t[6]=(p*a*n-o*m*n-p*i*u+e*m*u+o*i*v-e*a*v)*S,t[7]=(o*h*n-l*a*n+l*i*u-e*h*u-o*i*f+e*a*f)*S,t[8]=x*S,t[9]=(p*c*n-l*d*n-p*r*f+e*d*f+l*r*v-e*c*v)*S,t[10]=(o*d*n-p*s*n+p*r*u-e*d*u-o*r*v+e*s*v)*S,t[11]=(l*s*n-o*c*n-l*r*u+e*c*u+o*r*f-e*s*f)*S,t[12]=T*S,t[13]=(l*d*i-p*c*i+p*r*h-e*d*h-l*r*m+e*c*m)*S,t[14]=(p*s*i-o*d*i-p*r*a+e*d*a+o*r*m-e*s*m)*S,t[15]=(o*c*i-l*s*i+l*r*a-e*c*a-o*r*h+e*s*h)*S,this},t.prototype.extractBasis=function(t,e,r){var i=this.elements;return t.set(i[0],i[1],i[2]),e.set(i[4],i[5],i[6]),r.set(i[8],i[9],i[10]),this},t.prototype.compose=function(t,e,r,i){void 0===i&&(i=Mt.ZERO);var n=this.elements,o=e.x,s=e.y,a=e.z,u=e.w,l=-i.x,c=-i.y,h=-i.z,f=o+o,p=s+s,d=a+a,m=o*f,v=o*p,y=o*d,g=s*p,x=s*d,T=a*d,E=u*f,S=u*p,b=u*d,A=r.x,_=r.y,C=r.z;return n[0]=(1-(g+T))*A,n[1]=(v+b)*A,n[2]=(y-S)*A,n[3]=0,n[4]=(v-b)*_,n[5]=(1-(m+T))*_,n[6]=(x+E)*_,n[7]=0,n[8]=(y+S)*C,n[9]=(x-E)*C,n[10]=(1-(m+g))*C,n[11]=0,n[12]=l*n[0]+c*n[4]+h*n[8]-l+t.x,n[13]=l*n[1]+c*n[5]+h*n[9]-c+t.y,n[14]=l*n[2]+c*n[6]+h*n[10]-h+t.z,this},t.prototype.decompose=function(e,r,i){var n=t.tempVec0,o=this.elements,s=n.set(o[0],o[1],o[2]).length(),a=n.set(o[4],o[5],o[6]).length(),u=n.set(o[8],o[9],o[10]).length();this.determinant()<0&&(s=-s),e.x=o[12],e.y=o[13],e.z=o[14];var l=t.tempMat0;l.copyFrom(this);var c=1/s,h=1/a,f=1/u;return l.elements[0]*=c,l.elements[1]*=c,l.elements[2]*=c,l.elements[4]*=h,l.elements[5]*=h,l.elements[6]*=h,l.elements[8]*=f,l.elements[9]*=f,l.elements[10]*=f,r.setFromRotationMatrix(l),i.x=s,i.y=a,i.z=u,this},t.prototype.getTranslation=function(t){var e=this.elements;return t.set(e[12],e[13],e[14])},t.prototype.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]))},t.prototype.getTransform=function(){var t=new Mt,e=new Lt,r=new Mt;return this.decompose(t,e,r),{translation:t,rotation:e,scale:r}},t.prototype.orthographic=function(t,e,r,i,n,o){var s=1/(e-t),a=1/(r-i),u=1/(o-n),l=-(e+t)*s,c=-(r+i)*a,h=-(o+n)*u;s*=2,a*=2,u*=-2;var f=this.elements;return f[0]=s,f[1]=0,f[2]=0,f[3]=0,f[4]=0,f[5]=a,f[6]=0,f[7]=0,f[8]=0,f[9]=0,f[10]=u,f[11]=0,f[12]=l,f[13]=c,f[14]=h,f[15]=1,this},t.prototype.perspective=function(t,e,r,i,n){var o=1/Math.tan(.5*t),s=1/(r-i),a=this.elements;return a[0]=n?o:o/e,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=n?o*e:o,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=(i+r)*s,a[11]=-1,a[12]=0,a[13]=0,a[14]=2*i*r*s,a[15]=0,null!==i&&i!==1/0||(a[10]=-1,a[14]=-2*r),this},t.prototype.projectPoint=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;s.x=o[0]*r+o[4]*i+o[8]*n+o[12],s.y=o[1]*r+o[5]*i+o[9]*n+o[13],s.z=o[2]*r+o[6]*i+o[10]*n+o[14];var a=o[3]*r+o[7]*i+o[11]*n+o[15];return s.multiply(1/a)},t.prototype.transformPoint=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;return s.x=o[0]*r+o[4]*i+o[8]*n+o[12],s.y=o[1]*r+o[5]*i+o[9]*n+o[13],s.z=o[2]*r+o[6]*i+o[10]*n+o[14],s},t.prototype.transformNormal=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;return s.x=o[0]*r+o[4]*i+o[8]*n,s.y=o[1]*r+o[5]*i+o[9]*n,s.z=o[2]*r+o[6]*i+o[10]*n,s.normalize()},t.prototype.transformVector4=function(t,e){var r=t.x,i=t.y,n=t.z,o=t.w,s=this.elements,a=null!=e?e:t;return a.x=s[0]*r+s[4]*i+s[8]*n+s[12]*o,a.y=s[1]*r+s[5]*i+s[9]*n+s[13]*o,a.z=s[2]*r+s[6]*i+s[10]*n+s[14]*o,a.w=s[3]*r+s[7]*i+s[11]*n+s[15]*o,a},t.prototype.equals=function(t){for(var e=this.elements,r=t.elements,i=0;i<16;i++)if(!_t(e[i],r[i]))return!1;return!0},t.prototype.toArray=function(){return Pt([],It(this.elements),!1)},t.prototype.fill=function(t,e){void 0===e&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8],t[e+9]=r[9],t[e+10]=r[10],t[e+11]=r[11],t[e+12]=r[12],t[e+13]=r[13],t[e+14]=r[14],t[e+15]=r[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,r,i){return(new t).lookAt(e,r,i)},t.fromPerspective=function(e,r,i,n,o){return(new t).perspective(e,r,i,n,o)},t.fromColumnVectors=function(e,r,i,n){return(new t).setFromColumnVectors(e,r,i,n)},t.fromMatrix3=function(e){return(new t).setFromMatrix3(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromScale=function(e,r,i){return(new t).setFromScale(e,r,i)},t.fromTranslation=function(e,r,i){return(new t).setFromTranslation(e,r,i)},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,r){return(new t).setFromRotationAxis(e,r)},t.fromEuler=function(e){return(new t).setFromEuler(e)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromShear=function(e,r,i){return(new t).setFromShear(e,r,i)},t.fromBasis=function(e,r,i){return(new t).setFromBasis(e,r,i)},t.fromRowMajorData=function(e,r,i,n,o,s,a,u,l,c,h,f,p,d,m,v){return new t(e,o,l,p,r,s,c,d,i,a,h,m,n,u,f,v)},t.IDENTITY=new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),t.ZERO=new t(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),t.tempVec0=new Mt,t.tempVec1=new Mt,t.tempVec2=new Mt,t.tempMat0=new t,t}();!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"}(Ot||(Ot={}));var Nt,Vt,Dt=function(){function t(e,r,i,n){void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=t.DEFAULT_ORDER),this.x=e,this.y=r,this.z=i,this.order=n}return t.prototype.set=function(t,e,r,i){return void 0===i&&(i=this.order),this.x=t,this.y=e,this.z=r,this.order=i,this},t.prototype.setZero=function(t){return void 0===t&&(t=this.order),this.set(0,0,0,t)},t.prototype.setFromRotationMatrix4=function(t,e){void 0===e&&(e=this.order);var r=t.elements,i=r[0],n=r[4],o=r[8],s=r[1],a=r[5],u=r[9],l=r[2],c=r[6],h=r[10];switch(e){case Ot.XYZ:this.y=Math.asin(Rt(o,-1,1)),Math.abs(o)<.9999999?(this.x=Math.atan2(-u,h),this.z=Math.atan2(-n,i)):(this.x=Math.atan2(c,a),this.z=0);break;case Ot.YXZ:this.x=Math.asin(-Rt(u,-1,1)),Math.abs(u)<.9999999?(this.y=Math.atan2(o,h),this.z=Math.atan2(s,a)):(this.y=Math.atan2(-l,i),this.z=0);break;case Ot.ZXY:this.x=Math.asin(Rt(c,-1,1)),Math.abs(c)<.9999999?(this.y=Math.atan2(-l,h),this.z=Math.atan2(-n,a)):(this.y=0,this.z=Math.atan2(s,i));break;case Ot.ZYX:this.y=Math.asin(-Rt(l,-1,1)),Math.abs(l)<.9999999?(this.x=Math.atan2(c,h),this.z=Math.atan2(s,i)):(this.x=0,this.z=Math.atan2(-n,a));break;case Ot.YZX:this.z=Math.asin(Rt(s,-1,1)),Math.abs(s)<.9999999?(this.x=Math.atan2(-u,a),this.y=Math.atan2(-l,i)):(this.x=0,this.y=Math.atan2(o,h));break;case Ot.XZY:this.z=Math.asin(-Rt(n,-1,1)),Math.abs(n)<.9999999?(this.x=Math.atan2(c,a),this.y=Math.atan2(o,i)):(this.x=Math.atan2(-u,h),this.y=0);break;default:console.error("setFromRotationMatrix: unknown order: "+e)}return this.x*=bt,this.y*=bt,this.z*=bt,this.order=e,this},t.prototype.setFromQuaternion=function(e,r){void 0===r&&(r=this.order);var i=t.tempMat0;return i.setFromQuaternion(e),this.setFromRotationMatrix4(i,r)},t.prototype.setFromVector3=function(t,e){return void 0===e&&(e=this.order),this.set(t.x,t.y,t.z,e)},t.prototype.setFromArray=function(t,e,r){var i,n,o,s;return void 0===e&&(e=0),void 0===r&&(r=this.order),this.x=null!==(i=t[e])&&void 0!==i?i:0,this.y=null!==(n=t[e+1])&&void 0!==n?n:0,this.z=null!==(o=t[e+2])&&void 0!==o?o:0,this.order=null!==(s=t[e+3])&&void 0!==s?s:r,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.order)},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.order=t.order,this},t.prototype.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)},t.prototype.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)},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},t.prototype.reorder=function(t){var e=new Lt;return e.setFromEuler(this),this.setFromQuaternion(e,t)},t.prototype.rotateVector3=function(e,r){return t.tempQuat0.setFromEuler(this).rotateVector3(e,r)},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.order===this.order},t.prototype.toVector3=function(t){return t.set(this.x,this.y,this.z)},t.prototype.toArray=function(){return[this.x,this.y,this.z]},t.prototype.toQuaternion=function(t){var e,r=(e=this).x,i=e.y,n=e.z,o=e.order,s=Math.cos(r*St*.5),a=Math.cos(i*St*.5),u=Math.cos(n*St*.5),l=Math.sin(r*St*.5),c=Math.sin(i*St*.5),h=Math.sin(n*St*.5);switch(o){case Ot.XYZ:t.set(l*a*u+s*c*h,s*c*u-l*a*h,s*a*h+l*c*u,s*a*u-l*c*h);break;case Ot.YXZ:t.set(l*a*u+s*c*h,s*c*u-l*a*h,s*a*h-l*c*u,s*a*u+l*c*h);break;case Ot.ZXY:t.set(l*a*u-s*c*h,s*c*u+l*a*h,s*a*h+l*c*u,s*a*u-l*c*h);break;case Ot.ZYX:t.set(l*a*u-s*c*h,s*c*u+l*a*h,s*a*h-l*c*u,s*a*u+l*c*h);break;case Ot.YZX:t.set(l*a*u+s*c*h,s*c*u+l*a*h,s*a*h-l*c*u,s*a*u-l*c*h);break;case Ot.XZY:t.set(l*a*u-s*c*h,s*c*u-l*a*h,s*a*h+l*c*u,s*a*u+l*c*h);break;default:console.error("unknown euler order: "+o)}return t},t.prototype.toMatrix4=function(t){var e,r=t.elements,i=(e=this).x,n=e.y,o=e.z,s=e.order,a=Math.cos(i*St),u=Math.sin(i*St),l=Math.cos(n*St),c=Math.sin(n*St),h=Math.cos(o*St),f=Math.sin(o*St);if(s===Ot.XYZ){var p=a*h,d=a*f,m=u*h,v=u*f;r[0]=l*h,r[4]=-l*f,r[8]=c,r[1]=d+m*c,r[5]=p-v*c,r[9]=-u*l,r[2]=v-p*c,r[6]=m+d*c,r[10]=a*l}else if(s===Ot.YXZ){var y=l*h,g=l*f,x=c*h,T=c*f;r[0]=y+T*u,r[4]=x*u-g,r[8]=a*c,r[1]=a*f,r[5]=a*h,r[9]=-u,r[2]=g*u-x,r[6]=T+y*u,r[10]=a*l}else if(s===Ot.ZXY){y=l*h,g=l*f,x=c*h,T=c*f;r[0]=y-T*u,r[4]=-a*f,r[8]=x+g*u,r[1]=g+x*u,r[5]=a*h,r[9]=T-y*u,r[2]=-a*c,r[6]=u,r[10]=a*l}else if(s===Ot.ZYX){p=a*h,d=a*f,m=u*h,v=u*f;r[0]=l*h,r[4]=m*c-d,r[8]=p*c+v,r[1]=l*f,r[5]=v*c+p,r[9]=d*c-m,r[2]=-c,r[6]=u*l,r[10]=a*l}else if(s===Ot.YZX){var E=a*l,S=a*c,b=u*l,A=u*c;r[0]=l*h,r[4]=A-E*f,r[8]=b*f+S,r[1]=f,r[5]=a*h,r[9]=-u*h,r[2]=-c*h,r[6]=S*f+b,r[10]=E-A*f}else if(s===Ot.XZY){E=a*l,S=a*c,b=u*l,A=u*c;r[0]=l*h,r[4]=-f,r[8]=c*h,r[1]=E*f+A,r[5]=a*h,r[9]=S*f-b,r[2]=b*f-S,r[6]=u*h,r[10]=A*f+E}else console.error("toMatrix4: Invalid order "+s);return r[3]=0,r[7]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,t},t.fromRotationMatrix4=function(e,r){return void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromRotationMatrix4(e,r)},t.fromQuaternion=function(e,r){return void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromQuaternion(e,r)},t.fromVector3=function(e,r){return void 0===r&&(r=t.DEFAULT_ORDER),(new t).setFromVector3(e,r)},t.fromArray=function(e,r,i){return void 0===r&&(r=0),void 0===i&&(i=t.DEFAULT_ORDER),(new t).setFromArray(e,r,i)},t.DEFAULT_ORDER=Ot.ZYX,t.tempQuat0=new Lt,t.tempMat0=new Ft,t}(),zt=function(){function t(t,e,r,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),this.x=t,this.y=e,this.z=r,this.w=i}return t.prototype.set=function(t,e,r,i){return this.x=t,this.y=e,this.z=r,this.w=i,this},t.prototype.setZero=function(){return this.x=0,this.y=0,this.z=0,this.w=0,this},t.prototype.setFromNumber=function(t){return this.x=t,this.y=t,this.z=t,this.w=t,this},t.prototype.setFromArray=function(t,e){var r,i,n,o;return void 0===e&&(e=0),this.x=null!==(r=t[e])&&void 0!==r?r:0,this.y=null!==(i=t[e+1])&&void 0!==i?i:0,this.z=null!==(n=t[e+2])&&void 0!==n?n:0,this.w=null!==(o=t[e+3])&&void 0!==o?o:0,this},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.x+=t,this.y+=t,this.z+=t,this.w+=t):t instanceof 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},t.prototype.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},t.prototype.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},t.prototype.subtract=function(t){return"number"==typeof t?(this.x-=t,this.y-=t,this.z-=t,this.w-=t):t instanceof 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},t.prototype.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},t.prototype.multiply=function(t){return"number"==typeof t?(this.x*=t,this.y*=t,this.z*=t,this.w*=t):t instanceof 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},t.prototype.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},t.prototype.divide=function(t){return"number"==typeof t?(this.x/=t,this.y/=t,this.z/=t,this.w/=t):t instanceof 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},t.prototype.scale=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},t.prototype.sum=function(){return this.x+this.y+this.z+this.w},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.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},t.prototype.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},t.prototype.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},t.prototype.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},t.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.normalize=function(){return this.divide(this.length()||1)},t.prototype.setLength=function(t){return this.normalize().multiply(t)},t.prototype.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},t.prototype.lerpVectors=function(t,e,r){return this.x=t.x+(e.x-t.x)*r,this.y=t.y+(e.y-t.y)*r,this.z=t.z+(e.z-t.z)*r,this.w=t.w+(e.w-t.w)*r,this},t.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w},t.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w},t.prototype.isZero=function(){var t,e=At,r=(t=this).x,i=t.y,n=t.z,o=t.w;return Math.abs(r)<=e&&Math.abs(i)<=e&&Math.abs(n)<=e&&Math.abs(o)<=e},t.prototype.toArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.toVector3=function(){return new Mt(this.x,this.y,this.z)},t.prototype.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},t.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this},t.prototype.applyMatrix=function(t,e){return t.transformVector4(this,e)},t.fromNumber=function(e){return(new t).setFromNumber(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.ONE=new t(1,1,1,1),t.ZERO=new t(0,0,0,0),t}(),Bt=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s},Ut=function(t,e,r){if(r||2===arguments.length)for(var i,n=0,o=e.length;n<o;n++)!i&&n in e||(i||(i=Array.prototype.slice.call(e,0,n)),i[n]=e[n]);return t.concat(i||Array.prototype.slice.call(e))},kt=function(){function t(t,e,r,i,n,o,s,a,u){void 0===t&&(t=1),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===o&&(o=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===u&&(u=1),this.elements=[t,e,r,i,n,o,s,a,u]}return t.prototype.set=function(t,e,r,i,n,o,s,a,u){var l=this.elements;return l[0]=t,l[3]=i,l[6]=s,l[1]=e,l[4]=n,l[7]=a,l[2]=r,l[5]=o,l[8]=u,this},t.prototype.setFromRowMajorData=function(t,e,r,i,n,o,s,a,u){var l=this.elements;return l[0]=t,l[3]=e,l[6]=r,l[1]=i,l[4]=n,l[7]=o,l[2]=s,l[5]=a,l[8]=u,this},t.prototype.setFromColumnVectors=function(t,e,r){return this.set(t.x,t.y,t.z,e.x,e.y,e.z,r.x,r.y,r.z)},t.prototype.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])},t.prototype.setFromArray=function(t,e){void 0===e&&(e=0);for(var r=0;r<9;r++)this.elements[r]=t[e+r];return this},t.prototype.setFromQuaternion=function(t){var e=t.x,r=t.y,i=t.z,n=t.w,o=e+e,s=r+r,a=i+i,u=e*o,l=e*s,c=e*a,h=r*s,f=r*a,p=i*a,d=n*o,m=n*s,v=n*a,y=this.elements;return y[0]=1-(h+p),y[1]=l+v,y[2]=c-m,y[3]=l-v,y[4]=1-(u+p),y[5]=f+d,y[6]=c+m,y[7]=f-d,y[8]=1-(u+h),this},t.prototype.setZero=function(){for(var t=0;t<9;t++)this.elements[t]=0;return this},t.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1)},t.prototype.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])},t.prototype.copyFrom=function(t){return this.elements=Ut([],Bt(t.elements),!1),this},t.prototype.getColumnVector=function(t,e){return e.set(this.elements[3*t],this.elements[3*t+1],this.elements[3*t+2])},t.prototype.scale=function(t,e){var r=this.elements;return r[0]*=t,r[3]*=t,r[6]*=t,r[1]*=e,r[4]*=e,r[7]*=e,this},t.prototype.rotate=function(t){var e=Math.cos(t),r=Math.sin(t),i=this.elements,n=i[0],o=i[3],s=i[6],a=i[1],u=i[4],l=i[7];return i[0]=e*n+r*a,i[3]=e*o+r*u,i[6]=e*s+r*l,i[1]=-r*n+e*a,i[4]=-r*o+e*u,i[7]=-r*s+e*l,this},t.prototype.translate=function(t,e){var r=this.elements;return r[0]+=t*r[2],r[3]+=t*r[5],r[6]+=t*r[8],r[1]+=e*r[2],r[4]+=e*r[5],r[7]+=e*r[8],this},t.prototype.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)},t.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},t.prototype.multiplyMatrices=function(t,e){var r=t.elements,i=e.elements,n=this.elements,o=r[0],s=r[3],a=r[6],u=r[1],l=r[4],c=r[7],h=r[2],f=r[5],p=r[8],d=i[0],m=i[3],v=i[6],y=i[1],g=i[4],x=i[7],T=i[2],E=i[5],S=i[8];return n[0]=o*d+s*y+a*T,n[3]=o*m+s*g+a*E,n[6]=o*v+s*x+a*S,n[1]=u*d+l*y+c*T,n[4]=u*m+l*g+c*E,n[7]=u*v+l*x+c*S,n[2]=h*d+f*y+p*T,n[5]=h*m+f*g+p*E,n[8]=h*v+f*x+p*S,this},t.prototype.determinant=function(){var t=this.elements,e=t[0],r=t[3],i=t[6],n=t[1],o=t[4],s=t[7],a=t[2],u=t[5],l=t[8];return e*(o*l-u*s)+n*(u*i-r*l)+a*(r*s-o*i)},t.prototype.invert=function(){var t=this.elements,e=t[0],r=t[3],i=t[6],n=t[1],o=t[4],s=t[7],a=t[2],u=t[5],l=t[8],c=l*o-u*s,h=u*i-l*r,f=s*r-o*i,p=e*c+n*h+a*f;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);var d=1/p;return t[0]=c*d,t[1]=(a*s-l*n)*d,t[2]=(u*n-a*o)*d,t[3]=h*d,t[4]=(l*e-a*i)*d,t[5]=(a*r-u*e)*d,t[6]=f*d,t[7]=(n*i-s*e)*d,t[8]=(o*e-n*r)*d,this},t.prototype.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},t.prototype.transformPoint=function(t,e){var r=t.x,i=t.y,n=t.z,o=this.elements,s=null!=e?e:t;return s.x=o[0]*r+o[3]*i+o[6]*n,s.y=o[1]*r+o[4]*i+o[7]*n,s.z=o[2]*r+o[5]*i+o[8]*n,s},t.prototype.transformNormal=function(t,e){return this.transformPoint(t,e).normalize()},t.prototype.equals=function(t){for(var e=this.elements,r=t.elements,i=0;i<9;i++)if(!_t(e[i],r[i]))return!1;return!0},t.prototype.toArray=function(){return Ut([],Bt(this.elements),!1)},t.prototype.fill=function(t,e){void 0===e&&(e=0);var r=this.elements;t[e]=r[0],t[e+1]=r[1],t[e+2]=r[2],t[e+3]=r[3],t[e+4]=r[4],t[e+5]=r[5],t[e+6]=r[6],t[e+7]=r[7],t[e+8]=r[8]},t.fromIdentity=function(){return new t(1,0,0,0,1,0,0,0,1)},t.fromColumnVectors=function(e,r,i){return(new t).setFromColumnVectors(e,r,i)},t.fromMatrix4=function(e){return(new t).setFromMatrix4(e)},t.fromArray=function(e,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromQuaternion=function(e){return(new t).setFromQuaternion(e)},t.fromRowMajorData=function(e,r,i,n,o,s,a,u,l){return new t(e,n,a,r,o,u,i,s,l)},t}(),Gt=function(){function t(t,e){void 0===t&&(t=Mt.ZERO),void 0===e&&(e=Mt.X),this.origin=new Mt,this.direction=new Mt,this.origin.copyFrom(t),this.direction.copyFrom(e).normalize()}return t.prototype.set=function(t,e){return this.origin.copyFrom(t),this.direction.copyFrom(e).normalize(),this},t.prototype.clone=function(){return new t(this.origin,this.direction)},t.prototype.copyFrom=function(t){return this.set(t.origin,t.direction)},t.prototype.recast=function(e){return this.origin.copyFrom(this.at(e,t.tempVec0)),this},t.prototype.at=function(t,e){var r=e||new Mt;return r.copyFrom(this.origin),r.addScaledVector(this.direction,t)},t.prototype.equals=function(t){return this.origin.equals(t.origin)&&this.direction.equals(t.direction)},t.prototype.applyMatrix=function(t){return this.origin.applyProjectionMatrix(t),this.direction.applyNormalMatrix(t),this},t.prototype.intersectBox=function(t,e){var r,i,n,o,s,a,u,l,c,h,f=(r=this.origin).x,p=r.y,d=r.z,m=(i=this.direction).x,v=i.y,y=i.z,g=(n=t.min).x,x=n.y,T=n.z,E=(o=t.max).x,S=o.y,b=o.z,A=1/m,_=1/v,C=1/y;if(A>=0?(s=(g-f)*A,a=(E-f)*A):(s=(E-f)*A,a=(g-f)*A),_>=0?(u=(x-p)*_,l=(S-p)*_):(u=(S-p)*_,l=(x-p)*_),!(s>l||u>a||((u>s||s!=s)&&(s=u),(l<a||a!=a)&&(a=l),(u>s||s!=s)&&(s=u),(l<a||a!=a)&&(a=l),C>=0?(c=(T-d)*C,h=(b-d)*C):(c=(b-d)*C,h=(T-d)*C),s>h||c>a||((c>s||s!=s)&&(s=c),(h<a||a!=a)&&(a=h),a<0))))return s>=0?this.at(s,e):this.at(a,e)},t.prototype.intersectPlane=function(t,e){var r=t.normal,i=t.distance,n=r.dot(this.direction);if(0===n)return 0===r.dot(this.origin)+i?(e||new Mt).copyFrom(this.origin):void 0;var o=-(this.origin.dot(r)+i)/n;return o>=0?this.at(o,e):void 0},t.prototype.intersectSphere=function(e,r){var i=e.center,n=t.tempVec0.subtractVectors(i,this.origin),o=n.dot(this.direction),s=n.dot(n)-o*o,a=e.radius*e.radius;if(!(s>a)){var u=Math.sqrt(a-s),l=o-u,c=o+u;if(!(c<0))return l>=0?this.at(l,r):this.at(c,r)}},t.prototype.intersectTriangle=function(e,r,i){var n,o=e.p0,s=e.p1,a=e.p2,u=t.tempVec0.subtractVectors(s,o),l=t.tempVec1.subtractVectors(a,o),c=t.tempVec2.subtractVectors(this.origin,o),h=t.tempVec3.crossVectors(u,l),f=this.direction.dot(h);if(f>0){if(i)return;n=1}else{if(!(f<0))return;n=-1,f=-f}l.crossVectors(c,l);var p=n*this.direction.dot(l);if(!(p<0)){u.cross(c);var d=n*this.direction.dot(u);if(!(d<0||p+d>f)){var m=-n*c.dot(h);if(!(m<0))return this.at(m/f,r)}}},t.tempVec0=new Mt,t.tempVec1=new Mt,t.tempVec2=new Mt,t.tempVec3=new Mt,t}(),Xt=function(){function t(t,e,r,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=0),this.r=t,this.g=e,this.b=r,this.a=i}return t.prototype.set=function(t,e,r,i){return this.r=t,this.g=e,this.b=r,this.a=i,this},t.prototype.setZero=function(){return this.r=0,this.g=0,this.b=0,this.a=0,this},t.prototype.setFromNumber=function(t){return this.r=t,this.g=t,this.b=t,this.a=t,this},t.prototype.setFromVector4=function(t){return this.r=t.x,this.g=t.y,this.b=t.z,this.a=t.w,this},t.prototype.setFromArray=function(t,e){var r,i,n,o;return void 0===e&&(e=0),this.r=null!==(r=t[e])&&void 0!==r?r:0,this.g=null!==(i=t[e+1])&&void 0!==i?i:0,this.b=null!==(n=t[e+2])&&void 0!==n?n:0,this.a=null!==(o=t[e+3])&&void 0!==o?o:0,this},t.prototype.setFromHSV=function(t,e,r,i){void 0===i&&(i=1);var n=r*e,o=t/60,s=n*(1-Math.abs(o%2-1)),a=0,u=0,l=0;o>=0&&o<=1?(a=n,u=s):o>=1&&o<=2?(a=s,u=n):o>=2&&o<=3?(u=n,l=s):o>=3&&o<=4?(u=s,l=n):o>=4&&o<=5?(a=s,l=n):o>=5&&o<=6&&(a=n,l=s);var c=r-n;return this.set(a+c,u+c,l+c,i)},t.prototype.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,r=parseInt(t.substring(3,5),16)/255,i=parseInt(t.substring(5,7),16)/255,n=9===t.length?parseInt(t.substring(7,9),16)/255:1;return this.set(e,r,i,n)},t.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.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},t.prototype.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},t.prototype.add=function(t){return"number"==typeof t?(this.r+=t,this.g+=t,this.b+=t,this.a+=t):t instanceof 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},t.prototype.subtract=function(t){return"number"==typeof t?(this.r-=t,this.g-=t,this.b-=t,this.a-=t):t instanceof 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},t.prototype.multiply=function(t){return"number"==typeof t?(this.r*=t,this.g*=t,this.b*=t,this.a*=t):t instanceof 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},t.prototype.divide=function(t){return"number"==typeof t?(this.r/=t,this.g/=t,this.b/=t,this.a/=t):t instanceof 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},t.prototype.scale=function(t){return this.r*=t,this.g*=t,this.b*=t,this.a*=t,this},t.prototype.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},t.prototype.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},t.prototype.clamp=function(t,e){return this.max(t).min(e)},t.prototype.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},t.prototype.luminance=function(){return.3*this.r+.59*this.g+.11*this.b},t.prototype.equals=function(t){return t.r===this.r&&t.g===this.g&&t.b===this.b&&t.a===this.a},t.prototype.toLinear=function(){return this.r=t.gammaToLinear(this.r),this.g=t.gammaToLinear(this.g),this.b=t.gammaToLinear(this.b),this},t.prototype.toGamma=function(){return this.r=t.linearToGamma(this.r),this.g=t.linearToGamma(this.g),this.b=t.linearToGamma(this.b),this},t.prototype.toArray=function(){return[this.r,this.g,this.b,this.a]},t.prototype.toVector4=function(){return new zt(this.r,this.g,this.b,this.a)},t.prototype.toHSV=function(){var e,r=(e=this).r,i=e.g,n=e.b,o=e.a,s=Math.max(r,i,n),a=Math.min(r,i,n),u=s-a,l=0,c=0;return 0!==s&&(c=u/s),s!=a&&(s==r?(l=(i-n)/u,i<n&&(l+=6)):s==i?l=(n-r)/u+2:s==n&&(l=(r-i)/u+4),l*=60),new t(l,c,s,o)},t.prototype.toHexString=function(e){void 0===e&&(e=!0);var r=t.ToHex(Math.round(255*this.r)),i=t.ToHex(Math.round(255*this.g)),n=t.ToHex(Math.round(255*this.b)),o=t.ToHex(Math.round(255*this.a));return e?"#"+r+i+n+o:"#"+r+i+n},t.prototype.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,r){return void 0===r&&(r=0),(new t).setFromArray(e,r)},t.fromHexString=function(e){return(new t).setFromHexString(e)},t.fromHSV=function(e,r,i,n){return void 0===n&&(n=1),(new t).setFromHSV(e,r,i,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.BLACK=new t(0,0,0,1),t.BLUE=new t(0,0,1,1),t.CLEAR=new t(0,0,0,0),t.CYAN=new t(0,1,1,1),t.GRAY=new t(.5,.5,.5,1),t.GREEN=new t(0,1,0,1),t.MAGENTA=new t(1,0,1,1),t.RED=new t(1,0,0,1),t.WHITE=new t(1,1,1,1),t.YELLOW=new t(1,.92,.016,1),t}(),Ht=function(){function t(t,e){void 0===t&&(t=new Mt(1/0,1/0,1/0)),void 0===e&&(e=new Mt(-1/0,-1/0,-1/0)),this.min=t.clone(),this.max=e.clone()}return t.prototype.set=function(t,e){return this.min.copyFrom(t),this.max.copyFrom(e),this},t.prototype.setFromArray=function(t){for(var e=Number(1/0),r=Number(1/0),i=Number(1/0),n=-1/0,o=-1/0,s=-1/0,a=0,u=t.length;a<u;a+=3){var l=t[a],c=t[a+1],h=t[a+2];l<e&&(e=l),c<r&&(r=c),h<i&&(i=h),l>n&&(n=l),c>o&&(o=c),h>s&&(s=h)}return this.min.set(e,r,i),this.max.set(n,o,s),this},t.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,r=t.length;e<r;e++)this.expandByPoint(t[e]);return this},t.prototype.setFromCenterAndSize=function(t,e){var r=e.clone().multiply(.5);return this.min.copyFrom(t).subtract(r),this.max.copyFrom(t).add(r),this},t.prototype.setFromObject=function(t){return this.makeEmpty(),this.expandByObject(t)},t.prototype.clone=function(){return(new t).copyFrom(this)},t.prototype.copyFrom=function(t){return this.min.copyFrom(t.min),this.max.copyFrom(t.max),this},t.prototype.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},t.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},t.prototype.getCenter=function(t){return void 0===t&&(t=new Mt),this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiply(.5)},t.prototype.getSize=function(t){return void 0===t&&(t=new Mt),this.isEmpty()?t.set(0,0,0):t.subtractVectors(this.max,this.min)},t.prototype.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},t.prototype.expandByVector=function(t){return this.min.subtract(t),this.max.add(t),this},t.prototype.expandByScalar=function(t){return this.min.add(-t),this.max.add(t),this},t.prototype.expandByBox=function(t){return this.min.min(t.min),this.max.max(t.max),this},t.prototype.expandByObject=function(e){e.updateWorldMatrix(!1,!1);var r=e.geometry;if(void 0!==r){null===r.boundingBox&&r.computeBoundingBox();var i=new t;i.copyFrom(r.boundingBox),i.applyMatrix4(e.matrixWorld),this.union(i)}for(var n=e.children,o=0,s=n.length;o<s;o++)this.expandByObject(n[o]);return this},t.prototype.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)},t.prototype.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},t.prototype.getParameter=function(t,e){return void 0===e&&(e=new Mt),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))},t.prototype.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)},t.prototype.intersectsSphere=function(t){var e=new Mt;return this.clampPoint(t.center,e),e.distanceSquared(t.center)<=t.radius*t.radius},t.prototype.clampPoint=function(t,e){return void 0===e&&(e=new Mt),e.copyFrom(t).clamp(this.min,this.max)},t.prototype.distanceToPoint=function(t){return t.clone().clamp(this.min,this.max).subtract(t).length()},t.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},t.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},t.prototype.applyMatrix4=function(t,e){if(void 0===e&&(e=new Mt),this.isEmpty())return this;var r=this.getOBBPoints(t,e);return this.setFromPoints(r),this},t.prototype.getOBBPoints=function(t,e){if(void 0===e&&(e=new Mt),this.isEmpty())return[];var r=[];return r[0]=new Mt(this.min.x,this.min.y,this.min.z),r[1]=new Mt(this.min.x,this.min.y,this.max.z),r[2]=new Mt(this.min.x,this.max.y,this.min.z),r[3]=new Mt(this.min.x,this.max.y,this.max.z),r[4]=new Mt(this.max.x,this.min.y,this.min.z),r[5]=new Mt(this.max.x,this.min.y,this.max.z),r[6]=new Mt(this.max.x,this.max.y,this.min.z),r[7]=new Mt(this.max.x,this.max.y,this.max.z),r.forEach((function(r){r.subtract(e),r.applyMatrix(t),r.add(e)})),r},t.prototype.getBoundingSphere=function(t){this.getCenter(t.center);var e=new Mt;return t.radius=.5*this.getSize(e).length(),t},t.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},t.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},t}(),Yt=function(){function t(t,e){void 0===t&&(t=Mt.ZERO),void 0===e&&(e=-1),this.center=t.clone(),this.radius=e}return t.prototype.set=function(t,e){return this.center.copyFrom(t),this.radius=e,this},t.prototype.setFromPoints=function(t,e){var r=this.center;if(void 0!==e){r.copyFrom(e);for(var i=0,n=0;n<t.length;n++)i=Math.max(i,r.distanceSquared(t[n]));this.radius=Math.sqrt(i)}else{var o=(new Ht).setFromPoints(t);o.getCenter(r),this.radius=o.getSize().length()/2}return this},t.prototype.copyFrom=function(t){return this.center.copyFrom(t.center),this.radius=t.radius,this},t.prototype.isEmpty=function(){return this.radius<0},t.prototype.makeEmpty=function(){return this.center.set(0,0,0),this.radius=-1,this},t.prototype.containsPoint=function(t){return t.distanceSquared(this.center)<=this.radius*this.radius},t.prototype.distanceToPoint=function(t){return t.distance(this.center)-this.radius},t.prototype.intersectsSphere=function(t){var e=this.radius+t.radius;return t.center.distanceSquared(this.center)<=e*e},t.prototype.intersectsBox=function(t){return t.intersectsSphere(this)},t.prototype.clampPoint=function(t,e){var r=this.center.distanceSquared(t);return void 0===e&&(e=new Mt),e.copyFrom(t),r>this.radius*this.radius&&(e.subtract(this.center).normalize(),e.multiply(this.radius).add(this.center)),e},t.prototype.getBoundingBox=function(t){return void 0===t&&(t=new Ht),this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)},t.prototype.applyMatrix4=function(t){var e=t.elements,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=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],o=Math.sqrt(Math.max(r,i,n));return this.center.applyMatrix(t),this.radius=this.radius*o,this},t.prototype.translate=function(t){return this.center.add(t),this},t.prototype.expandByPoint=function(t){var e=(new Mt).subtractVectors(t,this.center),r=e.lengthSquared();if(r>this.radius*this.radius){var i=Math.sqrt(r),n=.5*(i-this.radius);this.center.add(e.multiply(n/i)),this.radius+=n}return this},t.prototype.union=function(t){var e=new Mt,r=new Mt;return r.subtractVectors(t.center,this.center).normalize().multiply(t.radius),this.expandByPoint(e.copyFrom(t.center).add(r)),this.expandByPoint(e.copyFrom(t.center).subtract(r)),this},t.prototype.intersect=function(t){var e=(new Mt).subtractVectors(this.center,t.center),r=e.length();return r>this.radius+t.radius?this.makeEmpty():(this.center=this.center.add(e.normalize().multiply(r/2)),this.radius=this.radius+t.radius-r,this)},t.prototype.equals=function(t){return t.center.equals(this.center)&&t.radius===this.radius},t.prototype.clone=function(){return(new t).copyFrom(this)},t}(),jt=Object.freeze({__proto__:null,get EulerOrder(){return Ot},Euler:Dt,Quaternion:Lt,Vector2:wt,Vector3:Mt,Vector4:zt,Matrix3:kt,Matrix4:Ft,Ray:Gt,PI2:Et,DEG2RAD:St,RAD2DEG:bt,NumberEpsilon:At,isZero:function(t){return isNaN(t)||Math.abs(t)<At},isEqual:_t,damp:function(t,e,r,i){return Ct(t,e,1-Math.exp(-r*i))},lerp:Ct,degToRad:function(t){return t*St},radToDeg:function(t){return t*bt},clamp:Rt,Color:Xt,Box3:Ht,Sphere:Yt}),Wt=(Nt=new Float32Array(1),Vt=new Int32Array(Nt.buffer),function(t){Nt[0]=t;var e=Vt[0],r=e>>16&32768,i=e>>12&2047,n=e>>23&255;return n<103?r:n>142?(r|=31744,r|=(255==n?0:1)&&8388607&e):n<113?r|=((i|=2048)>>114-n)+(i>>113-n&1):(r|=n-112<<10|i>>1,r+=1&i)}),Zt=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),r=0;r<e.length;r++)e[r]=Wt(t[r])}return t.prototype.set=function(t,e){for(var r=0;r<t.length;r++)this.data[r+e]=Wt(t[r])},t}();var qt,Kt=new Dt,Qt=new Ft;function Jt(t,e,r,i,n,o,s){var a=t,u=i/n,l=i,c=e.speedOverLifetime;c&&(l=c.getIntegrateValue(0,i,n));var h=e.gravityModifier?e.gravityModifier.getIntegrateByTime(0,i):0;a.copyFrom(o),a.addScaledVector(s,l),a.addScaledVector(r,h);var f=e.linearVelOverLifetime||{},p=e.orbitalVelOverLifetime||{},d=["x","y","z"];if(p.enabled){var m=new Mt;p.center&&m.setFromArray(p.center);var v=a.clone().subtract(m),y=p.asRotation,g=d.map((function(t){var e=p[t];return e?y?e.getValue(u):e.getIntegrateValue(0,i,n):0}));Kt.setFromArray(g).negate(),Qt.setFromEuler(Kt);var x=Qt.transformPoint(v);a.addVectors(m,x)}if(f.enabled)for(var T=f.asMovement,E=0;E<3;E++){var S=f[d[E]];if(S){var b=T?S.getValue(u):S.getIntegrateValue(0,i,n);a.setElement(E,a.getElement(E)+b)}}return a}function $t(t){return Array.isArray(t)?[t[0],t[1],t[2]]:[0,0,0]}function te(t,e){for(var r=0,i=t.length;r<i;r++)t[r]=e;return t}function ee(t,e,r,i){void 0===i&&(i=0);for(var n=0;n<r;n++)t[n]=e[n+i];return t}function re(t,e){1===arguments.length&&(e=t,t=[]);var r=e,i=Math.hypot.apply(Math,u([],a(r),!1));if(0===i)return ee(t,r,r.length);for(var n=0;n<r.length;n++)t[n]=r[n]/i;return t}function ie(t,e,r){if(e&&r)for(var i=0,n=e.length;i<n;i++)t[i]=e[i]*r[i];else if(e){if(t!==e)for(i=0;i<e.length;i++)t[i]=e[i]}else if(r&&t!==r)for(i=0;i<r.length;i++)t[i]=r[i];return t}var ne,oe=((qt={})[L.PARTICLE_ORIGIN_CENTER]=[0,0],qt[L.PARTICLE_ORIGIN_CENTER_BOTTOM]=[0,-.5],qt[L.PARTICLE_ORIGIN_CENTER_TOP]=[0,.5],qt[L.PARTICLE_ORIGIN_LEFT_TOP]=[-.5,.5],qt[L.PARTICLE_ORIGIN_LEFT_CENTER]=[-.5,0],qt[L.PARTICLE_ORIGIN_LEFT_BOTTOM]=[-.5,-.5],qt[L.PARTICLE_ORIGIN_RIGHT_CENTER]=[.5,0],qt[L.PARTICLE_ORIGIN_RIGHT_BOTTOM]=[.5,-.5],qt[L.PARTICLE_ORIGIN_RIGHT_TOP]=[.5,.5],qt);function se(t,e){return t?[t[0]-.5,.5-t[1]]:e?oe[e]:[0,0]}function ae(t){return Math.pow(2,Math.round(Math.log(t)/Math.LN2))}function ue(t,e,r){var i=r.position,n=new Mt(t,e,0),o=new Mt;return r.getInverseViewProjectionMatrix().projectPoint(n,o),o.subtract(i),new Gt(i,o)}function le(t,e,r){var i=t.x,n=t.y,o=t.z,s=new Mt(i-e,n+r,o),a=new Mt(i-e,n-r,o),u=new Mt(i+e,n-r,o),l=new Mt(i+e,n+r,o);return[{p0:s,p1:a,p2:u},{p0:s.clone(),p1:u.clone(),p2:l}]}var ce="not_implement",he=function(){function t(t){this.onCreate(t)}return t.prototype.onCreate=function(t){throw Error(ce)},t.prototype.getIntegrateValue=function(t,e,r){throw Error(ce)},t.prototype.getIntegrateByTime=function(t,e){throw Error(ce)},t.prototype.getValue=function(t){throw Error(ce)},t.prototype.toUniform=function(t){throw Error(ce)},t.prototype.map=function(t){throw Error(ce)},t.prototype.scaleXCoord=function(t){return this},t}(),fe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.value=t},e.prototype.getIntegrateValue=function(t,e,r){return this.value*(e-t)},e.prototype.getIntegrateByTime=function(t,e){return.5*this.value*(e*e-t*t)},e.prototype.getValue=function(t){return this.value},e.prototype.toUniform=function(){return new Float32Array([0,this.value,0,0])},e.prototype.map=function(t){var e=this.value;return this.value=t(e),this},e}(he),pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.items=t},e.prototype.getValue=function(t){var e=this.items;return e[Math.floor(Math.random()*e.length)]},e.prototype.map=function(t){return this.items=this.items.map(t),this},e}(he),de=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.min=t[0],this.max=t[1]},e.prototype.getValue=function(t){return Ye(this.min,this.max)},e.prototype.toUniform=function(){return new Float32Array([4,this.min,this.max,0])},e.prototype.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},e}(he),me=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.min=t[0],this.max=t[1]},e.prototype.getValue=function(t){for(var e=this.min,r=this.max,i=[],n=0;n<e.length;n++){var o=Math.random();i[n]=e[n]*(1-o)+r[n]*o}return i},e.prototype.map=function(t){return this.min=this.min.map(t),this.max=this.max.map(t),this},e}(he),ve=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.min=t[0],this.max=t[1],this.xCoord=1},e.prototype.getValue=function(t){return t/=this.xCoord,this.min*(1-t)+this.max*t},e.prototype.toUniform=function(){return new Float32Array([1,this.min,this.max,this.xCoord])},e.prototype.getIntegrateValue=function(t,e,r){void 0===r&&(r=1);var i=this.min,n=this.max,o=this.xCoord*r;return((i+e/o*(n-i)+i)*e-(i+t/o*(n-i)+i)*t)/2},e.prototype.getIntegrateByTime=function(t,e){return _e(e,0,this.xCoord,this.min,this.max)-_e(t,0,this.xCoord,this.min,this.max)},e.prototype.map=function(t){return this.min=t(this.min),this.max=t(this.max),this},e.prototype.scaleXCoord=function(t){return this.xCoord=t,this},e}(he),ye=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.stops=H(t)},e.prototype.getStops=function(){return this.stops},e.prototype.getValue=function(t){for(var e=this.stops,r=e.length-1,i=0;i<r;i++){var n=e[i],o=e[i+1];if(n.stop<=t&&o.stop>t){var s=(t-n.stop)/(o.stop-n.stop);return Y(n.color,o.color,s,!0)}}return e[r].color.slice()},e}(he),ge=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.getAllData=function(t,e){for(var r=new(e?Zt:Float32Array)(4*t.index),i=0,n=0,o=t.curves;i<o.length;i++){var s=o[i].toData();r.set(s,n),n+=s.length}return e?r.data:r},e.prototype.onCreate=function(t){var e=1/0,r=-1/0;if(Number.isFinite(t[0])&&Number.isFinite(t[1])){for(var i=[],n=2;n<t.length;n++)i.push(t[n].slice(0,4));this.keys=i,this.min=t[0],this.dist=t[1]-t[0]}else{i=t.map((function(t){if(Ge(t))return e=Math.min(e,t[1]),r=Math.max(r,t[1]),t.slice(0,4);if("object"==typeof t&&t){var i=t,n=i.time,o=i.value,s=i.inTangent,a=void 0===s?0:s,u=i.outTangent,l=void 0===u?0:u;return e=Math.min(e,o),r=Math.max(r,o),[n,o,a,l]}throw new Error("invalid keyframe")}));var o=r-e;if(this.keys=i,0!==o)for(n=0;n<i.length;n++){var s=i[n];s[1]=(s[1]-e)/o}var a=i[0];a[0]>0&&(a[2]=0,i.unshift([0,a[1],0,0]));var u=i[i.length-1];u[0]<1&&(u[3]=0,i.push([1,u[1],0,0])),this.min=e,this.dist=o}this.isCurveValue=!0},e.prototype.getValue=function(t){var e=this,r=e.keys,i=e.min,n=e.dist,o=r;if(t<=o[0][0])return o[0][1]*n+i;for(var s=o.length-1,a=0;a<s;a++){var u=o[a],l=o[a+1];if(t>u[0]&&t<=l[0])return Ce(t,u,l)*n+i}return o[s][1]*n+i},e.prototype.getIntegrateByTime=function(t,e){var r=this.integrate(e,!0)-this.integrate(t,!0);return.5*this.min*(e-t)*(e-t)+r*this.dist},e.prototype.getIntegrateValue=function(t,e,r){r=r||1;var i=(this.integrate(e/r,!1)-this.integrate(t/r,!1))*r,n=(e-t)/r;return this.min*n+i*this.dist},e.prototype.integrate=function(t,e){var r=this.keys;if(t<=r[0][0])return 0;for(var i=0,n=r.length-1,o=e?Oe:Re,s=0;s<n;s++){var a=r[s],u=r[s+1],l=a[0],c=u[0];if(t>l&&t<=c)return i+o(t,a,u);i+=o(c,a,u)}return i},e.prototype.toData=function(){for(var t=this.keys,e=new Float32Array(4*t.length),r=0,i=0;r<t.length;r++,i+=4)e.set(t[r],i);return e},e.prototype.toUniform=function(t){var e=t.index,r=this.keys;return t.curves.push(this),t.index+=r.length,t.max=Math.max(t.max,r.length),t.curveCount+=r.length,new Float32Array([2,e+1/r.length,this.min,this.dist])},e.prototype.map=function(t){return this.keys.forEach((function(e){e[1]=t(e[1])})),this},e.prototype.scaleXCoord=function(t){return this.keys.forEach((function(e){return e[0]=t*e[0]})),this},e}(he),xe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.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 r=this.keys[0];r[0]>0&&this.keys.unshift([0,r[1]]),this.isLineSeg=!0},e.prototype.getValue=function(t){var e=this.keys;if(t<e[0][0])return e[0][1];for(var r=e.length-1,i=0;i<r;i++){var n=e[i],o=e[i+1],s=n[0],a=o[0];if(t>=s&&t<=a){var u=(t-s)/(a-s),l=n[1];return l+u*(o[1]-l)}}return e[r][1]},e.prototype.getIntegrateValue=function(t,e,r){return void 0===r&&(r=1),(this.integrate(e,!1)-this.integrate(t,!1))*r},e.prototype.getIntegrateByTime=function(t,e){return this.integrate(e,!0)-this.integrate(t,!0)},e.prototype.integrate=function(t,e){var r=this.keys;if(t<=r[0][0])return 0;for(var i=0,n=r.length-1,o=e?_e:Ae,s=0;s<n;s++){var a=r[s],u=r[s+1],l=a[0],c=u[0];if(t>l&&t<=c)return i+o(t,l,c,a[1],u[1]);i+=o(c,l,c,a[1],u[1])}return i},e.prototype.toData=function(){for(var t=this.keys,e=new Float32Array(4*Math.ceil(t.length/2)),r=0,i=0;r<t.length;r++,i+=2)e.set(t[r],i);return e.set(t[t.length-1],e.length-2),e},e.prototype.toUniform=function(t){var e=t.index,r=this.keys,i=Math.ceil(r.length/2);return t.lineSegCount+=i,t.curves.push(this),t.index+=i,t.max=Math.max(t.max,i),new Float32Array([3,e,i,0])},e.prototype.map=function(t){return this.keys.forEach((function(e){return e[1]=t(e[1])})),this},e.prototype.scaleXCoord=function(t){return this.keys.forEach((function(e){return e[0]=t*e[0]})),this},e}(he),Te=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(t){this.keys=t[0],this.values=t[1]},e.prototype.getValue=function(t){for(var e=this.keys,r=this.values,i=0;i<e.length-1;i++){var n=e[i],o=e[i+1];if(n[0]<=t&&o[0]>=t){var s=o[1]-n[1],a=void 0;if(0===s)a=(t-n[0])/(o[0]-n[0]);else a=(Ce(t,n,o)-n[1])/s;return this.calculateVec(i,a)}}return t<=e[0][0]?r[0].slice():r[r.length-1].slice()},e.prototype.calculateVec=function(t,e){for(var r=this.values[t],i=this.values[t+1],n=[0,0,0],o=0;o<r.length;o++)n[o]=r[o]*(1-e)+i[o]*e;return n},e}(he),Ee=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.onCreate=function(e){t.prototype.onCreate.call(this,e),this.cps=e[2]},e.prototype.calculateVec=function(t,e){for(var r=this.values[t],i=this.values[t+1],n=this.cps[t+t],o=this.cps[t+t+1],s=[0,0,0],a=1-e,u=a*a*a,l=3*e*a*a,c=3*e*e*a,h=e*e*e,f=0;f<r.length;f++)s[f]=u*r[f]+l*n[f]+c*o[f]+h*i[f];return s},e}(Te),Se=((ne={})[ot.RANDOM]=function(t){return t[0]instanceof Array?new me(t):new de(t)},ne[ot.CONSTANT]=function(t){return new fe(t)},ne[ot.CONSTANT_VEC2]=function(t){return new fe(t)},ne[ot.CONSTANT_VEC3]=function(t){return new fe(t)},ne[ot.CONSTANT_VEC4]=function(t){return new fe(t)},ne[ot.CURVE]=function(t){return new ge(t)},ne[ot.RGBA_COLOR]=function(t){return new fe(t)},ne[ot.COLORS]=function(t){return new pe(t.map((function(t){return G(t,!1)})))},ne[ot.LINE]=function(t){return 2===t.length&&0===t[0][0]&&1===t[1][0]?new ve([t[0][1],t[1][1]]):new xe(t)},ne[ot.GRADIENT_COLOR]=function(t){return new ye(t)},ne[ot.LINEAR_PATH]=function(t){return new Te(t)},ne[ot.BEZIER_PATH]=function(t){return new Ee(t)},ne);function be(t){if(!t||!isNaN(+t))return new fe(t||0);if(t instanceof he)return t;if(Xe(Se[t[0]]))return Se[t[0]](t[1]);throw new Error("ValueType: ".concat(t[0]," is not support"))}function Ae(t,e,r,i,n){var o=t-e;return(i+i+(n-i)*o/(r-e))*o/2}function _e(t,e,r,i,n){var o=t*t,s=e*e;return(2*(o*t)*(i-n)+3*o*(e*n-r*i)-s*e*(2*i+n)+3*s*r*i)/(6*(e-r))}function Ce(t,e,r){var i=r[0]-e[0],n=e[3]*i,o=r[2]*i,s=(t-e[0])/i,a=s*s,u=a*s,l=u-2*a+s,c=u-a,h=-2*u+3*a;return(2*u-3*a+1)*e[1]+l*n+c*o+h*r[1]}function Re(t,e,r){var i=r[0]-e[0],n=e[3]*i,o=r[2]*i,s=e[0],a=e[1],u=r[1],l=s-t,c=l*l,h=c*l;return(n+o+2*a-2*u)*h*l/(4*i*i*i)+(2*n+o+3*a-3*u)*h/(3*i*i)+n*c/2/i-a*l}function Oe(t,e,r){var i=r[0]-e[0],n=e[3]*i,o=r[2]*i,s=e[0],a=e[1],u=r[1],l=s-t,c=l*l,h=c*l,f=i*i,p=f*i;return(-30*p*a*(s+t)*l+10*f*n*(s+2*t)*c+5*i*(s+3*t)*(2*n+o+3*a-3*u)*h+3*(s+4*t)*(n+o+2*a-2*u)*h*l)/60/p}function we(t,e){if(e){var r=e[0],i=e[1];if(r===ot.CURVE){t.curves.push(i);var n=i.length;i[0][0]>0&&n++,i[i.length-1][0]<1&&n++,t.index+=n,t.max=Math.max(t.max,n),t.curveCount+=n}else if(r===ot.LINE){if(2===(n=i.length)&&0===i[0][0]&&1===i[1][0])return;i[0][0]>0&&n++,i[i.length-1][0]<1&&n++;var o=Math.ceil(n/2);t.lineSegCount+=o,t.curves.push(i),t.index+=o,t.max=Math.max(t.max,o)}}}function Me(){return{curves:[],index:0,max:0,lineSegCount:0,curveCount:0}}var Le,Ie=new Dt,Pe=new Mt(1,1,1),Fe=new Mt(0,0,0),Ne=function(){function t(t,e){var r,i=t.positionOverLifetime,n=void 0===i?{}:i,o=e.transform,s=e.duration,a=e.endBehavior,u=o.scale;this.transform=o,this.basicTransform={position:o.position.clone(),rotation:o.getRotation(),scale:u},n.path&&(this.basicTransform.path=be(n.path)),this.positionOverLifetime=n,this.options={startSpeed:n.startSpeed||0,startSize:u&&u.x||1,sizeAspect:u&&u.x/(u.y||1)||1,startColor:[1,1,1,1],duration:s||0,looping:a&&a===at.loop,gravity:Mt.fromArray(n.gravity||[]),gravityModifier:be(null!==(r=n.gravityOverLifetime)&&void 0!==r?r:0),direction:n.direction?Mt.fromArray(n.direction).normalize():new Mt,endBehavior:a||0};var l=t.sizeOverLifetime;l&&(l.separateAxes?(this.sizeSeparateAxes=!0,this.sizeXOverLifetime=be(l.x||1),this.sizeYOverLifetime=be(l.y||1),this.sizeZOverLifetime=be(l.z||1)):this.sizeXOverLifetime=be(l.size||1));var c=n.linearX||n.linearY||n.linearZ;c&&(this.linearVelOverLifetime={x:n.linearX&&be(n.linearX),y:n.linearY&&be(n.linearY),z:n.linearZ&&be(n.linearZ),asMovement:n.asMovement,enabled:!!c});var h=n.orbitalX||n.orbitalY||n.orbitalZ;h&&(this.orbitalVelOverLifetime={x:n.orbitalX&&be(n.orbitalX),y:n.orbitalY&&be(n.orbitalY),z:n.orbitalZ&&be(n.orbitalZ),center:$t(n.orbCenter),asRotation:n.asRotation,enabled:!!h}),this.speedOverLifetime=n.speedOverLifetime&&be(n.speedOverLifetime);var f=t.rotationOverLifetime;if(f&&(this.rotationOverLifetime={asRotation:f.asRotation,separateAxes:f.separateAxes,z:be(f.z||0)},f.separateAxes)){var p=this.rotationOverLifetime;p.x=be(f.x||0),p.y=be(f.y||0)}this.gravityModifier=this.options.gravityModifier}return t.prototype.getVelocity=function(){return this.velocity||(this.velocity=this.options.direction.clone().multiply(this.options.startSpeed)),this.velocity},t.prototype.willTranslate=function(){return!!(this.linearVelOverLifetime&&this.linearVelOverLifetime.enabled||this.orbitalVelOverLifetime&&this.orbitalVelOverLifetime.enabled||this.options.gravityModifier&&!this.options.gravity.isZero()||this.options.startSpeed&&!this.options.direction.isZero())},t.prototype.updatePosition=function(t,e,r){this.basicTransform.position.set(t,e,r)},t.prototype.updateRotation=function(t,e,r){this.basicTransform.rotation.set(t,e,r)},t.prototype.getRenderData=function(t,e){var r,i,n=this.options,o=Pe.setFromNumber(1),s=Ie.set(0,0,0),a=t<0?t:Math.max(t,0),u=n.duration,l=a/u,c={life:l,transform:this.transform,startSize:this.basicTransform.scale.clone()},h=this.basicTransform;l=l<0?0:l>1?1:l,this.sizeXOverLifetime&&(o.x=this.sizeXOverLifetime.getValue(l),this.sizeSeparateAxes?(o.y=this.sizeYOverLifetime.getValue(l),o.z=this.sizeZOverLifetime.getValue(l)):o.z=o.y=o.x,r=!0),(r||e)&&c.transform.setScale(o.x,o.y,o.z);var f,p=this.rotationOverLifetime;if(p){var d=function(t){return p.asRotation?t.getValue(l):t.getIntegrateValue(0,l,u)},m=d(p.z),v=p.separateAxes;s.x=v?d(p.x):0,s.y=v?d(p.y):0,s.z=m,i=!0}if(i||e){var y=Ie.addEulers(h.rotation,s);c.transform.setRotation(y.x,y.y,y.z)}(this.willTranslate()||e)&&(f=Jt(Pe.setFromNumber(0),this,n.gravity,a,u,h.position,this.getVelocity()));if(h.path&&(f||(f=Fe.copyFrom(h.position)),f.add(h.path.getValue(l))),f&&c.transform.setPosition(f.x,f.y,f.z),c.startSize){var g=c.transform.scale;c.transform.setScale(g.x*c.startSize.x,g.y*c.startSize.y,g.z*c.startSize.z)}return c},t}(),Ve="[Galacean Effects]";function De(t){return["%c".concat(Ve),"background: #AA0100; color: white","".concat(t)]}var ze,Be={error:function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];console.error.apply(console,u(u([],a(De(t)),!1),[e],!1)),null==Le||Le("error",t,e)},info:function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];console.debug.apply(console,u([],a(De(t)),!1)),null==Le||Le("info",t,e)},warn:function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];console.warn.apply(console,u([],a(De(t)),!1)),null==Le||Le("warn",t,e)},register:function(t){t&&Xe(t)&&(Le=t)}};function Ue(){}function ke(t){return"string"==typeof t}t.DestroyOptions=void 0,(ze=t.DestroyOptions||(t.DestroyOptions={}))[ze.destroy=0]="destroy",ze[ze.keep=1]="keep",ze[ze.force=0]="force";var Ge=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function Xe(t){return"[object Function]"===Object.prototype.toString.call(t)}function He(t){return"[object Object]"===Object.prototype.toString.call(t)}function Ye(t,e){return t+Math.random()*(e-t)}function je(){throw Error("destroyed item cannot be used again")}var We,Ze=new Lt,qe=1,Ke=function(){function t(t,e){void 0===t&&(t={}),this.position=new Mt(0,0,0),this.quat=new Lt(0,0,0,1),this.rotation=new Dt(0,0,0),this.scale=new Mt(1,1,1),this.anchor=new Mt(0,0,0),this.children=[],this.worldMatrix=Ft.fromIdentity(),this.localMatrix=Ft.fromIdentity(),this.valid=!1,this.dirtyFlags={localData:!1,localMatrix:!1,worldMatrix:!1,parentMatrix:!1},this.worldTRSCache={position:new Mt(0,0,0),quat:new Lt(0,0,0,1),scale:new Mt(1,1,1)},this.name="transform_".concat(qe++),t&&this.setTransform(t),e&&(this.parentTransform=e),void 0!==t.valid&&this.setValid(t.valid)}return t.getRotation=function(t,e){var r=Ze.copyFrom(t);return r.conjugate(),e.setFromQuaternion(r)},Object.defineProperty(t.prototype,"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)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parentMatrixDirty",{get:function(){return this.dirtyFlags.parentMatrix},set:function(t){this.dirtyFlags.parentMatrix!==t&&(this.dirtyFlags.parentMatrix=t,this.dispatchValueChange())},enumerable:!1,configurable:!0}),t.prototype.setPosition=function(t,e,r){this.position.x===t&&this.position.y===e&&this.position.z===r||(this.position.x=t,this.position.y=e,this.position.z=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.translate=function(t,e,r){0===t&&0===e&&0===r||(this.position.x+=t,this.position.y+=e,this.position.z+=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setRotation=function(t,e,r){this.rotation.x===t&&this.rotation.y===e&&this.rotation.z===r||(this.rotation.x=t,this.rotation.y=e,this.rotation.z=r,this.quat.setFromEuler(this.rotation),this.quat.conjugate(),this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setQuaternion=function(t,e,r,i){this.quat.x===t&&this.quat.y===e&&this.quat.z===r&&this.quat.w===i||(this.quat.x=t,this.quat.y=e,this.quat.z=r,this.quat.w=i,this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setScale=function(t,e,r){this.scale.x===t&&this.scale.y===e&&this.scale.z===r||(this.scale.x=t,this.scale.y=e,this.scale.z=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.rotateByQuat=function(t){this.quat.multiply(t),this.rotation.setFromQuaternion(this.quat),this.dirtyFlags.localData=!0,this.dispatchValueChange()},t.prototype.scaleBy=function(t,e,r){this.scale.x*=t,this.scale.y*=e,this.scale.z*=r,this.dirtyFlags.localData=!0,this.dispatchValueChange()},t.prototype.setAnchor=function(t,e,r){this.anchor.x===t&&this.anchor.y===e&&this.anchor.z===r||(this.anchor.x=t,this.anchor.y=e,this.anchor.z=r,this.dirtyFlags.localData=!0,this.dispatchValueChange())},t.prototype.setTransform=function(t,e){var r,i=t.position,n=t.rotation,o=t.scale,s=t.quat,a=t.name,u=t.anchor;if(a&&(this.name=a),i&&(i instanceof Mt?this.setPosition(i.x,i.y,i.z):this.setPosition(i[0],i[1],i[2])),s)s instanceof Lt?this.setQuaternion(s.x,s.y,s.z,s.w):this.setQuaternion(s[0],s[1],s[2],s[3]);else if(n){var l=e?-1:1;n instanceof Dt?this.setRotation(n.x*l,n.y*l,n.z*l):this.setRotation(n[0]*l,n[1]*l,n[2]*l)}o&&(o instanceof Mt?this.setScale(o.x,o.y,o.z):this.setScale(o[0],o[1],o[2])),u&&(u instanceof Mt?this.setAnchor(u.x,u.y,u.z):this.setAnchor(u[0],u[1],null!==(r=u[2])&&void 0!==r?r:0))},t.prototype.addChild=function(t){z(this.children,t)},t.prototype.removeChild=function(t){B(this.children,t)},t.prototype.getRotation=function(){return t.getRotation(this.quat,new Dt)},t.prototype.getQuaternion=function(){return this.quat},t.prototype.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)},t.prototype.getMatrix=function(){return this.updateLocalMatrix(),this.localMatrix},t.prototype.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},t.prototype.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},t.prototype.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()},t.prototype.getWorldPosition=function(){return this.updateTRSCache(),this.worldTRSCache.position.clone()},t.prototype.getWorldRotation=function(){return this.updateTRSCache(),t.getRotation(this.worldTRSCache.quat,new Dt)},t.prototype.assignWorldTRS=function(t,e,r){this.updateTRSCache(),t&&t.copyFrom(this.worldTRSCache.position),e&&e.copyFrom(this.worldTRSCache.quat),r&&r.copyFrom(this.worldTRSCache.scale)},t.prototype.cloneFromMatrix=function(t,e){t.decompose(this.position,this.quat,this.scale),e&&e.copyFrom(this.scale),this.dirtyFlags.localData=!0,this.dispatchValueChange()},t.prototype.setValid=function(t){this.valid!==t&&(this.valid=t,t?this.dirtyFlags.localData=!0:(this.localMatrix.identity(),this.dirtyFlags.localMatrix=!0),this.dispatchValueChange())},t.prototype.getValid=function(){return this.valid},t.prototype.dispose=function(){},t.prototype.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}},t.prototype.dispatchValueChange=function(){this.children.forEach((function(t){t.parentMatrixDirty=!0}))},t}(),Qe=function(){function t(t,e){this._v_priority=0,this.visible=!0,this._contentVisible=!1,this.timeInms=0,this.time=0,this._frozen=!1;var r=t.id,n=t.name,o=t.delay,s=t.parentId,a=t.endBehavior,u=t.transform,l=t.listIndex,c=void 0===l?0:l,h=t.duration,p=void 0===h?0:h;if(this.composition=e,this.id=r,this.name=n,this.delay=o,this.transform=new Ke(i({name:this.name},u),e.transform),this.parentId=s,this.duration=p,this.delayInms=1e3*(o||0),this.durInms=1e3*this.duration,this.endBehavior=a,this.lifetime=-this.delayInms/this.durInms,this.listIndex=c,this.speed=1,this.onConstructed(t),p<=0)throw Error("Item duration can't be less than 0, see ".concat(f["Item duration can't be less than 0"]))}return t.isComposition=function(t){return t.type===w.composition},t.isSprite=function(t){return t.type===w.sprite},t.isParticle=function(t){return t.type===w.particle},t.isFilterSprite=function(t){return t.type===w.filter},t.isNull=function(t){return t.type===w.null},t.isTree=function(t){return t.type===w.tree},t.isCamera=function(t){return t.type===w.camera},t.isExtraCamera=function(t){return"extra-camera"===t.id&&"extra-camera"===t.name},Object.defineProperty(t.prototype,"contentVisible",{get:function(){return this._contentVisible&&this.visible},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"content",{get:function(){return this._content},set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reusable",{get:function(){var t,e;return null!==(e=null===(t=this.composition)||void 0===t?void 0:t.reusable)&&void 0!==e&&e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return w.base},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frozen",{get:function(){return this._frozen},set:function(t){this.handleFrozenChanged(this._frozen=!!t)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lifetimeStarted",{get:function(){return this.started&&!this.delaying},enumerable:!1,configurable:!0}),t.prototype.setSpeed=function(t){this.speed=t},t.prototype.getSpeed=function(){return this.speed},t.prototype.start=function(){this.started&&!this.ended||(this.started=!0,this.delaying=!0,this.timeInms=0,this.time=0,this.callEnd=!1,this.ended=!1)},t.prototype.stop=function(){this.doStop(),this.started=!1},t.prototype.doStop=function(){this._content&&this._content.stop&&this._content.stop()},t.prototype.createContent=function(){return this._content||(this._content=this.doCreateContent(this.composition)),this._content},t.prototype.doCreateContent=function(t){},t.prototype.onConstructed=function(t){},t.prototype.onUpdate=function(t){var e,r;if(this.started&&!this.frozen&&this.composition){var i=t*this.speed,n=this.timeInms+=i;this.time+=i/1e3;var o=n-this.delayInms;if(this.delaying&&o>=0&&(this.delaying=!1,this.transform.setValid(!0),this.createContent(),this._contentVisible=!0,this.onLifetimeBegin(this.composition,this.content),this.composition.itemLifetimeEvent(this,!0)),!this.delaying){var s=o/this.durInms,a=this.isEnded(o),u=!0;if(this.transform.setValid(!0),a)if(u=!1,this.callEnd||(this.callEnd=!0,this.composition.itemLifetimeEvent(this,!1),this.onEnd()),2!==this.endBehavior&&5!==this.endBehavior){if(this.ended=!0,this.transform.setValid(!1),1===this.endBehavior||3===this.endBehavior?null===(r=(e=this.composition).onPlayerPause)||void 0===r||r.call(e,this):4===this.endBehavior&&(this.transform.setValid(!0),u=!0,s=1,i=0),this.reusable)0===this.endBehavior&&(this._contentVisible=!1,u=!0,i=0,this.type===w.composition&&this.handleVisibleChanged(!1));else{if(0===this.endBehavior||3===this.endBehavior||6===this.endBehavior)return this.dispose();1===this.endBehavior&&(this.endBehavior=2)}s=Math.min(s,1)}else u=!0,5===this.endBehavior&&(this.ended=!0);else this.callEnd&&this.reusable&&(this.setVisible(!0),this.callEnd=!1);this.lifetime=s%1,u&&this.onItemUpdate(i,s)}}},t.prototype.onItemRemoved=function(t,e){},t.prototype.onItemUpdate=function(t,e){},t.prototype.onLifetimeBegin=function(t,e){},t.prototype.onEnd=function(){},t.prototype.setColor=function(t,e,r,i){},t.prototype.setOpacity=function(t){},t.prototype.getVisible=function(){return this.visible},t.prototype.setVisible=function(t){this.visible!==t&&(this.visible=!!t,this.handleVisibleChanged(this.visible))},t.prototype.handleVisibleChanged=function(t){},t.prototype.handleFrozenChanged=function(t){},t.prototype.getWorldTransform=function(t){var e=null!=t?t:new Ke({valid:!0});return e.cloneFromMatrix(this.transform.getWorldMatrix()),e},t.prototype.getNodeTransform=function(t){return this.transform},t.prototype.translate=function(t,e,r){this.transform.translate(t,e,r)},t.prototype.rotate=function(t,e,r){var i=new Dt(t,e,r),n=Lt.fromEuler(i);n.conjugate(),this.transform.rotateByQuat(n)},t.prototype.scale=function(t,e,r){this.transform.scaleBy(t,e,r)},t.prototype.setPositionByPixel=function(t,e){if(this.composition){var r=this.transform.getWorldPosition().z,i=this.composition.camera.getInverseVPRatio(r),n=i.x,o=i.y,s=this.composition.renderer.getWidth()/2,a=this.composition.renderer.getHeight()/2;this.transform.setPosition(2*t*n/s,-2*e*o/a,r)}},t.prototype.setPosition=function(t,e,r){this.transform.setPosition(t,e,r)},t.prototype.setRotation=function(t,e,r){this.transform.setRotation(t,e,r)},t.prototype.setScale=function(t,e,r){this.transform.setScale(t,e,r)},t.prototype.getBoundingBox=function(){},t.prototype.getHitTestParams=function(t){},t.prototype.getRenderData=function(){return{transform:this.transform,life:0,visible:this.visible}},t.prototype.getCurrentPosition=function(){var t=new Mt;return this.transform.assignWorldTRS(t),t},t.prototype.isEnded=function(t){return t-this.durInms>.001},t.prototype.reset=function(){this.composition&&(this.onItemRemoved(this.composition,this._content),this._content=void 0,this._contentVisible=!1),this.started=!1},t.prototype.translateByPixel=function(t,e){if(this.composition){var r=this.composition.renderer.canvas.getBoundingClientRect(),i=r.width,n=r.height,o=this.transform.getWorldPosition().z,s=this.composition.camera.getInverseVPRatio(o),a=s.x,u=s.y;this.transform.translate(2*t*a/i,-2*e*u/n,0)}},t.prototype.dispose=function(){this.composition&&(this.composition.destroyItem(this),this.reset(),this.onUpdate=function(){return-1},this.composition=null,this._contentVisible=!1,this.transform.setValid(!1))},t}();function Je(t,e){var r=t.type,i=t.pluginName;if(!i)switch(r){case w.null:case w.base:i="cal";break;case w.sprite:i="sprite";break;case w.particle:i="particle";break;case w.interact:i="interact";break;case w.camera:i="camera";break;case w.filter:i="filter";break;case w.text:i="text";break;case w.tree:i="tree";break;default:throw new Error("invalid vfx item type")}return e.pluginSystem.createPluginItem(i,t,e)}t.Item=void 0,(We=t.Item||(t.Item={})).is=function(t,e){return t.type===e},We.isFilter=function(t){return t.type===w.filter},We.isComposition=function(t){return t.type===w.composition},We.isParticle=function(t){return t.type===w.particle},We.isNull=function(t){return t.type===w.null};var $e={},tr=[],er={};function rr(t,e,r,i){er[t]=r,$e[t]=e,i&&z(tr,t)}var ir=function(){function t(t){var e={},r=[],i=function(t){var i=$e[t];r.includes(i)||(r.push(i),e[t]=i)};tr.forEach(i),t.forEach(i),this.plugins=Object.keys(e).map((function(t){var e=$e[t];if(!e)throw new Error("plugin '".concat(t,"' not found.")+function(t){var e=nr[t];return e?"\nInstall Plugin: npm i ".concat(e,"@latest --save\nImport Plugin: import '").concat(e,"'"):""}(t));var r=new e;return r.name=t,r})).sort((function(t,e){return t.order-e.order}))}return t.prototype.initializeComposition=function(t,e){this.plugins.forEach((function(r){return r.onCompositionConstructed(t,e)}))},t.prototype.destroyComposition=function(t){this.plugins.forEach((function(e){return e.onCompositionDestroyed(t)}))},t.prototype.resetComposition=function(t,e){this.plugins.forEach((function(r){return r.onCompositionReset(t,e)}))},t.prototype.createPluginItem=function(t,e,r){var i=er[t];if(!i)throw new Error("plugin ".concat(t," no registered constructor"));var n=new i(e,r);if(!(n instanceof Qe))throw new Error("plugin ".concat(t," invalid constructor type"));return n},t.prototype.processRawJSON=function(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){return[2,this.callStatic("processRawJSON",t,e)]}))}))},t.prototype.callStatic=function(t){for(var e=[],r=1;r<arguments.length;r++)e[r-1]=arguments[r];return n(this,void 0,void 0,(function(){var r,i,n,s,l;return o(this,(function(o){for(r=[],i=this.plugins,n=0;n<i.length;n++)s=i[n],l=$e[s.name],t in l&&r.push(Promise.resolve(l[t].apply(l,u([],a(e),!1))));return[2,Promise.all(r)]}))}))},t.prototype.precompile=function(t,e,r){return n(this,void 0,void 0,(function(){return o(this,(function(i){return[2,this.callStatic("precompile",t,e,r)]}))}))},t.prototype.loadResources=function(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){return[2,this.callStatic("prepareResource",t,e)]}))}))},t}(),nr={"alipay-downgrade":"@galacean/effects-plugin-alipay-downgrade","editor-gizmo":"@galacean/effects-plugin-editor-gizmo",tree:"@galacean/effects-plugin-model",model:"@galacean/effects-plugin-model","orientation-transformer":"@galacean/effects-plugin-orientation-transformer",spine:"@galacean/effects-plugin-spine"};var or,sr=function(){function t(){this.order=100,this.name=""}return t.precompile=function(t,e){return Promise.resolve()},t.prototype.onCompositionConstructed=function(t,e){},t.prototype.onCompositionItemLifeBegin=function(t,e){},t.prototype.onCompositionItemLifeEnd=function(t,e){},t.prototype.onCompositionItemRemoved=function(t,e){},t.prototype.onCompositionReset=function(t,e){},t.prototype.onCompositionWillReset=function(t,e){},t.prototype.onCompositionDestroyed=function(t){},t.prototype.onCompositionUpdate=function(t,e){},t.prototype.prepareRenderFrame=function(t,e){return!1},t.prototype.postProcessFrame=function(t,e){},t}(),ar=function(){function t(t,e){this.transform=t;var r=t.position,i=t.getRotation(),n=e.options,o=n.near,s=n.far,a=n.fov,u=n.clipMode;if(this.clipMode=u,this.options={position:r.clone(),rotation:i.clone(),near:be(o),far:be(s),fov:be(a)},e.positionOverLifetime){var l=e.positionOverLifetime,c=l.path,h=l.linearX,f=void 0===h?0:h,p=l.linearY,d=void 0===p?0:p,m=l.linearZ,v=void 0===m?0:m;this.translateOverLifetime={path:c&&be(c),x:be(f),y:be(d),z:be(v)}}if(e.rotationOverLifetime){var y=e.rotationOverLifetime,g=y.separateAxes,x=y.x,T=void 0===x?0:x,E=y.y,S=void 0===E?0:E,b=y.z,A=void 0===b?0:b;this.rotationOverLifetime={separateAxes:g,x:be(T),y:be(S),z:be(A)}}}return t.prototype.update=function(t){var e=new Lt,r=new Mt,i=new Dt;r.copyFrom(this.options.position),i.copyFrom(this.options.rotation);var n=this.translateOverLifetime,o=this.rotationOverLifetime;if(t=Rt(t,0,1),n&&(r.x+=n.x.getValue(t),r.y+=n.y.getValue(t),r.z+=n.z.getValue(t),n.path)){var s=n.path.getValue(t);r.x+=s[0],r.y+=s[1],r.z+=s[2]}if(o){var a=o.z.getValue(t);i.z+=a,o.separateAxes?(i.x+=o.x.getValue(t),i.y+=o.y.getValue(t)):(i.x+=a,i.y+=a)}this.far=this.options.far.getValue(t),this.near=this.options.near.getValue(t),this.fov=this.options.fov.getValue(t),this.transform.setPosition(r.x,r.y,r.z),this.transform.setRotation(i.x,i.y,i.z),this.transform.assignWorldTRS(r,e),this.position=r,this.rotation=Ke.getRotation(e,i)},t}(),ur=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(sr),lr=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return w.camera},enumerable:!1,configurable:!0}),e.prototype.onConstructed=function(t){this.model=t.content},e.prototype.onItemUpdate=function(t,e){var r;null===(r=this.controller)||void 0===r||r.update(e),this.updateCamera()},e.prototype.updateCamera=function(){if(this.controller&&this.composition){var t=this.composition.camera;t.near=this.controller.near,t.far=this.controller.far,t.fov=this.controller.fov,t.clipMode=this.controller.clipMode,t.position=this.controller.position,t.rotation=this.controller.rotation}},e.prototype.getCurrentPosition=function(){return this.controller.position},e.prototype.doCreateContent=function(){return this.controller||(this.controller=new ar(this.transform,this.model)),this.controller},e}(Qe);t.HitTestType=void 0,(or=t.HitTestType||(t.HitTestType={}))[or.triangle=1]="triangle",or[or.box=2]="box",or[or.sphere=3]="sphere",or[or.custom=4]="custom";var cr,hr,fr="click",pr="touchstart",dr="touchmove",mr="touchend",vr=O,yr=function(){function t(t,e){void 0===e&&(e=!1),this.target=t,this.allowPropagation=e,this.enabled=!0,this.handlers={},this.nativeHandlers={}}return t.prototype.bindListeners=function(){var t,e,r,i,n,o,s=this;o=function(t){return t};var a="mousedown",u="mousemove",l="mouseup",c=function(t,e,r,i,o){void 0===i&&(i=0),void 0===o&&(o=0);var a=s.target,u=a.width,l=a.height,c=performance.now(),h=0,f=0;if(n){var p=c-n.ts;h=(i-n.dx)/p||0,f=(o-n.dy)/p||0,n={dx:i,dy:o,ts:c}}return{x:e,y:r,vx:h,vy:f,dx:i,dy:o,ts:c,width:u,height:l,origin:t}};q()&&(o=function(t){var e=t,r=e.touches,i=e.changedTouches;return r[0]||i[0]},a="touchstart",u="touchmove",l="touchend"),this.nativeHandlers=((t={})[a]=function(t){if(s.enabled){var a=o(t),u=gr(a);e=u.x,r=u.y,n=i={clientX:a.clientX,clientY:a.clientY,ts:performance.now(),x:e,y:r},s.dispatchEvent(pr,c(t,e,r))}},t[u]=function(t){if(i&&s.enabled){var n=gr(o(t));e=n.x,r=n.y,s.dispatchEvent(dr,c(t,e,r,e-i.x,r-i.y))}},t[l]=function(t){if(i&&s.enabled){!s.allowPropagation&&t.cancelable&&(t.preventDefault(),t.stopPropagation());var n=o(t),a=gr(n),u=Math.abs(i.clientX-n.clientX)+Math.abs(i.clientY-n.clientY);e=a.x,r=a.y,u<4&&s.dispatchEvent(fr,c(t,e,r)),s.dispatchEvent(mr,c(t,e,r,e-i.x,r-i.y))}i=0},t),Object.keys(this.nativeHandlers).forEach((function(t){var e;null===(e=s.target)||void 0===e||e.addEventListener(String(t),s.nativeHandlers[t])}))},t.prototype.dispatchEvent=function(t,e){var r=this.handlers[t];null==r||r.forEach((function(t){return t(e)}))},t.prototype.addEventListener=function(t,e){var r=this.handlers[t];return r||(r=this.handlers[t]=[]),z(r,e),function(){B(r,e)}},t.prototype.removeEventListener=function(t,e){var r=this.handlers[t];r&&B(r,e)},t.prototype.dispose=function(){var t=this;this.target&&(this.handlers={},Object.keys(this.nativeHandlers).forEach((function(e){var r;null===(r=t.target)||void 0===r||r.removeEventListener(String(e),t.nativeHandlers[e])})),this.nativeHandlers={},this.target=null)},t}();function gr(t){var e=t.target,r=t.clientX,i=t.clientY,n=e.getBoundingClientRect(),o=n.left,s=n.top;return{x:(r-o)/n.width*2-1,y:1-(i-s)/n.height*2}}function xr(t){switch(t){case S.ALPHA:case S.ADD:case S.SUBTRACTION:case S.STRONG_LIGHT:case S.WEAK_LIGHT:return 1;case S.SUPERPOSITION:return 2;case S.BRIGHTNESS:return 3;case S.MULTIPLY:return 0;default:return 1}}t.ShaderType=void 0,(cr=t.ShaderType||(t.ShaderType={}))[cr.vertex=0]="vertex",cr[cr.fragment=1]="fragment";var Tr,Er,Sr=((hr={})[t.ShaderType.vertex]={in:"attribute",out:"varying"},hr[t.ShaderType.fragment]={in:"varying"},hr);function br(t,e,r,i){var n=[],o="";n.push("#define GE_RUNTIME"),t&&(t.forEach((function(t){var e=a(t,2),r=e[0],i=e[1];!0===i?n.push("#define ".concat(r)):Number.isFinite(i)&&n.push("#define ".concat(r," ").concat(i))})),o=n.length?n.join("\n")+"\n":"");var s="WEBGL".concat(i),u=(o+="\n#ifndef ".concat(s,"\n#define ").concat(s,"\n#endif"))+"\n"+e,l=u.match(/#version\s+\b\d{3}\b\s*(es)?/),c=l?l[0]:"";if(c&&c.includes("300")){var h=new RegExp("".concat(c),"g");1===i&&(u=u.replace(/\b(in|out)\b/g,(function(t){var e;return null!==(e=Sr[r][t])&&void 0!==e?e:t}))),u=u.replace(h,"\n")}return u}function Ar(t,e){switch(e){case void 0:case S.ALPHA:t.blendFunction=[v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA];break;case S.ADD:t.blendFunction=[v.ONE,v.ONE,v.ONE,v.ONE];break;case S.SUBTRACTION:t.blendFunction=[v.ONE,v.ONE,v.ZERO,v.ONE],t.blendEquation=[v.FUNC_REVERSE_SUBTRACT,v.FUNC_REVERSE_SUBTRACT];break;case S.SUPERPOSITION:t.blendFunction=[v.ONE,v.ONE,v.ONE,v.ONE];break;case S.MULTIPLY:t.blendFunction=[v.DST_COLOR,v.ONE_MINUS_SRC_ALPHA,v.DST_COLOR,v.ONE_MINUS_SRC_ALPHA];break;case S.BRIGHTNESS:t.blendFunction=[v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA];break;case S.STRONG_LIGHT:t.blendFunction=[v.DST_COLOR,v.DST_ALPHA,v.ZERO,v.ONE];break;case S.WEAK_LIGHT:t.blendFunction=[v.DST_COLOR,v.ZERO,v.ZERO,v.ONE];break;default:console.warn("blendMode ".concat(e," not in specification, please set blend params separately"))}}function _r(t,e){e===b.DOUBLE?t.culling=!1:(t.culling=!0,t.frontFace=v.CW,t.cullFace=e===b.BACK?v.BACK:v.FRONT)}function Cr(t,e){switch(e){case void 0:t.stencilTest=!1;break;case A.MASK:t.stencilTest=!0,t.stencilFunc=[v.ALWAYS,v.ALWAYS],t.stencilOpZPass=[v.REPLACE,v.REPLACE];break;case A.OBSCURED:t.stencilTest=!0,t.stencilFunc=[v.EQUAL,v.EQUAL];break;case A.REVERSE_OBSCURED:t.stencilTest=!0,t.stencilFunc=[v.NOTEQUAL,v.NOTEQUAL];break;case A.NONE:t.stencilTest=!1;break;default:console.warn("maskMode ".concat(e," not in specification, please set stencil params seperately"))}}t.TextureLoadAction=void 0,(Tr=t.TextureLoadAction||(t.TextureLoadAction={}))[Tr.whatever=0]="whatever",Tr[Tr.clear=2]="clear",t.TextureSourceType=void 0,(Er=t.TextureSourceType||(t.TextureSourceType={}))[Er.none=0]="none",Er[Er.data=1]="data",Er[Er.image=2]="image",Er[Er.compressed=3]="compressed",Er[Er.video=4]="video",Er[Er.canvas=5]="canvas",Er[Er.framebuffer=6]="framebuffer",Er[Er.mipmaps=7]="mipmaps";var Rr=function(){function t(){this.callbacks={}}return t.prototype.downloadJSON=function(t,e,r){this.download(t,"json",e,r)},t.prototype.downloadBinary=function(t,e,r){this.download(t,"arraybuffer",e,r)},t.prototype.downloadBlob=function(t,e,r){this.download(t,"blob",e,r)},t.prototype.download=function(t,e,r,i){var n=this;if(void 0===e&&(e="json"),!this.start(t,r,i)){var o=new XMLHttpRequest,s=function(){n.finish(t,o.status,o.response)};o.responseType=e,o.addEventListener("load",(function(){200==o.status||0==o.status?n.finish(t,200,o.response):s()})),o.addEventListener("error",s),o.open("GET",t,!0),o.send()}},t.prototype.start=function(t,e,r){var i=this.callbacks[t];try{if(i)return!0;this.callbacks[t]=i=[]}finally{i.push(e,r)}},t.prototype.finish=function(t,e,r){var i=this.callbacks[t];delete this.callbacks[t];for(var n=200==e||0==e?[r]:[e,r],o=n.length-1,s=i.length;o<s;o+=2)i[o].apply(null,n)},t}(),Or=!1;function wr(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return!Or&&e?[3,2]:[4,Mr(t)];case 1:case 5:return[2,{image:r.sent(),url:t}];case 2:return r.trys.push([2,4,,6]),[4,Mr(e)];case 3:return[2,{image:r.sent(),url:e}];case 4:return r.sent(),Or=!0,[4,Mr(t)];case 6:return[2]}}))}))}function Mr(t){return n(this,void 0,void 0,(function(){var e,r;return o(this,(function(i){if(e="",t instanceof HTMLImageElement){if(t.complete)return[2,t];e=t.src}else t instanceof Blob?(e=URL.createObjectURL(t),r=!0):"string"==typeof t&&(e=t);if(!e)throw new Error("Invalid url type: ".concat(JSON.stringify(t)));return[2,new Promise((function(t,i){var n=new Image;/^data:/.test(e)||(n.crossOrigin="*"),n.onload=function(){return n.onload=null,r&&URL.revokeObjectURL(e),t(n)},n.onerror=function(t){return n.onerror=null,r&&URL.revokeObjectURL(e),i("Load image fail: ".concat(e,", reason: ").concat(JSON.stringify(t)))},n.src=e}))]}))}))}function Lr(t){return n(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new Promise((function(e,r){(new Rr).downloadBinary(t,e,(function(e,i){r("Couldn't load bins ".concat(t,": status ").concat(e,", ").concat(i))}))}))]}))}))}function Ir(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var r;return o(this,(function(i){return r=document.createElement("video"),"string"==typeof t?r.src=t:r.srcObject=t,r.crossOrigin="anonymous",r.muted=!0,e.loop&&r.addEventListener("ended",(function(){return r.play()})),Z()&&r.setAttribute("renderer","standard"),r.setAttribute("playsinline","playsinline"),[2,new Promise((function(t,e){var i=r.play();i?i.then((function(){return t(r)})):r.addEventListener("loadeddata",(function e(){t(r),r.removeEventListener("loadeddata",e)}),!0),r.addEventListener("error",(function(t){e(t)}))}))]}))}))}function Pr(e,r,s){return void 0===s&&(s=[]),n(this,void 0,void 0,(function(){var n,a,u,l,c,h,f;return o(this,(function(o){switch(o.label){case 0:return 34067!==e.target?[3,2]:(u=(n=e).mipmaps,l=n.target,c=u.map((function(t){return Promise.all(t.map((function(t){return Fr(t,r)})))})),[4,Promise.all(c)]);case 1:return h=o.sent(),f=s[u[0][0][1][0]].url,[2,i(i({keepImageSource:!1},e),{mipmaps:h,sourceFrom:{target:l,bin:f,type:t.TextureSourceType.mipmaps,mipmaps:u.map((function(t){return t.map((function(t){return[t[1][1],t[1][2]]}))}))}})];case 2:return u=(a=e).mipmaps,l=a.target,c=u.map((function(t){return Fr(t,r)})),[4,Promise.all(c)];case 3:return h=o.sent(),f=s[u[0][1][0]].url,[2,i(i({keepImageSource:!1},e),{mipmaps:h,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{target:l,bin:f,type:t.TextureSourceType.mipmaps,mipmaps:u.map((function(t){return[t[1][1],t[1][2]]}))}})]}}))}))}function Fr(t,e){return n(this,void 0,void 0,(function(){var r,i,n,s,u;return o(this,(function(o){if(r=a(t[1],3),i=r[0],n=r[1],s=r[2],!(u=e[i]))throw new Error("invalid bin pointer: ".concat(JSON.stringify(t)));return[2,Mr(new Blob([new Uint8Array(u,n,s)]))]}))}))}var Nr=1,Vr=function(){function e(){this.destroyed=!1,this.id="Tex"+Nr++}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.getWidth=function(){return this.width||0},e.prototype.getHeight=function(){return this.height||0},e.prototype.uploadCurrentVideoFrame=function(){},e.prototype.offloadData=function(){},e.prototype.reloadData=function(){},e.prototype.initialize=function(){},e.prototype.assembleOptions=function(e){var r=e.target,n=void 0===r?v.TEXTURE_2D:r,o=e.format,s=void 0===o?v.RGBA:o;return e.sourceType||(e.sourceType="image"in e?t.TextureSourceType.image:"data"in e?t.TextureSourceType.data:"video"in e?t.TextureSourceType.video:0),i({minFilter:v.NEAREST,magFilter:v.NEAREST,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE,target:n,format:v.RGBA,internalFormat:s,type:v.UNSIGNED_BYTE},e)},e}();function Dr(t,e,r,i){var n,o,s=e.length/r/i;return o=n=4===s||0===s?v.RGBA:3===s?v.RGB:2===s?v.LUMINANCE_ALPHA:v.LUMINANCE,Vr.createWithData(t,{data:e,width:r,height:i},{type:v.HALF_FLOAT,format:n,internalFormat:o,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE})}var zr=function(){function t(t,e,r){void 0===r&&(r=0),this.arrayBuffer=t,this.baseOffset=r;var i=new Uint8Array(this.arrayBuffer,this.baseOffset,12);if(171!==i[0]||75!==i[1]||84!==i[2]||88!==i[3]||32!==i[4]||49!==i[5]||49!==i[6]||187!==i[7]||13!==i[8]||10!==i[9]||26!==i[10]||10!==i[11])throw Error("texture missing KTX identifier");var n=Uint32Array.BYTES_PER_ELEMENT,o=new DataView(this.arrayBuffer,this.baseOffset+12,13*n),s=67305985===o.getUint32(0,!0);this.glType=o.getUint32(1*n,s),this.glTypeSize=o.getUint32(2*n,s),this.glFormat=o.getUint32(3*n,s),this.glInternalFormat=o.getUint32(4*n,s),this.glBaseInternalFormat=o.getUint32(5*n,s),this.pixelWidth=o.getUint32(6*n,s),this.pixelHeight=o.getUint32(7*n,s),this.pixelDepth=o.getUint32(8*n,s),this.numberOfArrayElements=o.getUint32(9*n,s),this.numberOfFaces=o.getUint32(10*n,s),this.numberOfMipmapLevels=o.getUint32(11*n,s),this.bytesOfKeyValueData=o.getUint32(12*n,s),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:Be.warn("Number of faces expected"+e+", but found "+this.numberOfFaces):Be.warn("Texture arrays not currently supported"):Be.warn("Only 2D textures currently supported")}return t.prototype.mipmaps=function(t){for(var e=[],r=64+this.bytesOfKeyValueData,i=this.pixelWidth,n=this.pixelHeight,o=t?this.numberOfMipmapLevels:1,s=0;s<o;s++){for(var a=new Int32Array(this.arrayBuffer,this.baseOffset+r,1)[0],u=0;u<this.numberOfFaces;u++){var l=new Uint8Array(this.arrayBuffer,this.baseOffset+r+4,a);e.push({data:l,width:i,height:n}),r+=a+4,r+=3-(a+3)%4}i=Math.max(1,.5*i),n=Math.max(1,.5*n)}return e},t}();function Br(e){var r=new zr(e,1),i=r.numberOfMipmapLevels,n=r.pixelWidth,o=r.pixelHeight,s=r.glType,a=r.numberOfFaces,u=r.glInternalFormat,l=r.glFormat,c=i>=Math.floor(Math.log2(Math.max(n,o))+1);return{sourceType:t.TextureSourceType.compressed,type:s,target:6===a?v.TEXTURE_CUBE_MAP:v.TEXTURE_2D,internalFormat:u,format:l,mipmaps:r.mipmaps(c)}}var Ur,kr=function(){function e(){this.reloadPending={}}return e.prototype.reload=function(t){return n(this,void 0,void 0,(function(){var e,r;return o(this,(function(i){switch(i.label){case 0:return e=t.id,this.reloadPending[e]?[2]:t.sourceFrom?(this.reloadPending[e]=!0,[4,this.loadSource(t.sourceFrom)]):[3,2];case 1:return r=i.sent(),t.updateSource(r),this.reloadPending[e]=!1,[3,3];case 2:throw new Error("No source from");case 3:return[2]}}))}))},e.prototype.canOffloadTexture=function(e){if(e){var r=e.type;if(r===t.TextureSourceType.compressed||r===t.TextureSourceType.image){var i=e,n=i.target,o=i.map,s=e.url;return n===v.TEXTURE_CUBE_MAP?"object"==typeof o&&!!o:ke(s)&&s.length>0}if(r===t.TextureSourceType.mipmaps){var a=e,u=a.bin,l=a.mipmaps,c=e,h=(n=c.target,c.maps),f=e.urls;return u?l.length>0:n===v.TEXTURE_CUBE_MAP?h.every((function(t){return"object"==typeof t&&t})):f.every((function(t){return ke(t)&&t.length>0}))}}return!1},e.prototype.loadSource=function(e,r){return n(this,void 0,void 0,(function(){var n,s,a,u,l,c,h,f,p,d,m,y,g,x,T,E,S,b=this;return o(this,(function(o){switch(o.label){case 0:return n=e.type,s=e.target,a=e.map,u=e.url,c=(l=e).bin,h=l.mipmaps,f=e.urls,p=e.maps,s!==v.TEXTURE_CUBE_MAP||n===t.TextureSourceType.mipmaps?[3,2]:[4,this.loadCubeMap(a)];case 1:return d=o.sent(),[2,i(i({},r),{cube:d,target:v.TEXTURE_CUBE_MAP,sourceType:t.TextureSourceType.image,sourceFrom:{type:t.TextureSourceType.image,map:i({},a),target:v.TEXTURE_CUBE_MAP}})];case 2:return n!==t.TextureSourceType.image?[3,4]:[4,Mr(u)];case 3:return m=o.sent(),[2,i(i({},r),{image:m,sourceType:t.TextureSourceType.image,sourceFrom:{type:n,url:u,target:v.TEXTURE_2D}})];case 4:return n!==t.TextureSourceType.video?[3,6]:[4,Ir(u)];case 5:return y=o.sent(),[2,i(i({},r),{video:y,sourceType:t.TextureSourceType.video})];case 6:return n!==t.TextureSourceType.compressed?[3,8]:[4,Lr(u)];case 7:return g=o.sent(),[2,i(i(i({},Br(g)),r),{sourceFrom:{url:u,type:t.TextureSourceType.compressed}})];case 8:return n!==t.TextureSourceType.mipmaps?[3,17]:c?[4,Lr(c)]:[3,13];case 9:return x=o.sent(),T=null!=s?s:v.TEXTURE_2D,E=T===v.TEXTURE_2D?h.slice():h.map((function(t){return t.slice()})),S=void 0,s!==v.TEXTURE_CUBE_MAP?[3,11]:[4,Promise.all(h.map((function(t){return b.loadMipmapImages(t,x)})))];case 10:return S=o.sent(),[3,12];case 11:S=this.loadMipmapImages(h,x),o.label=12;case 12:return[2,i(i({},r),{mipmaps:S,target:T,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{bin:c,mipmaps:E,target:T,type:t.TextureSourceType.mipmaps}})];case 13:return s!==v.TEXTURE_2D&&s?[3,15]:[4,Promise.all(f.map((function(t){return Mr(t)})))];case 14:return S=o.sent(),[2,i(i({},r),{mipmaps:S,target:v.TEXTURE_2D,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{type:n,urls:f.slice(),target:v.TEXTURE_2D}})];case 15:return s!==v.TEXTURE_CUBE_MAP?[3,17]:[4,Promise.all(p.map((function(t){return b.loadCubeMap(t)})))];case 16:return S=o.sent(),[2,i(i({},r),{mipmaps:S,target:v.TEXTURE_CUBE_MAP,sourceType:t.TextureSourceType.mipmaps,sourceFrom:{type:n,maps:p.map((function(t){return i({},t)})),target:v.TEXTURE_CUBE_MAP}})];case 17:throw new Error("Invalid resource type: ".concat(n))}}))}))},e.prototype.loadMipmapImages=function(t,e){return n(this,void 0,void 0,(function(){return o(this,(function(r){return[2,Promise.all(t.map((function(t){return Mr(new Blob([new Uint8Array(e,t[0],t[1])]))})))]}))}))},e.prototype.loadCubeMap=function(t){return n(this,void 0,void 0,(function(){return o(this,(function(e){return[2,Promise.all(t.map((function(t){return Mr(t)})))]}))}))},e}();function Gr(){return Ur||(Ur=new kr),Ur}var Xr,Hr=function(){function t(t){this.destroyed=!1;var e=t.name,r=void 0===e?"defaultDataBlock":e;this.name=r}return t.prototype.setUniformValues=function(t){var e=this;Object.keys(t).forEach((function(r){e.setUniformValue(r,t[r])}))},t.prototype.invalidAllFlags=function(){},t.prototype.updateUniformSubData=function(t,e,r){},t}();function Yr(t){return"object"==typeof t&&t&&void 0===t.length&&t instanceof Vr}t.MaterialRenderType=void 0,(Xr=t.MaterialRenderType||(t.MaterialRenderType={}))[Xr.normal=0]="normal",Xr[Xr.transformFeedback=1]="transformFeedback";var jr,Wr,Zr=1,qr=function(){function e(e){this.props=e,this.destroyed=!1,this.initialized=!1;var r=e.name,n=void 0===r?"Material"+Zr++:r,o=e.renderType,s=void 0===o?t.MaterialRenderType.normal:o,a=e.shader,u=e.uniformSemantics;this.name=n,this.renderType=s,this.shaderSource=a,this.uniformSemantics=i({},u)}return Object.defineProperty(e.prototype,"blending",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendFunction",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendEquation",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilTest",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilRef",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFunc",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpZPass",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"culling",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frontFace",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendColor",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthRange",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polygonOffsetFill",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"polygonOffset",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sampleAlphaToCoverage",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorMask",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilMask",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpFail",{set:function(t){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpZFail",{set:function(t){},enumerable:!1,configurable:!0}),e.prototype.initialize=function(){},e.prototype.use=function(t,e){},e}(),Kr="uniform vec2 uFilterSourceSize;uniform sampler2D uFilterSource;\n#define INTERPOLATION 1\nvec4 filterMain(vec2 texCoord,sampler2D tex){\n#ifdef INTERPOLATION\nvec2 texInPixel=texCoord*uFilterSourceSize;vec2 coordMin=floor(texInPixel);vec2 pp=texInPixel-coordMin;vec4 fCoord=vec4(coordMin/uFilterSourceSize,(coordMin+vec2(1.))/uFilterSourceSize);vec4 cLT=texture2D(uFilterSource,vec2(fCoord.x,fCoord.w));vec4 cLB=texture2D(uFilterSource,vec2(fCoord.x,fCoord.y));vec4 cRT=texture2D(uFilterSource,vec2(fCoord.z,fCoord.w));vec4 cRB=texture2D(uFilterSource,vec2(fCoord.z,fCoord.y));return mix(mix(cLB,cRB,pp.x),mix(cLT,cRT,pp.x),pp.y);\n#else\nreturn texture2D(uFilterSource,texCoord);\n#endif\n}";t.ShaderCompileResultStatus=void 0,(jr=t.ShaderCompileResultStatus||(t.ShaderCompileResultStatus={}))[jr.noShader=0]="noShader",jr[jr.success=1]="success",jr[jr.fail=2]="fail",jr[jr.compiling=3]="compiling",t.GLSLVersion=void 0,(Wr=t.GLSLVersion||(t.GLSLVersion={})).GLSL1="100",Wr.GLSL3="300 es";var Qr=function(t){this.source=t},Jr="effects-internal-copy",$r="effects-internal-copy-mesh",ti="\n#ifdef WEBGL2\n#define vsIn in\n#define vsOut out\n#else\n#define vsIn attribute\n#define vsOut varying\n#endif\nprecision highp float;\nvsIn vec2 aPos;\nvsOut vec2 vTex;\nvoid main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.0))/2.;\n}",ei="precision mediump float;\n#ifdef WEBGL2\n#define fsIn in\n#define fsOut out\n#define texture2D texture\n#else\n#define fsIn varying\n#endif\n".concat(Kr,"\nfsIn vec2 vTex;\n#ifdef WEBGL2\nlayout (location = 0) out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\n\n#ifdef DEPTH_TEXTURE\nuniform sampler2D uDepth;\n#ifndef WEBGL2\n#extension GL_EXT_frag_depth : enable\n#define gl_FragDepth gl_FragDepthEXT\n#endif\n#endif\nvoid main(){\n fragColor = filterMain(vTex,uFilterSource);\n #ifdef DEPTH_TEXTURE\n gl_FragDepth = texture2D(uDepth,vTex).r;\n #endif\n}\n");function ri(e,r){var i=2===e,n=i?"#version 300 es":"";return{name:Jr,vertex:br([],n+"\n"+ti,t.ShaderType.vertex,e),fragment:br([],n+"\n"+ei,t.ShaderType.fragment,e),glslVersion:i?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1,marcos:[["WEBGL2",!!i],["DEPTH_TEXTURE",!!r]],cacheId:$r+ +r}}var ii,ni={format:v.RGBA,type:v.UNSIGNED_BYTE,minFilter:v.LINEAR,magFilter:v.LINEAR,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE},oi=Symbol("dispose"),si=function(){function e(t){this.textureCache={},this.textureRef={},this.engine=t}return e.prototype.requestColorAttachmentTexture=function(e){var r=this,i=e.width,n=e.height,o=e.name,s={sourceType:t.TextureSourceType.framebuffer,data:{width:i,height:n},name:o},a=[o];Object.getOwnPropertyNames(ni).forEach((function(t){var r,i=null!==(r=e[t])&&void 0!==r?r:ni[t];s[t]=i,a.push(t,i)}));var u=a.join(":"),l=this.textureCache[u];if(l)this.textureRef[u]++;else{var c=this.engine;rt(c),l=Vr.create(c,s),this.textureCache[u]=l,this.textureRef[u]=1,l[oi]=l.dispose,l.dispose=function(){return r.removeTexture(u)}}return l},e.prototype.removeTexture=function(t){var e=this.textureRef[t];if(e<=1){e<0&&console.error("ref count < 0");var r=this.textureCache[t];r&&(r[oi](),r.dispose=r[oi]),delete this.textureCache[t],delete this.textureRef[t]}else this.textureRef[t]=e-1},e.prototype.dispose=function(){var t=this;Object.keys(this.textureCache).forEach((function(e){var r=t.textureCache[e];r[oi](),r.dispose=r[oi]})),this.textureCache={},this.textureRef={},this.engine=void 0},e}(),ai=function(){function t(t){void 0===t&&(t={}),this.semantics=i({},t)}return t.prototype.toObject=function(){return i({},this.semantics)},t.prototype.setSemantic=function(t,e){void 0===e?delete this.semantics[t]:this.semantics[t]=e},t.prototype.getSemanticValue=function(t,e){var r=this.semantics[t];return Xe(r)?r(e):r},t.prototype.hasSemanticValue=function(t){return t in this.semantics},t.prototype.dispose=function(){var t=this;Object.keys(this.semantics).forEach((function(e){delete t.semantics[e]}))},t}(),ui=((ii={})[v.FLOAT]=Float32Array.BYTES_PER_ELEMENT,ii[v.INT]=Int32Array.BYTES_PER_ELEMENT,ii[v.SHORT]=Int16Array.BYTES_PER_ELEMENT,ii[v.BYTE]=Int8Array.BYTES_PER_ELEMENT,ii),li=function(){function t(t){this.name=t}return t.prototype.initialize=function(){},t.prototype.flush=function(){},t}();function ci(t){return t===v.INT?new Int32Array(0):t===v.SHORT?new Int16Array(0):new Float32Array(0)}var hi="lookup_texture",fi="offscreen_canvas",pi={};function di(t){return pi[t]}var mi,vi,yi=1,gi=function(){function e(t,e){this.engine=t,this.destroyed=!1,this.visible=!0;var r=e.material,i=e.geometry,n=e.name,o=void 0===n?"<unnamed>":n,s=e.priority,a=void 0===s?0:s,u=e.worldMatrix,l=void 0===u?Ft.fromIdentity():u;this.id="Mesh"+yi++,this.name=o,this.geometry=i,this.material=r,this.priority=a,this.worldMatrix=l}return Object.defineProperty(e.prototype,"priority",{get:function(){return this._priority},set:function(t){this._priority=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.setVisible=function(t){this.visible=t},e.prototype.render=function(t){var e=t.renderingData,r=this.material;e.currentFrame.globalUniforms&&(e.currentCamera&&(t.setGlobalMatrix("effects_MatrixInvV",e.currentCamera.getInverseViewMatrix()),t.setGlobalMatrix("effects_MatrixV",e.currentCamera.getViewMatrix()),t.setGlobalMatrix("effects_MatrixVP",e.currentCamera.getViewProjectionMatrix()),t.setGlobalMatrix("_MatrixP",e.currentCamera.getProjectionMatrix())),t.setGlobalMatrix("effects_ObjectToWorld",this.worldMatrix)),e.currentFrame.editorTransform&&r.setVector4("uEditorTransform",e.currentFrame.editorTransform),r.use(t,e.currentFrame.globalUniforms);var i=this.geometry;i.flush(),t.drawGeometry(i,r)},e.prototype.getVisible=function(){return this.visible},e.prototype.firstGeometry=function(){return this.geometry},e.prototype.setMaterial=function(e,r){r!==t.DestroyOptions.keep&&this.material.dispose(r),this.material=e},e.prototype.restore=function(){},e.prototype.dispose=function(e){if(!this.destroyed){(null==e?void 0:e.geometries)!==t.DestroyOptions.keep&&this.geometry.dispose();var r=null==e?void 0:e.material;r!==t.DestroyOptions.keep&&this.material.dispose(r),this.destroyed=!0,void 0!==this.engine&&(this.engine.removeMesh(this),this.engine=void 0)}},e}(),xi=1e3;t.RenderPassAttachmentStorageType=void 0,(mi=t.RenderPassAttachmentStorageType||(t.RenderPassAttachmentStorageType={}))[mi.none=0]="none",mi[mi.color=1]="color",mi[mi.stencil_8_opaque=2]="stencil_8_opaque",mi[mi.depth_16_opaque=3]="depth_16_opaque",mi[mi.depth_stencil_opaque=4]="depth_stencil_opaque",mi[mi.depth_16_texture=5]="depth_16_texture",mi[mi.depth_24_stencil_8_texture=6]="depth_24_stencil_8_texture",t.TextureStoreAction=void 0,(vi=t.TextureStoreAction||(t.TextureStoreAction={}))[vi.store=0]="store",vi[vi.clear=2]="clear";var Ti,Ei=function(){function e(e,r){if(this.destroyed=!1,r){var n=r.texture,o=r.size;if(n instanceof Vr)this.texture=n,this.externalTexture=!0;else if(n){var s=n.wrapT,a=n.wrapS,u=n.minFilter,l=n.magFilter,c=n.internalFormat,h=n.format,f=void 0===h?v.RGBA:h,p=n.type,d=void 0===p?v.UNSIGNED_BYTE:p;this.externalTexture=!1,this.textureOptions={size:o,format:f,type:d,internalFormat:c||f,wrapT:s,wrapS:a,minFilter:u,magFilter:l,name:r.name},this.texture=Vr.create(e,i(i({},this.textureOptions),{sourceType:t.TextureSourceType.framebuffer,data:{width:o[0],height:o[1]}}))}}}return e.prototype.dispose=function(){this.destroyed||(this.texture.dispose(),this.destroyed=!0)},Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"storageType",{get:function(){return t.RenderPassAttachmentStorageType.color},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){var t=this.texture;return t?[t.getWidth(),t.getHeight()]:[0,0]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this.texture.getWidth()||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.texture.getHeight()||0},enumerable:!1,configurable:!0}),e}();t.RenderPassDestroyAttachmentType=void 0,(Ti=t.RenderPassDestroyAttachmentType||(t.RenderPassDestroyAttachmentType={}))[Ti.force=0]="force",Ti[Ti.keep=1]="keep",Ti[Ti.keepExternal=2]="keepExternal",Ti[Ti.destroy=0]="destroy";var Si=1,bi=function(){function e(e,r){this.attachments=[],this.destroyed=!1,this.initialized=!1;var n=r.name,o=void 0===n?"RenderPass_"+Si++:n,s=r.clearAction,a=r.semantics,u=r.depthStencilAttachment,l=r.storeAction,c=r.priority,h=void 0===c?0:c,f=r.meshOrder,p=void 0===f?t.OrderType.ascending:f,d=r.meshes,m=void 0===d?[]:d,v=r.delegate,y=void 0===v?{}:v;this.name=o,this.renderer=e,this.priority=h,this.meshOrder=p,this.meshes=J(m.slice(),this.meshOrder),this.depthStencilType=(null==u?void 0:u.storageType)||t.RenderPassAttachmentStorageType.none,this.clearAction=i({},s),this.storeAction=i({colorAction:t.TextureStoreAction.store,depthAction:t.TextureStoreAction.store,stencilAction:t.TextureStoreAction.store},l),this.semantics=new ai(a),this.options=r,this.delegate=y,this.setViewportOptions(r)}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"viewport",{get:function(){return this.getViewport()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilAttachment",{get:function(){return this.getStencilAttachment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthAttachment",{get:function(){return this.getDepthAttachment()},enumerable:!1,configurable:!0}),e.prototype.addMesh=function(t){$(this.meshes,t,this.meshOrder)},e.prototype.removeMesh=function(t){B(this.meshes,t)},e.prototype.setMeshes=function(t){var e;return this.meshes.length=0,(e=this.meshes).splice.apply(e,u([0,0],a(t),!1)),J(this.meshes,this.meshOrder),this.meshes},e.prototype.getInitAttachments=function(){return this.attachments.length>0?this.attachments:this.options.attachments},e.prototype.configure=function(t){if(this.frameBuffer)t.setFrameBuffer(this.frameBuffer);else{var e=a(this.getViewport(),4),r=e[0],i=e[1],n=e[2],o=e[3];t.setViewport(r,i,n,o)}},e.prototype.execute=function(t){t.clear(this.clearAction),t.renderMeshes(this.meshes),t.clear(this.storeAction)},e.prototype.frameCleanup=function(t){},e.prototype.resetColorAttachments=function(e){var r=this;if(e.length||this.resetAttachments({attachments:[]}),this.attachments.length){var i=e.map((function(e){return e.updateSource({sourceType:t.TextureSourceType.framebuffer}),new Ei(r.renderer.engine,{texture:e})}));this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments=i,this.frameBuffer&&(this.frameBuffer.bind(),this.frameBuffer.resetColorTextures(e.map((function(t){return t}))))}else this.resetAttachments({attachments:e.map((function(t){return{texture:t}}))})},e.prototype.resetAttachments=function(t){this.options=t,this.setViewportOptions(t),this.renderer&&this._resetAttachments()},e.prototype.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.prototype._resetAttachments=function(){var e,r,n=this,o=this.renderer,s=this.options;this.attachments.length&&(this.attachments.forEach((function(t){return!t.externalTexture&&t.dispose()})),this.attachments.length=0,null===(e=this.frameBuffer)||void 0===e||e.dispose({depthStencilAttachment:t.RenderPassDestroyAttachmentType.keepExternal}),this.frameBuffer=null);var a=this.viewportScale,u=this.isCustomViewport?this.customViewport:[0,0,o.getWidth()*a,o.getHeight()*a],l=[u[2],u[3]],c=this.name;if(null===(r=s.attachments)||void 0===r?void 0:r.length){var h=s.attachments.map((function(t,e){var r;return new Ei(n.renderer.engine,i({size:l,name:(null===(r=t.texture)||void 0===r?void 0:r.name)||"".concat(c,"##color_").concat(e)},t))}));this.attachments=h;var f=cn.create({storeAction:this.storeAction,name:c,viewport:u,viewportScale:this.viewportScale,isCustomViewport:this.isCustomViewport,attachments:h.map((function(t){return t.texture})),depthStencilAttachment:s.depthStencilAttachment||{storageType:t.RenderPassAttachmentStorageType.none}},o);f.bind(),f.unbind(),this.frameBuffer=f}else this.attachments.length=0},e.prototype.getViewport=function(){var t,e=(null===(t=this.frameBuffer)||void 0===t?void 0:t.viewport)||this.customViewport;if(e)return e;var r=this.renderer,i=this.viewportScale;return r?[0,0,r.getWidth()*i,r.getHeight()*i]:[0,0,0,0]},e.prototype.getDepthAttachment=function(){var t=this.frameBuffer;if(t)return{storageType:t.depthStencilStorageType,storage:t.depthStorage,texture:t.getDepthTexture()?this.getDepthTexture(t.getDepthTexture(),t.externalStorage):void 0}},e.prototype.getStencilAttachment=function(){var t=this.frameBuffer;if(t)return{storageType:t.depthStencilStorageType,storage:t.stencilStorage,texture:t.getStencilTexture()?this.getStencilTexture(t.getStencilTexture(),t.externalStorage):void 0}},e.prototype.getDepthTexture=function(t,e){var r;if(!this.depthTexture){var i=null===(r=this.options.depthStencilAttachment)||void 0===r?void 0:r.texture,n=t===i?i:t;return e||(this.depthTexture=n),n}return this.depthTexture},e.prototype.getStencilTexture=function(t,e){var r;if(!this.stencilTexture){var i=null===(r=this.options.depthStencilAttachment)||void 0===r?void 0:r.texture,n=t===i?i:t;return e||(this.stencilTexture=n),n}return this.stencilTexture},e.prototype.initialize=function(t){return this.initialized||(this._resetAttachments(),this.initialized=!0),this},e.prototype.dispose=function(e){var r,i;if(!this.destroyed){var n=(null==e?void 0:e.meshes)||void 0;n!==t.DestroyOptions.keep&&this.meshes.forEach((function(t){t.dispose(n)})),this.meshes.length=0;var o=(null==e?void 0:e.colorAttachment)?e.colorAttachment:t.RenderPassDestroyAttachmentType.force;this.attachments.forEach((function(e){e.externalTexture&&o===t.RenderPassDestroyAttachmentType.keepExternal||o===t.RenderPassDestroyAttachmentType.keep||e.dispose()})),this.attachments.length=0,(null==e?void 0:e.semantics)!==t.DestroyOptions.keep&&this.semantics.dispose(),this.destroyed=!0;var s=(null==e?void 0:e.depthStencilAttachment)?e.depthStencilAttachment:t.RenderPassDestroyAttachmentType.force,a=this.frameBuffer;if(a)a.dispose({depthStencilAttachment:s}),a.externalStorage&&s===t.RenderPassDestroyAttachmentType.keepExternal||s===t.RenderPassDestroyAttachmentType.keep||(null===(r=this.stencilTexture)||void 0===r||r.dispose(),null===(i=this.depthTexture)||void 0===i||i.dispose());this.options=this.renderer=null,this.initialize=je}},e}(),Ai="#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(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;}in vec4 vColor;in vec4 vTexCoord;in highp vec2 vParams;uniform vec3 uFrameColor;void main(){fragColor=vec4(uFrameColor.xyz,1.0);}",_i="#version 300 es\nprecision highp float;\n#define SHADER_VERTEX 1\n#define SPRITE_SHADER 1\nin vec4 aPoint;in vec2 aIndex;uniform mat4 uMainData[MAX_ITEM_COUNT];uniform vec4 uTexParams[MAX_ITEM_COUNT];uniform vec4 uTexOffset[MAX_ITEM_COUNT];uniform mat4 effects_ObjectToWorld;uniform mat4 effects_MatrixInvV;uniform mat4 effects_MatrixVP;out vec4 vColor;out vec4 vTexCoord;\n#ifdef ADJUST_LAYER\nout vec2 vFeatherCoord;\n#endif\nout highp vec3 vParams;const float d2r=3.141592653589793/180.;\n#ifdef ENV_EDITOR\nuniform vec4 uEditorTransform;\n#endif\nvec4 filterMain(float t,vec4 position);\n#pragma FILTER_VERT\nvec3 rotateByQuat(vec3 a,vec4 quat){vec3 qvec=quat.xyz;vec3 uv=cross(qvec,a);vec3 uuv=cross(qvec,uv)*2.;return a+(uv*2.*quat.w+uuv);}void main(){int index=int(aIndex.x);vec4 texParams=uTexParams[index];mat4 mainData=uMainData[index];float life=mainData[1].z;if(life<0.||life>1.){gl_Position=vec4(3.,3.,3.,1.);}else{vec4 _pos=mainData[0];vec2 size=mainData[1].xy;vec3 point=rotateByQuat(vec3(aPoint.xy*size,0.),mainData[2]);vec4 pos=vec4(_pos.xyz,1.0);float renderMode=texParams.z;if(renderMode==0.){pos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixInvV[0].xyz*point.x+effects_MatrixInvV[1].xyz*point.y;}else if(renderMode==1.){pos.xyz+=point;pos=effects_ObjectToWorld*pos;}else if(renderMode==2.){pos=effects_ObjectToWorld*pos;pos.xy+=point.xy;}else if(renderMode==3.){pos=effects_ObjectToWorld*pos;pos.xyz+=effects_MatrixInvV[0].xyz*point.x+effects_MatrixInvV[2].xyz*point.y;}gl_Position=effects_MatrixVP*pos;\n#ifdef ADJUST_LAYER\nvec4 filter_Position=filterMain(life,pos);\n#endif\ngl_PointSize=6.0;\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#ifdef ADJUST_LAYER\nfilter_Position=vec4(filter_Position.xy*uEditorTransform.xy+uEditorTransform.zw*filter_Position.w,filter_Position.zw);\n#endif\n#endif\n#ifdef ADJUST_LAYER\nvTexCoord=vec4(filter_Position.xy/filter_Position.w+1.,gl_Position.xy/gl_Position.w+1.)/2.;vFeatherCoord=aPoint.zw;\n#else\nvec4 texOffset=uTexOffset[index];vTexCoord=vec4(aPoint.zw*texOffset.zw+texOffset.xy,texParams.xy);\n#endif\nvColor=mainData[3];vParams=vec3(aIndex.y,texParams.y,texParams.x);}}",Ci="#version 300 es\nprecision highp float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(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 SPRITE_SHADER 1\nin vec4 vColor;in vec4 vTexCoord;in highp vec3 vParams;\n#ifdef ADJUST_LAYER\nuniform sampler2D uSamplerPre;vec4 filterMain(vec2 coord,sampler2D tex);in vec2 vFeatherCoord;uniform sampler2D uFeatherSampler;\n#endif\nuniform sampler2D uSampler0;uniform sampler2D uSampler1;uniform sampler2D uSampler2;uniform sampler2D uSampler3;uniform sampler2D uSampler4;uniform sampler2D uSampler5;uniform sampler2D uSampler6;uniform sampler2D uSampler7;\n#if MAX_FRAG_TEX == 16\nuniform sampler2D uSampler8;uniform sampler2D uSampler9;uniform sampler2D uSampler10;uniform sampler2D uSampler11;uniform sampler2D uSampler12;uniform sampler2D uSampler13;uniform sampler2D uSampler14;uniform sampler2D uSampler15;\n#endif\nvec4 texture2DbyIndex(float index,vec2 coord);\n#pragma FILTER_FRAG\n#ifndef WEBGL2\n#define round(a) floor(0.5+a)\n#endif\nvoid main(){vec4 color=vec4(0.);\n#ifdef ADJUST_LAYER\nvec2 featherCoord=abs(vFeatherCoord-vec2(0.5))/0.5;float cc=sqrt(max(featherCoord.x,featherCoord.y));float blend=vColor.a*texture2D(uFeatherSampler,vec2(cc,0.)).r;if(blend>=1.){color=filterMain(vTexCoord.xy,uSamplerPre);}else if(blend<=0.){color=texture2D(uSamplerPre,vTexCoord.zw);}else{color=mix(texture2D(uSamplerPre,vTexCoord.zw),filterMain(vTexCoord.xy,uSamplerPre),blend);}\n#else\nvec4 texColor=texture2DbyIndex(round(vParams.x),vTexCoord.xy);color=blendColor(texColor,vColor,round(vParams.y));if(vParams.z==0.&&color.a<0.04){discard;}\n#endif\ncolor.a=clamp(color.a,0.0,1.0);fragColor=color;}vec4 texture2DbyIndex(float index,vec2 coord){\n#ifndef ADJUST_LAYER\nif(index==0.){return texture2D(uSampler0,coord);}if(index==1.){return texture2D(uSampler1,coord);}if(index==2.){return texture2D(uSampler2,coord);}if(index==3.){return texture2D(uSampler3,coord);}if(index==4.){return texture2D(uSampler4,coord);}if(index==5.){return texture2D(uSampler5,coord);}if(index==6.){return texture2D(uSampler6,coord);}if(index==7.){return texture2D(uSampler7,coord);}\n#if MAX_FRAG_TEX == 16\nif(index==8.){return texture2D(uSampler8,coord);}if(index==9.){return texture2D(uSampler9,coord);}if(index==10.){return texture2D(uSampler10,coord);}if(index==11.){return texture2D(uSampler11,coord);}if(index==12.){return texture2D(uSampler12,coord);}if(index==13.){return texture2D(uSampler13,coord);}if(index==14.){return texture2D(uSampler14,coord);}if(index==15.){return texture2D(uSampler15,coord);}\n#endif\nreturn texture2D(uSampler0,coord);\n#else\nreturn vec4(0.);\n#endif\n}",Ri="#version 300 es\nprecision mediump float;\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#define textureCube texture\n#define textureCubeLodEXT textureLod\nlayout(location=0)out vec4 fragColor;\n#else\n#define fragColor gl_FragColor\n#endif\nvec4 blendColor(vec4 color,vec4 vc,float mode){vec4 ret=color*vc;\n#ifdef PRE_MULTIPLY_ALPHA\nfloat alpha=vc.a;\n#else\nfloat alpha=ret.a;\n#endif\nif(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\nin float vLife;in vec2 vTexCoord;in 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\nin vec4 vTexCoordBlend;\n#ifdef USE_FILTER\nuniform vec4 uFSprite;\n#endif\n#endif\nin 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(){fragColor=uPreviewColor;}\n#else\n#pragma FILTER_FRAG\nvoid main(){vec4 color=vec4(1.0);vec4 tempColor=vColor;vec2 texOffset=uTexOffset;if(vLife<0.){discard;}\n#ifdef USE_FILTER\n#ifdef USE_SPRITE\ntexOffset=uTexOffset/uFSprite.xy;\n#endif\ncolor=filterMain(vTexCoord,uMaskTex);\n#else\nif(uColorParams.x>0.0){color=getTextureColor(uMaskTex,vTexCoord);}\n#endif\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);fragColor=color;}\n#endif\n",Oi="#version 300 es\nprecision highp float;\n#define SHADER_VERTEX 1\n#define PATICLE_SHADER 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\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#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\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\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(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++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).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++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(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;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}float integrateCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;vec4 a=vec4(dt3*dt,dt3,dt2,dt)/vec4(4.*k*k*k,3.*k*k,2.*k,1.);vec4 b=vec4(m0+m1+2.*v0-2.*v1,2.*m0+m1+3.*v0-3.*v1,m0,-v0);return dot(a,b);}float integrateByTimeCurveFrames(float t1,vec4 k0,vec4 k1){float k=k1.x-k0.x;float m0=k0.w*k;float m1=k1.z*k;float t0=k0.x;float v0=k0.y;float v1=k1.y;float dt=t0-t1;float dt2=dt*dt;float dt3=dt2*dt;float k2=k*k;float k3=k2*k;vec4 a=vec4(-30.*k3,10.*k2,5.*k,3.)*vec4(dt,dt2,dt3,dt3*dt);vec4 b=vec4(v0,m0,2.*m0+m1+3.*v0-3.*v1,m0+m1+2.*v0-2.*v1)*vec4(t0+t1,t0+2.*t1,t0+3.*t1,t0+4.*t1);return dot(a,b)/60./k3;}float integrateByTimeFromCurveFrames(float t1,float frameStart,float frameCount){if(t1==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 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(t1>k0.x&&t1<=k1.x){return ret+integrateByTimeCurveFrames(t1,k0,k1);}ret+=integrateByTimeCurveFrames(k1.x,k0,k1);}return ret;}float integrateFromCurveFrames(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 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);if(time>k0.x&&time<=k1.x){return ret+integrateCurveFrames(time,k0,k1);}ret+=integrateCurveFrames(k1.x,k0,k1);}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;}else 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==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateFromCurveFrames(t1,idx,ilen);return d*value.w+value.z*t1;}if(type==4.){return mix(value.y,value.z,aSeed)*t1;}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==2.){float idx=floor(value.y);float ilen=floor(1./fract(value.y)+0.5);float d=integrateByTimeFromCurveFrames(t1,idx,ilen)-integrateByTimeFromCurveFrames(t0,idx,ilen);return d*value.w+value.z*pow(t1-t0,2.)*0.5;}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.;}return 0.;}const float d2r=3.141592653589793/180.;in vec3 aPos;in vec4 aOffset;in vec3 aVel;in vec3 aRot;in vec4 aColor;in vec3 aDirX;in vec3 aDirY;\n#ifdef USE_SPRITE\nin vec3 aSprite;uniform vec4 uSprite;struct UVDetail{vec2 uv0;vec3 uv1;};UVDetail getSpriteUV(vec2 uv,float lifeTime);out vec4 vTexCoordBlend;\n#endif\n#pragma EDITOR_VERT_DEFINE\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 uAcceleration;uniform vec4 uGravityModifierValue;uniform vec4 uOpacityOverLifetimeValue;\n#ifdef ROT_X_LIFETIME\nuniform vec4 uRXByLifeTimeValue;\n#endif\n#ifdef ROT_Y_LIFETIME\nuniform vec4 uRYByLifeTimeValue;\n#endif\n#ifdef ROT_Z_LIFETIME\nuniform vec4 uRZByLifeTimeValue;\n#endif\n#ifdef COLOR_OVER_LIFETIME\nuniform sampler2D uColorOverLifetime;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n#if LINEAR_VEL_X\nuniform vec4 uLinearXByLifetimeValue;\n#endif\n#if LINEAR_VEL_Y\nuniform vec4 uLinearYByLifetimeValue;\n#endif\n#if LINEAR_VEL_Z\nuniform vec4 uLinearZByLifetimeValue;\n#endif\n#endif\n#ifdef SPEED_OVER_LIFETIME\nuniform vec4 uSpeedLifetimeValue;\n#endif\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n#if ORB_VEL_X\nuniform vec4 uOrbXByLifetimeValue;\n#endif\n#if ORB_VEL_Y\nuniform vec4 uOrbYByLifetimeValue;\n#endif\n#if ORB_VEL_Z\nuniform vec4 uOrbZByLifetimeValue;\n#endif\nuniform vec3 uOrbCenter;\n#endif\nuniform vec4 uSizeByLifetimeValue;\n#ifdef SIZE_Y_BY_LIFE\nuniform vec4 uSizeYByLifetimeValue;\n#endif\nout float vLife;out vec4 vColor;out vec2 vTexCoord;\n#ifdef USE_FILTER\n#pragma FILTER_VERT\n#endif\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;}vec3 calLinearMov(float _life,float _dur){vec3 mov=vec3(0.0);\n#ifdef AS_LINEAR_MOVEMENT\n#define FUNC(a) getValueFromTime(_life,a)\n#else\n#define FUNC(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#if LINEAR_VEL_X\nmov.x=FUNC(uLinearXByLifetimeValue);\n#endif\n#if LINEAR_VEL_Y\nmov.y=FUNC(uLinearYByLifetimeValue);\n#endif\n#if LINEAR_VEL_Z\nmov.z=FUNC(uLinearZByLifetimeValue);\n#endif\n#undef FUNC\nreturn mov;}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\nvec3 calculateTranslation(vec3 vel,float t0,float t1,float dur){float dt=t1-t0;float d=getIntegrateByTimeFromTime(0.,dt,uGravityModifierValue);vec3 acc=uAcceleration.xyz*d;\n#ifdef SPEED_OVER_LIFETIME\nreturn vel*getIntegrateFromTime0(dt/dur,uSpeedLifetimeValue)*dur+acc;\n#endif\nreturn vel*dt+acc;}mat3 transformFromRotation(vec3 rot,float _life,float _dur){vec3 rotation=rot;\n#ifdef ROT_LIFETIME_AS_MOVEMENT\n#define FUNC1(a) getValueFromTime(_life,a)\n#else\n#define FUNC1(a) getIntegrateFromTime0(_life,a) * _dur\n#endif\n#ifdef ROT_X_LIFETIME\nrotation.x+=FUNC1(uRXByLifeTimeValue);\n#endif\n#ifdef ROT_Y_LIFETIME\nrotation.y+=FUNC1(uRYByLifeTimeValue);\n#endif\n#ifdef ROT_Z_LIFETIME\nrotation.z+=FUNC1(uRZByLifeTimeValue);\n#endif\nif(dot(rotation,rotation)==0.0){return mat3(1.0);}\n#undef FUNC1\nreturn mat3FromRotation(rotation);}void 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\nvec3 point=transformFromRotation(aRot,life,dur)*(aDirX*size.x+aDirY*size.y);vec3 pt=calculateTranslation(aVel,aOffset.z,uParams.x,dur);vec3 _pos=aPos+pt;\n#if ORB_VEL_X + ORB_VEL_Y + ORB_VEL_Z\n_pos=mat3FromRotation(calOrbitalMov(life,dur))*(_pos-uOrbCenter);_pos+=uOrbCenter;\n#endif\n#if LINEAR_VEL_X + LINEAR_VEL_Y + LINEAR_VEL_Z\n_pos.xyz+=calLinearMov(life,dur);\n#endif\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 USE_FILTER\nfilterMain(life);\n#endif\n#ifdef ENV_EDITOR\ngl_Position=vec4(gl_Position.xy*uEditorTransform.xy+uEditorTransform.zw*gl_Position.w,gl_Position.zw);\n#endif\n#pragma EDITOR_VERT_TRANSFORM\n}}",wi="#version 300 es\nprecision mediump float;\n#define SHADER_VERTEX 1\n#version 300 es\n#ifdef WEBGL2\n#define texture2D texture\n#else\n#endif\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#ifdef SHADER_VERTEX\nin float aSeed;out float vSeed;\n#define NONE_CONST_INDEX 1\n#else\n#if LOOKUP_TEXTURE_CURVE\n#define NONE_CONST_INDEX 1\n#endif\n#endif\n#ifdef NONE_CONST_INDEX\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\n#else\n#define MAX_C CURVE_VALUE_COUNT\n#endif\nfloat evaluateCurveFrames(float time,vec4 keyframe0,vec4 keyframe1){float dt=keyframe1.x-keyframe0.x;float m0=keyframe0.w*dt;float m1=keyframe1.z*dt;float t=(time-keyframe0.x)/dt;float t2=t*t;float t3=t2*t;return dot(vec4(dot(vec3(2.,-3.,1.),vec3(t3,t2,1.)),dot(vec3(1,-2.,1),vec3(t3,t2,t)),t3-t2,dot(vec2(-2,3),vec2(t3,t2))),vec4(keyframe0.y,m0,m1,keyframe1.y));}float valueFromCurveFrames(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++){\n#ifdef NONE_CONST_INDEX\nif(i==count){return lookup_curve(count).y;}vec4 k0=lookup_curve(i+start);vec4 k1=lookup_curve(i+1+start);\n#else\nif(i<start){continue;}vec4 k0=lookup_curve(i);vec4 k1=lookup_curve(i+1);if(i==end){return k0.y;}\n#endif\nif(time>=k0.x&&time<=k1.x){return evaluateCurveFrames(time,k0,k1);}}return lookup_curve(0).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++){\n#ifdef NONE_CONST_INDEX\nif(i>count){return lookup_curve(i).w;}\n#else\nif(i<start){continue;}if(i>end){return lookup_curve(i-2).w;}\n#endif\n#ifdef NONE_CONST_INDEX\nvec4 seg=lookup_curve(i+start);\n#else\nvec4 seg=lookup_curve(i);\n#endif\nvec2 p0=seg.xy;vec2 p1=seg.zw;if(time>=p0.x&&time<=p1.x){return evaluteLineSeg(time,p0,p1);}\n#ifdef NONE_CONST_INDEX\nvec2 p2=lookup_curve(i+start+1).xy;\n#else\nvec2 p2=lookup_curve(i+1).xy;\n#endif\nif(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;}else if(type==1.){return mix(value.y,value.z,time/value.w);}if(type==2.){return valueFromCurveFrames(time,floor(value.y),floor(1./fract(value.y)+0.5))*value.w+value.z;}if(type==3.){return valueFromLineSegs(time,value.y,value.z);}if(type==4.){\n#ifdef SHADER_VERTEX\nfloat seed=aSeed;\n#else\nfloat seed=vSeed;\n#endif\nreturn mix(value.y,value.z,seed);}return 0.;}in vec4 aPos;in vec3 aDir;in vec3 aInfo;in vec4 aColor;in float aTime;\n#ifdef ATTR_TRAIL_START\nin float aTrailStart;\n#else\nuniform float uTrailStart[64];in 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\nout float vLife;out vec2 vTexCoord;out 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}",Mi="uniform vec4 uTexRange;uniform vec2 uFilterSourceSize;\n#define INTERPOLATION 0\nvec4 filterMain(vec2 texCoord,sampler2D source){float x=uTexRange.x+texCoord.x*uTexRange.y;\n#if INTERPOLATION\nvec2 texInPixel=texCoord*uFilterSourceSize;vec2 coordMin=floor(texInPixel);vec2 pp=texInPixel-coordMin;vec4 fCoord=vec4(coordMin/uFilterSourceSize,(coordMin+vec2(1.))/uFilterSourceSize);vec4 cLT=texture2D(uFilterSource,vec2(fCoord.x,fCoord.w));vec4 cLB=texture2D(uFilterSource,vec2(fCoord.x,fCoord.y));vec4 cRT=texture2D(uFilterSource,vec2(fCoord.z,fCoord.w));vec4 cRB=texture2D(uFilterSource,vec2(fCoord.z,fCoord.y));vec4 color=mix(mix(cLB,cRB,pp.x),mix(cLT,cRT,pp.x),pp.y);\n#else\nvec4 color=texture2D(source,vec2(x,texCoord.y));\n#endif\nx=uTexRange.z+texCoord.x*uTexRange.w;vec4 opacity=texture2D(source,vec2(x,texCoord.y));return vec4(color.rgb,opacity.r);}",Li="uniform sampler2D uAlphaXSample;uniform sampler2D uAlphaYSample;vec4 filterMain(vec2 texCoord,sampler2D source){vec4 color=texture2D(source,texCoord);float x=texture2D(uAlphaXSample,vec2(vFeatherCoord.x,0.)).r;float y=texture2D(uAlphaYSample,vec2(vFeatherCoord.y,0.)).r;return vec4(color.rgb,color.a*min(x,y));}",Ii="uniform mat4 uMoveCameraViewPro;vec4 filterMain(float p,vec4 pos){return uMoveCameraViewPro*pos;}",Pi="uniform sampler2D uLastSource;uniform vec4 uParams;vec4 filterMain(vec2 coord,sampler2D tex){vec4 c1=texture2D(tex,coord);if(uParams.x<1.){return c1;}vec4 c2=texture2D(uLastSource,coord);return mix(c1,c2,uParams.y);}",Fi="uniform vec4 uWaveParams;\n#ifdef PATICLE_SHADER\nin vec4 vWaveParams;\n#else\nuniform vec4 vWaveParams;\n#endif\nvec4 filterMain(vec2 texCoord,sampler2D tex){vec2 vp=texCoord-uWaveParams.xy;float xx=dot(vp,uWaveParams.zw);float d=sin(vWaveParams.x*xx+vWaveParams.y)*vWaveParams.z;vec2 up=vec2(-uWaveParams.w,uWaveParams.z)*d;return texture2D(tex,clamp(texCoord+up,0.,1.));}",Ni="uniform vec4 uMovementValue;uniform vec4 uStrengthValue;uniform vec4 uPeriodValue;out vec4 vWaveParams;void filterMain(float lifetime){const float pi2=3.14159265;vWaveParams=vec4(getValueFromTime(lifetime,uPeriodValue)*pi2,getValueFromTime(lifetime,uMovementValue)*pi2,getValueFromTime(lifetime,uStrengthValue),0.);}",Vi="uniform sampler2D uBloomBlur;uniform vec4 uBloomParams;vec4 filterMain(vec2 coord,sampler2D tex){const vec3 gamma=vec3(1./2.2);vec4 c1=texture2D(tex,coord);vec4 bloomColor=texture2D(uBloomBlur,coord);float alpha=max(c1.a,bloomColor.a);vec3 color=max(c1.rgb*c1.a,bloomColor.rgb*bloomColor.a)/alpha*uBloomParams.y+bloomColor.rgb*uBloomParams.x;return vec4(color,alpha);}",Di="uniform vec4 uColorThreshold;vec4 filterMain(vec2 coord,sampler2D tex){vec4 c1=texture2D(tex,coord);vec3 color=c1.rgb*c1.a;vec3 s=step(uColorThreshold.xyz,color);float m=min(s.r+s.g+s.b,1.);return c1*m;}",zi="precision highp float;attribute vec2 aPos;varying vec2 uv;void main(){gl_Position=vec4(aPos,0.,1.0);uv=(aPos+vec2(1.0))/2.;}",Bi="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;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));}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;}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=ACESToneMapping(finalColor);}gl_FragColor=vec4(clamp(GammaCorrection(finalColor),0.0,1.0),1.0);}",Ui="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);}",ki="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);}",Gi="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);}",Xi="precision highp float;varying vec2 uv;uniform sampler2D _MainTex;uniform float _Threshold;void main(){vec4 mainColor=texture2D(_MainTex,uv);mainColor.rgb=pow(mainColor.rgb,vec3(2.2));float brightness=max(mainColor.r,max(mainColor.g,mainColor.b));float w=max(0.0,brightness-_Threshold)/max(brightness,0.00001);mainColor.rgb*=w;gl_FragColor=vec4(mainColor.rgb,1.0);}",Hi=function(e){function i(r,i){var n=e.call(this,r,i)||this,o=n.renderer.engine,s=li.create(o,{mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),a=qr.create(o,{shader:{vertex:zi,fragment:Xi,glslVersion:t.GLSLVersion.GLSL1}});return a.blending=!1,a.depthTest=!1,a.culling=!1,n.screenMesh=gi.create(o,{geometry:s,material:a,priority:0}),n.priority=5e3,n}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],this.sceneTextureHandle.texture=this.mainTexture,t.setFrameBuffer(this.frameBuffer)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture);var r=e.renderingData.currentFrame.globalVolume.threshold;this.screenMesh.material.setFloat("_Threshold",r),e.renderMeshes([this.screenMesh])},i}(bi),Yi=function(e){function i(r,i,n){var o=e.call(this,r,n)||this;o.type=i;var s=o.renderer.engine,a="PostProcess",u=li.create(s,{name:a,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),l={vertex:zi,fragment:"H"==i?Ui:ki,glslVersion:t.GLSLVersion.GLSL1},c=qr.create(s,{name:a,shader:l});return c.blending=!1,c.depthTest=!1,c.culling=!1,o.screenMesh=gi.create(s,{name:a,geometry:u,material:c,priority:0}),o.priority=5e3,o}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setVector2("_TextureSize",Ji(this.mainTexture)),e.renderMeshes([this.screenMesh]),"V"===this.type&&(this.gaussianResult.texture=e.getFrameBuffer().getColorTextures()[0])},i}(bi),ji=function(e){function i(t,r){var i=e.call(this,t,r)||this,n="PostProcess",o=i.renderer.engine,s=li.create(o,{name:n,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),a={vertex:zi,fragment:Gi},u=qr.create(o,{name:n,shader:a});return u.blending=!1,u.depthTest=!1,u.culling=!1,i.screenMesh=gi.create(o,{name:n,geometry:s,material:u,priority:0}),i.priority=5e3,i}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear}),this.screenMesh.material.setTexture("_MainTex",this.mainTexture),this.screenMesh.material.setTexture("_GaussianDownTex",this.gaussianDownSampleResult.texture),this.screenMesh.material.setVector2("_GaussianDownTextureSize",Ji(this.gaussianDownSampleResult.texture)),e.renderMeshes([this.screenMesh])},i}(bi),Wi=function(e){function i(r,i){var n=e.call(this,r,{})||this,o="PostProcess",s=n.renderer.engine;n.sceneTextureHandle=i||new Ei(s);var a=li.create(s,{name:o,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),u=qr.create(s,{name:o,shader:{vertex:zi,fragment:Bi,glslVersion:t.GLSLVersion.GLSL1}});return u.blending=!1,u.depthTest=!1,u.culling=!1,n.screenMesh=gi.create(s,{name:o,geometry:a,material:u,priority:0}),n.priority=5e3,n}return r(i,e),i.prototype.configure=function(t){this.mainTexture=t.getFrameBuffer().getColorTextures()[0],this.sceneTextureHandle.texture||(this.sceneTextureHandle.texture=this.mainTexture),t.setFrameBuffer(null)},i.prototype.execute=function(e){e.clear({colorAction:t.TextureStoreAction.clear,depthAction:t.TextureStoreAction.clear,stencilAction:t.TextureStoreAction.clear});var r=e.renderingData.currentFrame.globalVolume,i=r.bloomIntensity,n=r.brightness,o=r.saturation,s=r.contrast,a=r.useBloom,u=r.useToneMapping;this.screenMesh.material.setTexture("_SceneTex",this.sceneTextureHandle.texture),this.screenMesh.material.setFloat("_Brightness",n),this.screenMesh.material.setFloat("_Saturation",o),this.screenMesh.material.setFloat("_Contrast",s),this.screenMesh.material.setInt("_UseBloom",a),a&&(this.screenMesh.material.setTexture("_GaussianTex",this.mainTexture),this.screenMesh.material.setFloat("_BloomIntensity",i)),this.screenMesh.material.setInt("_UseToneMapping",u),e.renderMeshes([this.screenMesh])},i}(bi),Zi={useHDR:!1,usePostProcessing:!1,useBloom:1,threshold:1,bloomIntensity:1,brightness:1,saturation:1,contrast:1,useToneMapping:1},qi="_effects_default_",Ki=1,Qi=function(){function e(e){var r;this.destroyed=!1,this.renderPassInfoMap=new WeakMap;var n=e.camera,o=e.keepColorBuffer,s=e.renderer,a=e.editorTransform,u=void 0===a?[1,1,0,0]:a,l=e.globalVolume,c=e.clearAction,h=void 0===c?{colorAction:t.TextureLoadAction.whatever,stencilAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.whatever}:c,f=s.engine;l&&(this.globalVolume=i(i({},Zi),l)),this.globalUniforms=new tn;var p,d=[],m={};if(this.renderer=s,this.globalVolume){var y=this.globalVolume.useHDR?v.HALF_FLOAT:v.UNSIGNED_BYTE;d=[{texture:{format:v.RGBA,type:y,magFilter:v.LINEAR,minFilter:v.LINEAR}}],p={storageType:t.RenderPassAttachmentStorageType.depth_stencil_opaque},m={colorAction:t.TextureLoadAction.clear,stencilAction:t.TextureLoadAction.clear,depthAction:t.TextureLoadAction.clear}}var g=[new bi(s,{name:qi,priority:xi,meshOrder:t.OrderType.ascending,depthStencilAttachment:p,attachments:d,clearAction:m})];if(this.setRenderPasses(g),this.globalVolume){var x=this.globalVolume.useBloom,T=new Ei(f);if(x){var E=[0,0,this.renderer.getWidth()/2,this.renderer.getHeight()/2],S=new Array(7),b=(y=this.globalVolume.useHDR?v.HALF_FLOAT:v.UNSIGNED_BYTE,new Hi(s,{name:"BloomThresholdPass",attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]}));b.sceneTextureHandle=T,this.addRenderPass(b);for(var A=0;A<7;A++){S[A]=new Ei(f);var _=new Yi(s,"H",{name:"GaussianDownPassH"+A,viewport:E,attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]}),C=new Yi(s,"V",{name:"GaussianDownPassV"+A,viewport:E,attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]});C.gaussianResult=S[A],this.addRenderPass(_),this.addRenderPass(C),E[2]/=2,E[3]/=2}E[2]*=4,E[3]*=4;for(A=0;A<6;A++){var R=new ji(s,{name:"GaussianUpPass"+A,viewport:E,attachments:[{texture:{format:v.RGBA,type:y,minFilter:v.LINEAR,magFilter:v.LINEAR}}]});R.gaussianDownSampleResult=S[5-A],this.addRenderPass(R),E[2]*=2,E[3]*=2}}var O=void 0;O=x?new Wi(s,T):new Wi(s),this.addRenderPass(O)}this.semantics=new ai(e.semantics),this.clearAction=h,this.name="RenderFrame".concat(Ki++);var w=g[0],M={type:v.UNSIGNED_BYTE,format:v.RGBA,internalFormat:v.RGBA,wrapS:v.MIRRORED_REPEAT,wrapT:v.MIRRORED_REPEAT,minFilter:v.NEAREST,magFilter:v.NEAREST};this.emptyTexture=Vr.create(f,i({data:{width:1,height:1,data:new Uint8Array([255,255,255,255])},sourceType:t.TextureSourceType.data},M)),this.transparentTexture=Vr.create(f,i({data:{width:1,height:1,data:new Uint8Array([0,0,0,0])},sourceType:t.TextureSourceType.data},M)),this.camera=n,this.keepColorBuffer=o,this.renderPassInfoMap.set(w,{listStart:0,listEnd:0,renderPass:w,intermedia:!1}),this.editorTransform=zt.fromArray(u),e.clearAction||this.resetClearActions(),this.passTextureCache=new si(f);var L=f.gpuCapability,I=L.detail,P=ri(L.level,I.readableDepthStencilTextures&&I.writableFragDepth);null===(r=this.renderer.getShaderLibrary())||void 0===r||r.addShader(P)}return Object.defineProperty(e.prototype,"renderPasses",{get:function(){return this._renderPasses.slice()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.addMeshToDefaultRenderPass=function(t){for(var e=this.renderPasses,r=this.renderPassInfoMap,i=t.priority,n=1;n<e.length;n++){var o=e[n-1],s=r.get(e[n]),a=r.get(o);if(s&&a&&(s.listStart>i&&(i>a.listEnd||1===n)))return this.addToRenderPass(o,t)}for(var u=e.length-1,l=e[u];u>=0&&!l.name.includes(qi);)l=e[--u];return this.addToRenderPass(l,t)},e.prototype.removeMeshFromDefaultRenderPass=function(e){for(var r,n,o,s=this,a=this.renderPasses,u=this.renderPassInfoMap,l=a.length-1;l>=0;l--){var c=a[l],h=u.get(c);if(h&&(h.listStart<=e.priority&&h.listEnd>=e.priority)){var f=c.meshes.indexOf(e);if(-1===f)return;var p=1===f&&c.meshes[0].name===Jr;if(c.removeMesh(e),p){var d=a[l+1],m=c.meshes;h.intermedia||null===(r=h.preRenderPass)||void 0===r||r.resetColorAttachments([]);for(var v=1;v<m.length;v++)null===(n=h.preRenderPass)||void 0===n||n.addMesh(m[v]);var y=null===(o=c.attachments[0])||void 0===o?void 0:o.texture,g=y===this.resource.color_a||y===this.resource.color_b;c.dispose({meshes:t.DestroyOptions.keep,colorAttachment:g?t.RenderPassDestroyAttachmentType.keep:t.RenderPassDestroyAttachmentType.destroy,depthStencilAttachment:t.RenderPassDestroyAttachmentType.keep}),B(a,c),this.removeRenderPass(c),u.delete(c),d&&this.updateRenderInfo(d),h.preRenderPass&&this.updateRenderInfo(h.preRenderPass),h.prePasses&&h.prePasses.forEach((function(e){if(s.removeRenderPass(e.pass),!1!==(null==e?void 0:e.destroyOptions)){e.pass.attachments.forEach((function(t){t.texture===s.resource.color_b&&t.texture===s.resource.color_a||t.texture.dispose()}));var r=i(i({},(null==e?void 0:e.destroyOptions)?e.destroyOptions:{}),{depthStencilAttachment:t.RenderPassDestroyAttachmentType.keep});e.pass.dispose(r)}})),this.resetRenderPassDefaultAttachment(a,Math.max(l-1,0)),1===a.length&&(a[0].resetColorAttachments([]),this.removeRenderPass(this.resource.finalCopyRP))}return this.resetClearActions()}}},e.prototype.splitDefaultRenderPassByMesh=function(e,r){var i,n,o,s=this.findMeshRenderPassIndex(e),l=this.renderPasses[s];this.createResource();var c=l.meshes.indexOf(e),h=l.meshes.slice(0,c),f=l.meshes.slice(c),p=this.renderPassInfoMap;if(!(null===(i=r.attachments)||void 0===i?void 0:i.length))throw Error("should include at least one color attachment");var d=this.renderPasses,m=d.indexOf(l);d[m-1],B(d,l);var y=p.get(l);p.delete(l);var g=2===this.renderer.engine.gpuCapability.level?v.LINEAR:v.NEAREST,x=new bi(this.renderer,{name:qi+m,priority:l.priority,attachments:[{texture:{sourceType:t.TextureSourceType.framebuffer,format:v.RGBA,name:"frame_a",minFilter:g,magFilter:g}}],clearAction:l.clearAction||{colorAction:t.TextureLoadAction.clear},storeAction:l.storeAction,depthStencilAttachment:this.resource.depthStencil,meshes:h,meshOrder:t.OrderType.ascending});f.unshift(this.createCopyMesh());var T=this.renderPasses;T[s]=x;var E=[],S=f.slice();r.prePasses&&(r.prePasses.forEach((function(t,e){t.priority=l.priority+1+e,t.setMeshes(f),E.push(t)})),T.splice.apply(T,u([s+1,0],a(E),!1)),S.splice(0,2));var b=this.resource.finalCopyRP;T.includes(b)||T.push(b);var A=E[E.length-1];A.initialize(this.renderer);var _=new bi(this.renderer,{name:qi+(m+1),priority:l.priority+1+((null===(n=r.prePasses)||void 0===n?void 0:n.length)||0),meshes:S,meshOrder:t.OrderType.ascending,depthStencilAttachment:this.resource.depthStencil,storeAction:r.storeAction,clearAction:{depthAction:t.TextureLoadAction.whatever,stencilAction:t.TextureLoadAction.whatever,colorAction:t.TextureLoadAction.whatever}});return T.splice(s+1+((null===(o=r.prePasses)||void 0===o?void 0:o.length)||0),0,_),this.setRenderPasses(T),this.updateRenderInfo(A),this.updateRenderInfo(x),this.updateRenderInfo(_),p.get(x).prePasses=y.prePasses,E.pop(),p.get(A).prePasses=E.map((function(t,e){return{pass:t,destroyOptions:!1}})),this.resetClearActions(),A},e.prototype.dispose=function(e){var r,i;(null==e?void 0:e.semantics)!==t.DestroyOptions.keep&&this.semantics.dispose();var n=(null==e?void 0:e.passes)?e.passes:void 0;n!==t.DestroyOptions.keep&&this._renderPasses.forEach((function(t){t.dispose(n)})),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=null===(r=this.resource.depthStencil)||void 0===r?void 0:r.texture)||void 0===i||i.dispose(),this.resource.finalCopyRP.dispose(),this.resource.resRP.dispose(),this.resource=null),this.destroyed=!0},e.prototype.resetRenderPassDefaultAttachment=function(t,e){for(var r,i,n,o=this.resource,s=o.color_a,a=o.color_b,u=e;u<t.length;u++){var l=t[u],c=null===(r=l.attachments[0])||void 0===r?void 0:r.texture;if(c&&n===c){var h=c===s?a:s;l.resetColorAttachments([h])}(c=null===(i=l.attachments[0])||void 0===i?void 0:i.texture)&&(n=c)}},e.prototype.findMeshRenderPassIndex=function(t){var e=-1;return this.renderPasses.every((function(r,i){return!r.name.startsWith(qi)||!r.meshes.includes(t)||(e=i,!1)})),e},e.prototype.addToRenderPass=function(t,e){var r=this.renderPassInfoMap.get(t),i=e.priority;0===t.meshes.length?r.listStart=r.listEnd=i:i<r.listStart?r.listStart=i:i>r.listEnd&&(r.listEnd=i),t.addMesh(e)},e.prototype.getRPAttachments=function(t,e){var r;if(1===(null==t?void 0:t.length)){var i=t[0],n=i.texture,o=i.persistent,s=n.format,a=null!==(r=null==e?void 0:e.getInitAttachments())&&void 0!==r?r:[];if(s===v.RGBA&&!o){var u=this.resource.color_a;return 0===a.length?[{texture:u}]:[{texture:a[0].texture===u?this.resource.color_b:u}]}}return t},e.prototype.resetClearActions=function(){var e=this.renderPasses.length>1?t.TextureLoadAction.clear:t.TextureLoadAction.whatever;this.clearAction.stencilAction=e,this.clearAction.depthAction=e,this.clearAction.colorAction=e,this.keepColorBuffer&&(this.clearAction.colorAction=t.TextureLoadAction.whatever)},e.prototype.updateRenderInfo=function(e){var r,i=this,n=this.renderPassInfoMap,o=this.renderPasses;n.has(e)?r=n.get(e):(r={intermedia:!1,renderPass:e,listStart:0,listEnd:0},n.set(e,r)),r.intermedia=e.attachments.length>0;var s=e.meshes;s[0]?(r.listStart=(s[0].name===Jr?s[1]:s[0]).priority,r.listEnd=s[s.length-1].priority):(r.listStart=0,r.listEnd=0);var a=o.indexOf(e),u=0===a?t.TextureLoadAction.clear:t.TextureLoadAction.whatever;return 0===a&&(e.clearAction.colorAction=t.TextureLoadAction.clear),e.clearAction.depthAction=u,e.clearAction.stencilAction=u,a>-1?e.semantics.setSemantic("EDITOR_TRANSFORM",(function(){return i.editorTransform})):e.semantics.setSemantic("EDITOR_TRANSFORM",void 0),r.preRenderPass=o[a-1],r},e.prototype.setRenderPasses=function(t){var e=this;void 0!==this.renderer&&t.forEach((function(t){return t.initialize(e.renderer)})),this._renderPasses=t.slice()},e.prototype.addRenderPass=function(t){void 0!==this.renderer&&t.initialize(this.renderer),this._renderPasses.push(t)},e.prototype.createResource=function(){var e,r=this.renderer.engine;if(!this.resource){var i=r.gpuCapability,n=i.detail,o=i.level,s=this.renderer.getWidth(),a=this.renderer.getHeight(),u=2===o?v.LINEAR:v.NEAREST,l=Vr.create(r,{sourceType:t.TextureSourceType.framebuffer,format:v.RGBA,name:"frame_a",minFilter:u,magFilter:u}),c=Vr.create(r,{sourceType:t.TextureSourceType.framebuffer,format:v.RGBA,data:{width:s,height:a},minFilter:u,magFilter:u,name:"frame_b"}),h=n.readableDepthStencilTextures&&n.writableFragDepth?t.RenderPassAttachmentStorageType.depth_24_stencil_8_texture:t.RenderPassAttachmentStorageType.depth_stencil_opaque,f=new bi(this.renderer,{depthStencilAttachment:{storageType:h},attachments:[{texture:l}]}).initialize(this.renderer),p=new $i(this.renderer,{name:"effects-final-copy",priority:1600,clearAction:{depthAction:t.TextureLoadAction.clear,stencilAction:t.TextureLoadAction.clear,colorAction:t.TextureLoadAction.clear},meshOrder:t.OrderType.ascending,meshes:[this.createCopyMesh({blend:!0,depthTexture:null===(e=f.getDepthAttachment())||void 0===e?void 0:e.texture})]});this.resource={color_a:f.attachments[0].texture,color_b:c,finalCopyRP:p,depthStencil:f.depthAttachment,resRP:f}}},e.prototype.createCopyMesh=function(t){var e=Jr,r=this.renderer.engine,i=li.create(r,{name:e,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),n=ri(r.gpuCapability.level,!!(null==t?void 0:t.depthTexture));this.renderer.getShaderLibrary().addShader(n);var o=qr.create(r,{uniformValues:{uDepth:null==t?void 0:t.depthTexture},name:e,shader:n});return o.blending=!1,o.depthTest=!1,o.culling=!1,(null==t?void 0:t.blend)&&(o.blending=!0,o.blendFunction=[v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA,v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA]),gi.create(r,{name:e,geometry:i,material:o,priority:0})},e.prototype.removeRenderPass=function(t){B(this._renderPasses,t)},e}();function Ji(t){return t?new wt(t.getWidth(),t.getHeight()):new wt}var $i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(null)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction)},e}(bi),tn=function(){this.floats={},this.ints={},this.matrices={},this.samplers=[],this.uniforms=[]},en=function(){function t(t){this.size=[0,0],this.multiSample=1,this.destroyed=!1;var e=t.storageType,r=t.format,i=t.attachment;this.storageType=e,this.format=r,this.attachment=i}return Object.defineProperty(t.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),t}(),rn="function"==typeof WebGL2RenderingContext,nn=function(){function t(t){this.setupCapability(t)}return t.prototype.setupCapability=function(t){var e,r=rn&&t instanceof WebGL2RenderingContext?2:1,i=2===r,n=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),o=t.getExtension("WEBGL_depth_texture"),s=!!t.getExtension("OES_texture_half_float_linear"),a=!!t.getExtension("OES_texture_float_linear");this.level=r,this.type=i?"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"),o&&(this.UNSIGNED_INT_24_8=o.UNSIGNED_INT_24_8_WEBGL),i&&!s&&(s=on(t,t.HALF_FLOAT)),i&&!a&&(a=on(t,t.FLOAT)),this.internalFormatDepth16=i?t.DEPTH_COMPONENT16:t.DEPTH_COMPONENT,this.internalFormatDepth24_stencil8=i?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL;var u=i||t.getExtension("OES_texture_float")?t.FLOAT:0,l=i?WebGL2RenderingContext.HALF_FLOAT:(null===(e=t.getExtension("OES_texture_half_float"))||void 0===e?void 0:e.HALF_FLOAT_OES)||0,c={floatTexture:u,halfFloatTexture:l,maxSample:i?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:i?!!t.getExtension("EXT_color_buffer_float"):u>0&&!!t.getExtension("WEBGL_color_buffer_float"),halfFloatColorAttachment:i?!!t.getExtension("EXT_color_buffer_float"):l>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:ln(t),halfFloatLinear:s,floatLinear:a,maxTextureAnisotropy:n?t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,shaderTextureLod:i||!!t.getExtension("EXT_shader_texture_lod"),instanceDraw:i||!!t.getExtension("ANGLE_instanced_arrays"),drawBuffers:i||!!this.drawBufferExtension,asyncShaderCompile:!!t.getExtension("KHR_parallel_shader_compile"),intIndexElementBuffer:!!t.getExtension("OES_element_index_uint"),standardDerivatives:i||!!t.getExtension("OES_standard_derivatives"),readableDepthStencilTextures:i||!!o,writableFragDepth:i||!!t.getExtension("EXT_frag_depth")};this.detail=c,n&&(this.textureMaxAnisotropyExt=n.TEXTURE_MAX_ANISOTROPY_EXT)},t.prototype.framebufferTexture2D=function(t,e,r,i,n){var o=this.drawBufferExtension;if(1===this.level&&!o&&r>0)throw new Error("draw multiple color buffers not available");var s=o?o["COLOR_ATTACHMENT".concat(r,"_WEBGL")]:t["COLOR_ATTACHMENT".concat(r)];s?t.framebufferTexture2D(e,s,i,n,0):console.error("invalid color attachment index: "+r)},t.prototype.drawBuffers=function(t,e){var r=this.drawBufferExtension;if(1!==this.level||r){var i=e.map((function(e,i){return e?r?r["COLOR_ATTACHMENT".concat(i,"_WEBGL")]:t["COLOR_ATTACHMENT".concat(i)]:t.NONE}));r?r.drawBuffersWEBGL(i):t.drawBuffers(i)}else if(e.length>1)throw Error("draw buffers not available")},t.prototype.setTextureAnisotropic=function(t,e,r){var i=this.detail.maxTextureAnisotropy;i&&t.texParameterf(e,this.textureMaxAnisotropyExt,Math.min(i,r||4))},t}();function on(t,e){var r=t.createTexture(),i=!1;return t.getError(),t.bindTexture(t.TEXTURE_2D,r),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()||(i=!0),t.deleteTexture(r),i}var sn,an,un={NONE:0,PVRTC:1,ASTC:2};function ln(t){return t.getExtension("WEBGL_compressed_texture_astc")?un.ASTC:t.getExtension("WEBGL_compressed_texture_pvrtc")||t.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc")?un.PVRTC:un.NONE}t.FilterMode=void 0,(sn=t.FilterMode||(t.FilterMode={}))[sn.Nearest=0]="Nearest",sn[sn.Linear=1]="Linear",t.RenderTextureFormat=void 0,(an=t.RenderTextureFormat||(t.RenderTextureFormat={}))[an.RGBA32=0]="RGBA32",an[an.RGBAHalf=1]="RGBAHalf";var cn=function(){function t(){}return t.prototype.resize=function(t,e,r,i){},t.prototype.resetColorTextures=function(t){},t.prototype.unbind=function(){},t.prototype.bind=function(){},Object.defineProperty(t.prototype,"stencilStorage",{get:function(){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthStorage",{get:function(){},enumerable:!1,configurable:!0}),t.prototype.getDepthTexture=function(){},t.prototype.getStencilTexture=function(){},t.prototype.getColorTextures=function(){return[]},t.prototype.dispose=function(t){},t}(),hn=function(){function t(){}return t.prototype.setGlobalFloat=function(t,e){},t.prototype.setGlobalInt=function(t,e){},t.prototype.setGlobalMatrix=function(t,e){},t.prototype.getFrameBuffer=function(){return null},t.prototype.setFrameBuffer=function(t){},t.prototype.setViewport=function(t,e,r,i){},t.prototype.resize=function(t,e){},t.prototype.clear=function(t){},t.prototype.getWidth=function(){return 0},t.prototype.getHeight=function(){return 0},t.prototype.addLostHandler=function(t){},t.prototype.addRestoreHandler=function(t){},t.prototype.lost=function(t){},t.prototype.restore=function(){},t.prototype.getShaderLibrary=function(){},t.prototype.renderRenderFrame=function(t){},t.prototype.renderMeshes=function(t){},t.prototype.drawGeometry=function(t,e){},t.prototype.getTemporaryRT=function(t,e,r,i,n,o){return null},t.prototype.dispose=function(t){},t}(),fn=1,pn=function(){function e(t,e,r,i){this.transform=r,this.engine=i,this.color=t.options.previewColor;var n=this.createMaterial(e),o=this.createGeometry();this.mesh=this.createMesh(o,n),this.updateMesh()}return e.prototype.updateMesh=function(){var t=this.mesh.material,e=t.getVector2("uSize").clone(),r=t.getVector4("uPos").clone(),i=new Mt,n=new Lt,o=this.transform.scale.clone();this.transform.assignWorldTRS(i,n,o),e.x=o.x,e.y=o.y,r.x=i.x,r.y=i.y,r.z=i.z,t.setVector2("uSize",e),t.setVector4("uPos",r),t.setQuaternion("uQuat",n)},e.prototype.createMaterial=function(e){var r,i=[["ENV_EDITOR",(null===(r=this.engine.renderer)||void 0===r?void 0:r.env)===c]],n=be(this.color).getValue(0),o=this.engine.gpuCapability.level,s={shader:{vertex:br(i,"\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",t.ShaderType.vertex,o),fragment:br(i,"\nprecision highp float;\n\n#define fragColor gl_FragColor\n\nvarying vec4 vColor;\nvoid main() {\n gl_FragColor = vColor;\n}\n",t.ShaderType.fragment,o),glslVersion:t.GLSLVersion.GLSL1,cacheId:"".concat(e.cachePrefix,"_effects_interact")},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},a=qr.create(this.engine,s);return a.depthTest=!1,a.setVector4("uPos",new zt(0,0,0,0)),a.setVector2("uSize",new wt(1,1)),a.setVector4("uColor",new zt(n[0]/255,n[1]/255,n[2]/255,n[3])),a.setQuaternion("uQuat",new Lt(0,0,0,0)),a},e.prototype.createGeometry=function(){var t=new Uint8Array([0,1,1,2,2,3,3,0]);return li.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:v.LINES,maxVertex:4})},e.prototype.createMesh=function(t,e){return gi.create(this.engine,{name:"Interact_preview"+fn++,priority:0,worldMatrix:Ft.fromIdentity(),geometry:t,material:e})},e}(),dn=function(e){function n(t,r){var i,n=e.call(this,t,r)||this;return n.engine=null===(i=n.composition)||void 0===i?void 0:i.getEngine(),n}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.interact},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){this.ui=t.content},n.prototype.onLifetimeBegin=function(t){var e,r,i,n=this.ui.options,o=(null!==(r=null===(e=this.engine)||void 0===e?void 0:e.renderer)&&void 0!==r?r:{}).env;null===(i=this.composition)||void 0===i||i.addInteractiveItem(this,n.type),n.type===R.DRAG&&(o!==c||n.enableInEditor)&&t.event&&this.beginDragTarget(n,t.event)},n.prototype.onItemUpdate=function(){var t;if(null===(t=this.previewContent)||void 0===t||t.updateMesh(),this.dragEvent&&this.bouncingArg){this.bouncingArg.vx*=.95,this.bouncingArg.vy*=.95,this.bouncingArg.dy+=this.bouncingArg.vy,this.bouncingArg.dx+=this.bouncingArg.vx,mn(this.bouncingArg)?(this.dragEvent=null,this.bouncingArg=null):this.handleDragMove(this.dragEvent,this.bouncingArg)}},n.prototype.onItemRemoved=function(t){var e;t.removeInteractiveItem(this,this.ui.options.type),this.clickable=!1,null===(e=this.previewContent)||void 0===e||e.mesh.dispose(),this.endDragTarget()},n.prototype.getBoundingBox=function(){var e=this.transform.getWorldMatrix(),r=le(Mt.ZERO,.5,.5);return r.forEach((function(t){e.transformPoint(t.p0),e.transformPoint(t.p1),e.transformPoint(t.p2)})),{type:t.HitTestType.triangle,area:r}},n.prototype.getHitTestParams=function(){if(this.clickable){var t=this.ui.options.behavior,e=this.getBoundingBox();return e?{type:e.type,triangles:e.area,behavior:t}:void 0}},n.prototype.doCreateContent=function(t){var e,r=this.ui.options,i=r.type,n=r.showPreview,o=this.engine,s=(null!==(e=null==o?void 0:o.renderer)&&void 0!==e?e:{}).env;if(rt(o),i===R.CLICK&&(this.clickable=!0,n&&s===c)){var a=t.getRendererOptions();this.previewContent=new pn(this.ui,a,this.transform,o)}return{}},n.prototype.beginDragTarget=function(t,e){var r=this;if("camera"===t.target){var n,o={touchstart:function(t){var e;r.dragEvent=null,r.bouncingArg=null;var i=null===(e=r.composition)||void 0===e?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){var e=r.bouncingArg;if(!mn(e,3)&&e){e.vx*=5,e.vy*=5,r.dragEvent=i({},n)}n=null}};Object.keys(o).forEach((function(t){e.addEventListener(t,o[t])})),o.touchmove({dx:0,dy:0,width:1,height:1}),this.endDragTarget=function(){Object.keys(o).forEach((function(t){e.removeEventListener(t,o[t])}))}}},n.prototype.endDragTarget=function(){},n.prototype.handleDragMove=function(t,e){var r,i;if(t&&t.cameraParam&&this.composition){var n=this.ui.options,o=t.cameraParam,s=o.position,u=o.fov,l=e.dy,c=e.dx*e.width/e.height,h=s[2],f=Math.tan(u*Math.PI/180/2)*Math.abs(h),p=l*f,d=c*f,m=s[0]-d,v=s[1]-p;if(n.dxRange){var y=a(n.dxRange,2);(m=Rt(m,g=y[0],x=y[1]))!==g&&m!==x&&g!==x&&(null===(r=e.origin)||void 0===r||r.preventDefault())}if(n.dyRange){var g,x,T=a(n.dyRange,2);(v=Rt(v,g=T[0],x=T[1]))!==g&&v!==x&&g!==x&&(null===(i=e.origin)||void 0===i||i.preventDefault())}this.composition.camera.position=new Mt(m,v,h)}},n}(Qe);function mn(t,e){var r=1e-5*(e||1);return t&&Math.abs(t.vx||0)<r&&Math.abs(t.vy||0)<r}var vn=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.mesh=[],e}return r(e,t),e.prototype.onCompositionItemLifeBegin=function(t,e){e instanceof dn&&e.previewContent&&this.addMesh(e.previewContent.mesh)},e.prototype.onCompositionItemRemoved=function(t,e){e instanceof dn&&e.previewContent&&this.removeMesh(e.previewContent.mesh,t.renderFrame)},e.prototype.prepareRenderFrame=function(t,e){return this.mesh&&this.mesh.forEach((function(t){return e.addMeshToDefaultRenderPass(t)})),this.mesh=[],!1},e.prototype.addMesh=function(t){this.mesh.push(t)},e.prototype.removeMesh=function(t,e){e.removeMeshFromDefaultRenderPass(t)},e}(sr),yn=function(){};t.maxSpriteMeshItemCount=8,t.maxSpriteTextureCount=8;var gn=1,xn=function(){function e(t,e,r){this.engine=t,this.composition=r,this.items=[],this.dirty=!1;var i=e.wireframe,n=this.createGeometry(i?v.LINES:v.TRIANGLES),o=this.createMaterial(e,2);this.wireframe=i,this.mesh=gi.create(t,{name:"MSprite"+gn++,priority:0,worldMatrix:Ft.fromIdentity(),geometry:n,material:o})}return e.prototype.setItems=function(e){var r,i,n,o,s,a=[],u=[],l=2,c=0,h=0,f=0;if(!e.length)return this.mesh.setVisible(!1),!0;for(var p=0;p<e.length;p++)if(e[p].renderInfo){s=e[p].renderInfo;break}if(!s)return!0;this.items=e.slice(),e.length>2&&(l=t.maxSpriteMeshItemCount),this.mtlSlotCount!==l&&this.mesh.setMaterial(this.createMaterial(s,l),{textures:t.DestroyOptions.keep});var d=null!==(o=null===(n=null===(i=null===(r=s.filter)||void 0===r?void 0:r.passSplitOptions)||void 0===i?void 0:i.attachments)||void 0===n?void 0:n.length)&&void 0!==o?o:0;this.splitLayer=d>0;for(p=0;p<e.length;p++){(C=null==(m=e[p])?void 0:m.renderer.texture)&&z(u,C),m.mesh=this}for(p=0;p<e.length;p++){var m,y=(C=null==(m=e[p])?void 0:m.renderer.texture)?u.indexOf(C):-1,g=this.getItemInitData(m,p,f,y);c+=g.aPoint.length,h+=g.index.length,a.push(g),f+=g.aPoint.length/6,this.updateItem(m,!0)}var x={aPoint:new Float32Array(c),index:new Uint16Array(h)},T={aPoint:0,index:0},E=function(t){var e=a[t];Object.keys(x).forEach((function(t){var r=x[t],i=e[t];r.set(i,T[t]),T[t]+=i.length}))};for(p=0;p<a.length;p++)E(p);var S=this.mesh,b=S.material,A=S.geometry,_=x.index;A.setIndexData(_),A.setAttributeData("aPoint",x.aPoint),A.setDrawCount(h),this.mesh.setVisible(!!A.getDrawCount()),this.mesh.priority=e[0].listIndex;for(p=0;p<u.length;p++){var C=u[p];b.setTexture("uSampler"+p,C)}for(var R=e[0].emptyTexture,O=u.length;O<t.maxSpriteMeshItemCount;O++)b.setTexture("uSampler"+O,R);if(this.splitLayer){var w=function(t,e){var r;if(e){for(var i=128,n=new Uint8Array(i),o=0,s=i-1;o<i;o++){var a=o/s,u=e.getValue(a);n[o]=Math.round(255*u)}r=Vr.createWithData(t,{width:i,height:1,data:n},{name:"feather",format:v.LUMINANCE,minFilter:v.LINEAR,magFilter:v.LINEAR,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE})}else r=Vr.createWithData(t);return r}(this.engine,e[0].feather);b.setTexture("uFeatherSampler",w)}},e.prototype.updateItem=function(t,e){var r=this.items.indexOf(t);if(!(r<=-1)){var i=this.mesh.material.getVector4Array("uTexParams"),n=4*r,o=t.getRenderData(t.time,e),s=this.mesh.material.getMatrixArray("uMainData"),l=16*r,c=l,h=l+4,f=l+8,p=l+12,d=new Mt,m=new Lt,v=new Mt,y=o.color||[s[p],s[p+1],s[p+2],s[p+3]];if(o.visible)o.transform.assignWorldTRS(d,m,v);else if(!e)return void(s[h+2]=-1);var g=u(u([],a(d.toArray()),!1),[0],!1),x=u(u([],a(v.toArray()),!1),[0],!1),T=m.toArray();isNaN(t.getCustomOpacity())||(y[3]=t.getCustomOpacity());for(var E=0;E<4;E++)s[c+E]=g[E],s[f+E]=T[E],s[h+E]=x[E],s[p+E]=y[E];if(x[2]=o.life,s[h+2]=o.life,e){var S=t.renderer;i[n]=S.occlusion?+S.transparentOcclusion:1,i[n+2]=S.renderMode,i[n+1]=+this.preMultiAlpha}if(o.texOffset){var b=this.mesh.material.getVector4Array("uTexOffset");for(E=0;E<4;E++)b[4*r+E]=o.texOffset[E]}}},e.prototype.applyChange=function(){this.dirty&&(this.setItems(this.items),this.dirty=!1)},e.prototype.getItemInitData=function(t,e,r,i){var n=t.geoData;this.lineMode?n=this.getItemGeometryData(t,e):n||(n=t.geoData=this.getItemGeometryData(t,e));var o=n.aPoint;if(o[4]!==e||o[5]!==i)for(var s=0;s<o.length;s+=6)o[s+4]=e,o[s+5]=i;var a=n.index,u=a.length,l=this.wireframe?new Uint8Array([0,1,1,3,2,3,2,0]):new a.constructor(u);if(!this.wireframe)for(s=0;s<u;s++)l[s]=r+a[s];return{aPoint:n.aPoint,index:l}},e.prototype.getItemRegionData=function(t){var e=this.items.indexOf(t);if(e>-1){var r=this.mesh.material.getMatrixArray("uMainData"),i=16*e;if(null===r)return;return{position:[r[i]||0,r[i+1]||0,r[i+2]||0],size:[r[i+4],r[i+5]],quat:[r[i+8],r[i+9],r[i+10],r[i+11]],color:[r[i+12],r[i+13],r[i+14],r[i+15]]}}},e.prototype.invalidMaterial=function(){this.mtlSlotCount=0},e.prototype.createGeometry=function(e){var r=Float32Array.BYTES_PER_ELEMENT;return li.create(this.engine,{attributes:{aPoint:{size:4,offset:0,stride:l*r,releasable:!0,type:v.FLOAT,data:new Float32Array(0)},aIndex:{size:2,offset:4*r,stride:l*r,dataSource:"aPoint",type:v.FLOAT}},indices:{data:new Uint16Array(0),releasable:!0},mode:e,maxVertex:4*t.maxSpriteMeshItemCount})},e.prototype.createMaterial=function(t,e){var r,n,o,a=t.filter,u=t.side,l=t.occlusion,c=t.blending,h=t.maskMode,f=t.mask,p=(null==a?void 0:a.mesh)||{},d=this.engine,m={shader:An(t,e,d.gpuCapability.level,null===(o=d.renderer)||void 0===o?void 0:o.env)};this.preMultiAlpha=xr(c),this.mtlSlotCount=e;var v=qr.create(d,m),y=i({side:u,blending:!0,blendMode:c,mask:f,maskMode:h,depthTest:!0,depthMask:l},p.materialStates);v.blending=y.blending,v.stencilRef=void 0!==y.mask?[y.mask,y.mask]:void 0,v.depthTest=y.depthTest,v.depthMask=y.depthMask,y.blending&&Ar(v,y.blendMode),v.blendFunction=y.blendFunction,Cr(v,y.maskMode),_r(v,y.side);var g=p.uniformValues;if(g)try{for(var x=s(Object.keys(g)),T=x.next();!T.done;T=x.next()){var E=T.value,S=g[E];S instanceof Vr?v.setTexture(E,S):"number"==typeof S?v.setFloat(E,S):2===S.length?v.setVector2(E,wt.fromArray(S)):4===S.length?v.setVector4(E,zt.fromArray(S)):v.setMatrix(E,Ft.fromArray(S))}}catch(t){r={error:t}}finally{try{T&&!T.done&&(n=x.return)&&n.call(x)}finally{if(r)throw r.error}}for(var b=[],A=[],_=[],C=0;C<e;C++)b.push(Ft.fromIdentity()),A.push(new zt),_.push(new zt);return v.hasUniform("uMainData")||v.setMatrixArray("uMainData",b),v.hasUniform("uTexParams")||v.setVector4Array("uTexParams",A),v.hasUniform("uTexOffset")||v.setVector4Array("uTexOffset",_),v},e.prototype.getItemGeometryData=function(t,e){var r=t.splits,i=t.renderer,n=t.textureSheetAnimation,o=t.startSize,s=o.x,a=o.y;if(i.shape){for(var u=i.shape,l=u.index,c=u.aPoint,h=new Float32Array(c),f=0;f<h.length;f+=6)h[f]*=s,h[f+1]*=a;return{index:l,aPoint:Array.from(h)}}var p=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],d=[],m=[],v=2,y=2;1===r.length&&(v=1,y=1);for(var g=0;g<v;g++)for(var x=0;x<y;x++){var T=4*(2*x+g),E=n?[0,0,1,1,r[0][4]]:r[2*x+g],S=E[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],b=((g+g+1)/v-1)/2,A=((x+x+1)/y-1)/2,_=E[0],C=E[1],R=E[4]?E[3]:E[2],O=E[4]?E[2]:E[3],w=[p[0]/v+b,p[1]/y+A,p[2]/v+b,p[3]/y+A,p[4]/v+b,p[5]/y+A,p[6]/v+b,p[7]/y+A];d.push(w[0]*s,w[1]*a,S[0]*R+_,S[1]*O+C,e,0,w[2]*s,w[3]*a,S[2]*R+_,S[3]*O+C,e,0,w[4]*s,w[5]*a,S[4]*R+_,S[5]*O+C,e,0,w[6]*s,w[7]*a,S[6]*R+_,S[7]*O+C,e,0),this.lineMode?m.push(T,1+T,1+T,3+T,3+T,2+T,2+T,T):m.push(T,1+T,2+T,2+T,1+T,3+T)}return{index:m,aPoint:d}},e}();function Tn(e){return t.maxSpriteTextureCount=Math.min(e.maxFragmentTextures,16),e.maxVertexUniforms>=256?t.maxSpriteMeshItemCount=32:e.maxVertexUniforms>=128?t.maxSpriteMeshItemCount=16:void(t.maxSpriteTextureCount=8)}function En(t){var e,r=t.renderer,i=t.filter,n=r.blending,o=r.side,s=r.occlusion,a=r.mask,u=r.maskMode,l=r.order,c=+n,h=t.cachePrefix||"-",f=(null===(e=null==i?void 0:i.mesh)||void 0===e?void 0:e.shaderCacheId)||"$F$";return{side:o,occlusion:s,blending:n,mask:a,maskMode:u,cachePrefix:h,filter:i,cacheId:"".concat(h,".").concat(f,".").concat(+o,"+").concat(+s,"+").concat(c,"+").concat(l,"+").concat(u,".").concat(a)}}function Sn(e,r,i){var n=null!=i?i:{},o=n.count,s=void 0===o?2:o,a=n.env,u=void 0===a?"":a,l=n.ignoreBlend,h=n.wireframe,f=[["MAX_ITEM_COUNT",s],["PRE_MULTIPLY_ALPHA",!1],["ENV_EDITOR",u===c],["ADJUST_LAYER",!!r],["USE_BLEND",!l],["MAX_FRAG_TEX",t.maxSpriteTextureCount>=16?16:8]],p=h?Ai:Ci.replace(/#pragma\s+FILTER_FRAG/,(null==r?void 0:r.fragment)||""),d=_i.replace(/#pragma\s+FILTER_VERT/,(null==r?void 0:r.vertex)||"vec4 filterMain(float t,vec4 pos){return effects_MatrixVP * pos;}");return{fragment:br(f,p,t.ShaderType.fragment,e),vertex:br(f,d,t.ShaderType.vertex,e),glslVersion:1===e?t.GLSLVersion.GLSL1:t.GLSLVersion.GLSL3,marcos:f,shared:!0}}function bn(t,e){return t.filter?"".concat(t.filter.mesh.shaderCacheId,"_effects_filter"):"".concat(t.cachePrefix,"_effects_sprite_").concat(e)}function An(t,e,r,i){var n=t.filter,o=t.wireframe,s=Sn(r,null==n?void 0:n.mesh,{count:e,wireframe:o,env:i});return s.shared=!0,o||(s.cacheId=bn(t,e)),s}var _n="listIndex",Cn=function(){function e(t){this.composition=t,this.meshSplits=[],this.items=[],this.meshes=[],this.time=0,this.itemsToRemove=[],this.itemsToAdd=[],this.engine=t.getEngine()}return e.prototype.resetMeshSplits=function(){this.meshSplits.length=0,this.meshes.length=0,this.items.length=0,this.itemsToAdd.length=0,this.itemsToRemove.length=0},e.prototype.diffMeshSplits=function(){for(var e,r,i,n,o,s,l=this.meshSplits,c=this.itemsToRemove,h=this.itemsToAdd,f=[],p=[],d=[],m=[],v=this.items,y={layerToAdd:[]},g=[],x=0;x<c.length;x++){if(Rn(S=c[x]))f.push.apply(f,u([],a(this.removeMeshSplitsItem(v,S,l,c)),!1)),this.check();else{var T=v.indexOf(S);T>-1&&(v.splice(T,1),g.length=0,T>0&&(g=this.combineSplits(v,T-1,l),f.push.apply(f,u([],a(g),!1))),!g.length&&T<=v.length-1&&(g=this.combineSplits(v,T,l),f.push.apply(f,u([],a(g),!1))),this.check())}}var E=!1;for(x=0;x<h.length;x++)for(var S=h[x],b=this.addMeshSplitsItem(v,S,l),A=0;A<b.length;A++){var _=b[A];if(_.spriteMesh)throw new Error("no sprite mesh in neo split");var C=_.spriteMesh=new xn(this.engine,_.renderInfo,this.composition);p.push(C.mesh),C.setItems(_.items.map((function(t){return t.content}))),C.applyChange(),C.splitLayer&&(null===(e=y.layerToAdd)||void 0===e||e.push(C)),_.dirty=!1,this.check(),E=!0}if(E){var R,O=function(e){var a=l[e],u=l[e+1];if(u.cacheId===a.cacheId&&!(null===(r=u.spriteMesh)||void 0===r?void 0:r.splitLayer)&&!(null===(i=a.spriteMesh)||void 0===i?void 0:i.splitLayer)&&a.items.length+u.items.length<=t.maxSpriteMeshItemCount){var c=a.items[0],h=u.items[u.items.length-1],f=w.getMeshSplits(v,v.indexOf(c),v.indexOf(h));if(1===f.length){Object.keys(f[0]).forEach((function(t){a[t]=f[0][t]})),null===(n=a.spriteMesh)||void 0===n||n.setItems(a.items.map((function(t){return t.content}))),null===(o=a.spriteMesh)||void 0===o||o.applyChange();var m=null===(s=u.spriteMesh)||void 0===s?void 0:s.mesh;a.spriteMesh&&a.spriteMesh.mesh&&(a.spriteMesh.mesh.priority=u.indexEnd),p.includes(m)?B(p,m):z(d,m),l.splice(e+1,1),e--}}R=e},w=this;for(x=0;x<l.length-1;x++)O(x),x=R}c.length=0;for(x=0;x<l.length;x++){var M=(I=l[x]).spriteMesh;if(0===I.items.length)throw new Error("split not combined");if(I.dirty){var L=I.indexStart;M.mesh.priority!==L&&(M.mesh.priority=L,m.push(M.mesh)),M.setItems(I.items.map((function(t){return t.content})))}M.applyChange(),I.dirty=!1}if(f.length)for(x=0;x<f.length;x++){var I,P=(C=(I=f[x]).spriteMesh).mesh;P.dispose({material:{textures:t.DestroyOptions.keep}}),d.push(P)}if(this.itemsToRemove.length=0,this.itemsToAdd.length=0,p.length+d.length+m.length){var F=this.meshes;return this.meshSplits.forEach((function(t,e){return F[e]=t.spriteMesh.mesh})),F.length=this.meshSplits.length,{add:p.length?p:void 0,remove:d.length?d:void 0,modify:m.length?m:void 0,layer:y.layerToAdd.length>0?y:void 0}}},e.prototype.addItem=function(t){this.items.includes(t)?B(this.itemsToRemove,t):z(this.itemsToAdd,t)},e.prototype.removeItem=function(t){this.items.includes(t)?Rn(t)?this.itemsToRemove.unshift(t):this.itemsToRemove.push(t):B(this.itemsToAdd,t)},e.prototype.getSpriteMesh=function(t){for(var e=this.meshSplits,r=0;r<e.length;r++){var i=e[r].spriteMesh;if(i.items.indexOf(t)>-1)return i}},e.prototype.onUpdate=function(t){for(var e=this.meshSplits,r=0;r<e.length;r++){for(var i=e[r].spriteMesh,n=i.items,o=0;o<n.length;o++){var s=n[o];s.ended||i.updateItem(s)}i.applyChange()}},e.prototype.dispose=function(){this.meshSplits.forEach((function(t){var e;null===(e=t.spriteMesh)||void 0===e||e.mesh.dispose()}))},e.prototype.check=function(){},e.prototype.addMeshSplitsItem=function(t,e,r){if(-1!==t.indexOf(e))throw Error("item has been added");if(!r[0]){if(U(t,e,_n),Rn(e)){var i=e.createContent(),n={indexStart:e.listIndex,indexEnd:e.listIndex,items:[e],renderInfo:i.renderInfo,cacheId:i.renderInfo.cacheId,textures:[e.content.renderer.texture]};return r.unshift(n),[n]}return[]}for(var o=function(i){var n=r[i],o=e.listIndex;if(Rn(e)){if(o<=n.indexEnd){U(t,e,_n);var a=t.indexOf(e),u=Math.min(a,t.indexOf(n.items[0])),l=Math.max(a,t.indexOf(n.items[n.items.length-1])),c=s.getMeshSplits(t,u,l),h=c.findIndex((function(t){return t.items.includes(e)}));if(2===c.length)return r.splice(i+h,0,c[h]),Object.keys(c[1-h]).forEach((function(t){n[t]=c[1-h][t]})),{value:[c[h]]};if(3===c.length){if(Object.keys(c[0]).forEach((function(t){n[t]=c[0][t]})),r.splice(i+1,0,c[1],c[2]),1!==h)throw Error("neo split not in middle");return{value:[c[1],c[2]]}}if(1!==c.length)throw Error("invalid splits 1");return Object.keys(c[0]).forEach((function(t){n[t]=c[0][t]})),{value:[]}}}else{if(o<n.indexStart||o===n.indexEnd)return U(t,e,_n),{value:[]};if(o<n.indexEnd){U(t,e,_n);var f=n.items[n.items.length-1],p=t.indexOf(f),d=s.getMeshSplits(t,t.indexOf(n.items[0]),p);if(Object.keys(d[0]).forEach((function(t){n[t]=d[0][t]})),2===d.length)return r.splice(i+1,0,d[1]),{value:[d[1]]};if(1!==d.length)throw Error("invalid splits 2")}}},s=this,a=0;a<r.length;a++){var u=o(a);if("object"==typeof u)return u.value}if(U(t,e,_n),Rn(e)){var l=r[r.length-1],c=this.getMeshSplits(t,t.indexOf(l.items[0]),t.indexOf(e));if(Object.keys(c[0]).forEach((function(t){l[t]=c[0][t]})),2===c.length)return r.push(c[1]),[c[1]];if(1!==c.length)throw Error("invalid splits 3")}return[]},e.prototype.removeMeshSplitsItem=function(t,e,r,i){for(var n,o,s=null,a=-1,u=[],l=0;l<r.length;l++){var c=r[l];if(c.indexStart<=e.listIndex&&c.indexEnd>=e.listIndex){s=c,a=l;break}}if(s){var h=s.items.indexOf(e);if(h<0){if(null==i?void 0:i.includes(e))return[];throw Error("item not found")}if(s.items.splice(h,1),s.dirty=!0,B(t,e),0===s.items.length){if(B(r,s),u.push(s),s=r[a-=1],!r.length||a<0)return u}else s.indexEnd=s.items[s.items.length-1].listIndex,s.indexStart=s.items[0].listIndex;if(0===a||a===r.length-2){var f=r[a],p=r[a+1];if(f&&p){var d=f.items[0],m=p.items[p.items.length-1];1===(v=this.getMeshSplits(t,t.indexOf(d),t.indexOf(m))).length&&(v[0].spriteMesh=r[a].spriteMesh,null===(n=v[0].spriteMesh)||void 0===n||n.invalidMaterial(),r[a]=v[0],u.push(r.splice(a+1,1)[0]))}}else if(a===r.length-1)if(0===s.items.length)u.push(r.splice(a,1)[0]);else{f=r[a-1],p=r[a],d=f.items[0],m=p.items[p.items.length-1];1===(v=this.getMeshSplits(t,t.indexOf(d),t.indexOf(m))).length&&(v[0].spriteMesh=r[a-1].spriteMesh,null===(o=v[0].spriteMesh)||void 0===o||o.invalidMaterial(),r[a-1]=v[0],u.push(r.splice(a,1)[0]))}else{var v;f=r[a-1],p=r[a+1],d=f.items[0],m=p.items[p.items.length-1];2===(v=this.getMeshSplits(t,t.indexOf(d),t.indexOf(m))).length&&(v[0].spriteMesh=r[a].spriteMesh,v[1].spriteMesh=r[a+1].spriteMesh,r[a]=v[0],r[a+1]=v[1],u.push(r.splice(a-1,1)[0]))}}return u},e.prototype.combineSplits=function(t,e,r){var i=t[e],n=[];if(Rn(i)&&i.composition){for(var o=void 0,s=0;s<r.length;s++){if(r[s].items.includes(i)){o=s;break}}var a=void 0,u=void 0;if(0===o?(a=r[o],u=r[o+1]):(a=r[o-1],u=r[o]),a&&u){var l=t.indexOf(a.items[0]),c=t.indexOf(u.items[u.items.length-1]);if(Number.isInteger(l)&&Number.isInteger(c)){var h=this.getMeshSplits(t,l,c);1===h.length&&(h[0].spriteMesh=r[o].spriteMesh,0===o?(r[0]=h[0],n.push(r.splice(1,1)[0])):(n.push(r.splice(o-1,1)[0]),r[o-1]=h[0]))}}}return n},e.prototype.getMeshSplits=function(e,r,i,n){void 0===r&&(r=0),void 0===i&&(i=e.length-1);for(var o=null,s=[],a=r;a<=i;a++){var u=e[a];if(n||u.started&&!(u.lifetime<0))if(Rn(u)){var l=u.createContent().renderInfo.cacheId,c=u.content.renderer.texture,h=!0;if(o){var f=o.textures.includes(c)?0:1;o.cacheId===l&&Qe.isSprite(u)&&o.items.length<t.maxSpriteMeshItemCount&&f+o.textures.length<=t.maxSpriteTextureCount?(U(o.items,u,_n),z(o.textures,c),h=!1):s.push(o)}h&&(o={indexStart:u.listIndex,cacheId:l,renderInfo:u.content.renderInfo,items:[u],textures:[c]})}else{if(n&&!u.contentVisible)continue;o&&(s.push(o),o=null)}}return o&&s.push(o),s.forEach((function(t){t.indexEnd=t.items[t.items.length-1].listIndex,t.dirty=!0})),s},e}();function Rn(t){return Qe.isSprite(t)||Qe.isFilterSprite(t)}var On={blending:0,cacheId:"-",mask:0,maskMode:0,occlusion:!1,side:0,cachePrefix:"-"},wn=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="sprite",t}return r(i,e),i.precompile=function(e,r,i){var n,o=r.getShaderLibrary(),s=r.engine.gpuCapability,a=s.level,u=s.detail,l=(null!=i?i:{}).env;if(!o.shaderResults[bn(On,2)]){o.addShader(An(On,2,a,l)),o.addShader(An(On,t.maxSpriteMeshItemCount,a,l));var c=!1;null===(n=e[0])||void 0===n||n.items.forEach((function(e){t.Item.isFilter(e)&&e.content.filter&&(c=!0,V(e.content.filter).forEach((function(t){if(!t.isParticle){var e=Sn(a,t,t);t.shaderCacheId&&(e.cacheId="".concat(t.shaderCacheId,"_effects_filter")),o.addShader(e)}})))})),c&&o.addShader(ri(a,!1)),u.writableFragDepth&&o.addShader(ri(a,!0))}return Promise.resolve()},i.prototype.onCompositionDestroyed=function(t){t.loaderData.spriteGroup.dispose(),delete t.loaderData.spriteGroup},i.prototype.onCompositionReset=function(t,e){if(!t.loaderData.spriteGroup){var r=new Cn(t);t.loaderData.spriteGroup=r,r.resetMeshSplits()}},i.prototype.onCompositionItemLifeBegin=function(t,e){var r=t.loaderData.spriteGroup;e.type!==w.composition&&r.addItem(e)},i.prototype.onCompositionItemRemoved=function(t,e){t.loaderData.spriteGroup.removeItem(e)},i.prototype.onCompositionUpdate=function(t,e){t.loaderData.spriteGroup.onUpdate(e)},i.prototype.prepareRenderFrame=function(t,e){var r,i,n,o=t.loaderData.spriteGroup.diffMeshSplits();return!!o&&(null===(r=o.remove)||void 0===r||r.forEach((function(t){return e.removeMeshFromDefaultRenderPass(t)})),null===(i=o.add)||void 0===i||i.forEach((function(t){return e.addMeshToDefaultRenderPass(t)})),null===(n=o.modify)||void 0===n||n.forEach((function(t){e.removeMeshFromDefaultRenderPass(t),e.addMeshToDefaultRenderPass(t)})),!!(this.layerInfo=o.layer))},i.prototype.postProcessFrame=function(t,e){var r,i;null===(i=null===(r=this.layerInfo)||void 0===r?void 0:r.layerToAdd)||void 0===i||i.forEach((function(t){var r=t.items[0].filter;if(void 0!==r){var i=r.passSplitOptions,n=e.splitDefaultRenderPassByMesh(t.mesh,i);r.renderPassDelegate&&(n.delegate=r.renderPassDelegate),r.onRenderPassCreated&&r.onRenderPassCreated(n,e)}})),this.layerInfo=void 0},i}(sr),Mn=new Dt,Ln=new Mt(1,1,1);new Mt;var In=function(){function t(t,e){var r;this.vfxItem=e,this.active=!1,this.transform=e.transform;var i=this.transform.scale;this.basicTransform={position:this.transform.position.clone(),rotation:this.transform.getRotation(),scale:new Mt(i.x,i.y,i.x)};var n=t.rotationOverLifetime,o=t.sizeOverLifetime,s=t.positionOverLifetime,a=void 0===s?{}:s;if(a){a.path&&(this.basicTransform.path=be(a.path));var u=a.linearX||a.linearY||a.linearZ;u&&(this.linearVelOverLifetime={x:a.linearX&&be(a.linearX),y:a.linearY&&be(a.linearY),z:a.linearZ&&be(a.linearZ),asMovement:a.asMovement,enabled:!!u});var l=a.orbitalX||a.orbitalY||a.orbitalZ;l&&(this.orbitalVelOverLifetime={x:a.orbitalX&&be(a.orbitalX),y:a.orbitalY&&be(a.orbitalY),z:a.orbitalZ&&be(a.orbitalZ),center:$t(a.orbCenter),asRotation:a.asRotation,enabled:!!l}),this.speedOverLifetime=a.speedOverLifetime&&be(a.speedOverLifetime)}if(o&&(o.separateAxes?(this.sizeSeparateAxes=!0,this.sizeXOverLifetime=be(o.x||1),this.sizeYOverLifetime=be(o.y||1),this.sizeZOverLifetime=be(o.z||1)):this.sizeXOverLifetime=be(o.size||1)),n&&(this.rotationOverLifetime={asRotation:n.asRotation,separateAxes:n.separateAxes,z:be(n.z||0)},n.separateAxes)){var c=this.rotationOverLifetime;c.x=be(n.x||0),c.y=be(n.y||0)}this.options={reusable:!!e.reusable,delay:e.delay||0,startSpeed:a.startSpeed||0,startSize:i&&i.x||1,sizeAspect:i&&i.x/(i.y||1)||1,duration:e.duration||0,looping:e.endBehavior&&e.endBehavior===at.loop,endBehavior:e.endBehavior||0,gravity:Mt.fromArray(a.gravity||[]),gravityModifier:be(null!==(r=a.gravityOverLifetime)&&void 0!==r?r:0),direction:a.direction?Mt.fromArray(a.direction).normalize():new Mt},this.id=e.id,this.time=0,this.name=e.name,this.visible=e.getVisible()}return Object.defineProperty(t.prototype,"ended",{get:function(){return this.time>this.options.duration&&!this.options.looping&&!this.options.reusable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startSize",{get:function(){return this.basicTransform.scale},set:function(t){this.basicTransform.scale=t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"velocity",{get:function(){return this._velocity||(this._velocity=this.options.direction.clone(),this._velocity.multiply(this.options.startSpeed)),this._velocity},enumerable:!1,configurable:!0}),t.prototype.getWillTranslate=function(){return!!(this.linearVelOverLifetime&&this.linearVelOverLifetime.enabled||this.orbitalVelOverLifetime&&this.orbitalVelOverLifetime.enabled||this.options.gravityModifier&&!this.options.gravity.isZero()||this.options.startSpeed&&!this.options.direction.isZero())},t.prototype.updateTime=function(t){var e=t-this.options.delay,r=this.options.duration;if(e>=r&&this.options.looping){for(var i=e-r;i>r;)i-=r;this.time=i}else{var n=4===this.options.endBehavior;this.time=n?Math.min(r,e):e}},t.prototype.getRenderData=function(t,e){var r=this.options,i=Ln.setFromNumber(1),n=Mn.set(0,0,0),o=!1,s=!1,a=t<0?t:Math.max(t,0),u=r.duration,l=a/u,c={life:l,transform:this.transform};l=l<0?0:l>1?1:l,this.sizeXOverLifetime&&(i.x=this.sizeXOverLifetime.getValue(l),this.sizeSeparateAxes?(i.y=this.sizeYOverLifetime.getValue(l),i.z=this.sizeZOverLifetime.getValue(l)):i.z=i.y=i.x,o=!0),this.calculateScaling(o,i,e);var h,f=this.rotationOverLifetime;if(f){var p=function(t){return f.asRotation?t.getValue(l):t.getIntegrateValue(0,l,u)},d=p(f.z),m=f.separateAxes;n.x=m?p(f.x):0,n.y=m?p(f.y):0,n.z=d,s=!0}if(s||e){var v=Mn.addEulers(this.basicTransform.rotation,n);c.transform.setRotation(v.x,v.y,v.z)}return(this.getWillTranslate()||e)&&Jt(h=new Mt,this,this.options.gravity,a,u,this.basicTransform.position,this.velocity),this.basicTransform.path&&(h||(h=this.basicTransform.position.clone()),h.add(this.basicTransform.path.getValue(l))),h&&this.transform.setPosition(h.x,h.y,h.z),c.active=this.active,c},t.prototype.calculateScaling=function(t,e,r){this.transform.setScale(e.x*this.startSize.x,e.y*this.startSize.y,e.z*this.startSize.z)},t}(),Pn=[[0,0,1,1,void 0]],Fn=[1,1,1,1],Nn=function(t){function e(e,r,n){var o,s,a,u,l,c,h,f,p=t.call(this,e,n)||this;p.startColor=[1,1,1,1];var d=e.interaction,m=e.renderer,v=e.options,y=e.listIndex,g=void 0===y?0:y,x=r.emptyTexture,T=n.transform.scale;p.options=i(i({},p.options),{startColor:v.startColor||[1,1,1,1]}),p.interaction=d,p.renderer={renderMode:null!==(o=m.renderMode)&&void 0!==o?o:M.BILLBOARD,blending:null!==(s=m.blending)&&void 0!==s?s:S.ALPHA,texture:p.initTexture(m.texture,x),occlusion:!!m.occlusion,transparentOcclusion:!!m.transparentOcclusion||m.maskMode===A.MASK,side:null!==(a=m.side)&&void 0!==a?a:b.DOUBLE,shape:m.shape,mask:null!==(u=m.mask)&&void 0!==u?u:0,maskMode:null!==(l=m.maskMode)&&void 0!==l?l:A.NONE,order:g};var E=se(m.anchor,m.particleOrigin);m.anchor||void 0===m.particleOrigin||p.basicTransform.position.add([-E[0]*T.x,-E[1]*T.y,0]),p.transform.setAnchor(E[0]*T.x,E[1]*T.y,0);var _=e.colorOverLifetime;return _&&(p.opacityOverLifetime=be(null!==(c=_.opacity)&&void 0!==c?c:1),_.color&&_.color[0]===ot.GRADIENT_COLOR&&(p.colorOverLifetime=H(_.color[1]))),(null===(h=e.filter)||void 0===h?void 0:h.feather)&&1!==(null===(f=e.filter)||void 0===f?void 0:f.feather)&&(p.feather=be(e.filter.feather)),p.emptyTexture=x,p.splits=e.splits||Pn,p.listIndex=n.listIndex||0,p.textureSheetAnimation=e.textureSheetAnimation,p.cachePrefix="-",p.parentId=n.parentId,p.reusable=n.reusable,p._renderInfo=En(p),p}return r(e,t),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){this._filter=t,this._renderInfo.filter=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderInfo",{get:function(){return this._renderInfo},enumerable:!1,configurable:!0}),e.prototype.initTexture=function(t,e){return null!=t?t:e},e.prototype.getTextures=function(){var t=[],e=this.renderer.texture;return e&&t.push(e),t},e.prototype.setColor=function(t,e,r,i){this.customColor=[t,e,r,i]},e.prototype.setOpacity=function(t){this.customOpacity=t},e.prototype.getCustomOpacity=function(){return this.customOpacity},e.prototype.getRenderData=function(e,r){var i,n=t.prototype.getRenderData.call(this,e,r),o=te(Fn,1),s=e<0?e:Math.max(e,0),a=this.options.duration,u=s/a<0?0:s/a>1?1:s/a;if(this.customColor)n.color=this.customColor;else{var l=this.opacityOverLifetime,c=this.colorOverLifetime;c&&(o=X(c,u,!0),i=!0),l&&(o[3]*=l.getValue(u),i=!0),(i||r)&&(n.color=ie(this.startColor,o,this.options.startColor))}var h=this.textureSheetAnimation;if(h){var f=h.total||h.row*h.col,p=0,d=0,m=1,v=1,y=void 0;if(this.splits){var g=this.splits[0];y=g[4],p=g[0],d=g[1],y?(m=g[3],v=g[2]):(m=g[2],v=g[3])}var x=void 0,T=void 0;y?(x=1/h.row*m,T=1/h.col*v):(x=1/h.col*m,T=1/h.row*v);var E=void 0;if(h.animate){var S=Math.round(u*(f-1)),b=Math.floor(S/h.col),A=S-b*h.col;E=y?[x*b,T*(h.col-A)]:[x*A,T*(1+b)]}else E=[0,T];n.texOffset=[p+E[0],v+d-E[1],x,T]}else r&&(n.texOffset=[0,0,1,1]);return n.visible=this.vfxItem.contentVisible,n.startSize=this.startSize,n},e.prototype.calculateScaling=function(t,e,r){(t||r)&&this.transform.setScale(e.x,e.y,e.z)},e}(In),Vn=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.sprite},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){this.sprite=t.content},n.prototype.onLifetimeBegin=function(t,e){e.active=!0},n.prototype.onItemRemoved=function(t,e){e&&(delete e.mesh,t.destroyTextures(e.getTextures()))},n.prototype.onItemUpdate=function(t,e){var r;null===(r=this.content)||void 0===r||r.updateTime(this.time)},n.prototype.getCurrentPosition=function(){var t=new Mt;return this.transform.assignWorldTRS(t),t},n.prototype.setColor=function(t,e,r,i){this.content.setColor(t,e,r,i)},n.prototype.setOpacity=function(t){this.content.setOpacity(t)},n.prototype.getBoundingBox=function(){var e=this.content;if(e&&this.transform){var r=this.transform.getWorldMatrix(),i=e.startSize,n=le(Mt.ZERO,i.x/2,i.y/2);return n.forEach((function(t){r.transformPoint(t.p0),r.transformPoint(t.p1),r.transformPoint(t.p2)})),{type:t.HitTestType.triangle,area:n}}},n.prototype.getHitTestParams=function(t){var e,r,i=this.content,n=null===(e=this.composition)||void 0===e?void 0:e.loaderData.spriteGroup,o=i&&i.interaction;if((t||o)&&n&&i){var s=this.getBoundingBox();if(s)return{behavior:(null===(r=i.interaction)||void 0===r?void 0:r.behavior)||0,type:s.type,triangles:s.area,backfaceCulling:i.renderer.side===b.FRONT}}},n.prototype.getRenderData=function(){return this.content.getRenderData(this.content.time)},n.prototype.doCreateContent=function(t){var e=t.getRendererOptions().emptyTexture;return new Nn(this.sprite,{emptyTexture:e},this)},n.prototype.createWireframeMesh=function(t,e){var r=new xn(this.composition.getEngine(),i({wireframe:!0},t.renderInfo),this.composition);return r.setItems([t]),r.mesh.material.setVector3("uFrameColor",Mt.fromArray(e)),r.mesh.priority=999,r},n}(Qe),Dn=1,zn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return w.filter},enumerable:!1,configurable:!0}),e.prototype.onConstructed=function(e){t.prototype.onConstructed.call(this,e),this.filterOptions=e.content.filter,this.cachePrefix="filter:"+Dn++,this.sprite.renderer.texture=this.composition.renderFrame.transparentTexture},e.prototype.onItemUpdate=function(e,r){var i,n,o,a,u;t.prototype.onItemUpdate.call(this,e,r);var l=null===(o=this._content)||void 0===o?void 0:o.mesh;if(l){var c=this.filter.mesh.variables;if(c){var h=l.mesh.material;try{for(var f=s(Object.keys(c)),p=f.next();!p.done;p=f.next()){var d=p.value,m=c[d](r);m.length>4?h.setMatrix(d,Ft.fromArray(m)):h.setVector4(d,zt.fromArray(m))}}catch(t){i={error:t}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(i)throw i.error}}}}null===(u=(a=this.filter).onItemUpdate)||void 0===u||u.call(a,e,this)},e.prototype.onItemRemoved=function(e,r){var i,n;null===(n=(i=this.filter).onItemRemoved)||void 0===n||n.call(i,this),t.prototype.onItemRemoved.call(this,e,r)},e.prototype.doCreateContent=function(e){var r,i=t.prototype.doCreateContent.call(this,e),n=D(this.filterOptions,e);this.filter=n,i.renderInfo.filter=n,i.filter=n,i.renderInfo.cacheId=i.renderInfo.cacheId.replace("$F$",null!==(r=n.mesh.shaderCacheId)&&void 0!==r?r:"");var o=n.mesh.variables;return n.mesh.uniformValues||(n.mesh.uniformValues={}),o&&Object.keys(o).forEach((function(t){var e=o[t];n.mesh.uniformValues[t]=e(0)})),i},e}(Vn),Bn=function(){function e(e,r){var i,n,o,s;this.particleCount=0;var a,u,l=r.composition.getEngine(),f=(null!==(i=l.renderer)&&void 0!==i?i:{}).env,p=e.speedOverLifetime,d=e.colorOverLifetime,m=e.linearVelOverLifetime,v=e.orbitalVelOverLifetime,y=e.sizeOverLifetime,g=e.rotationOverLifetime,x=e.sprite,T=e.gravityModifier,E=e.maxCount,S=e.duration,b=e.textureFlip,A=e.useSprite,_=e.name,C=e.filter,R=e.gravity,O=e.forceTarget,w=e.side,M=e.occlusion,L=e.anchor,I=e.blending,P=e.maskMode,F=e.mask,N=e.transparentOcclusion,V=e.listIndex,z=e.meshSlots,B=e.renderMode,U=void 0===B?0:B,k=e.diffuse,G=void 0===k?Vr.createWithData(l):k,X=l.gpuCapability.detail,H=X.halfFloatTexture,Y=X.maxVertexUniforms,j=[["RENDER_MODE",+U],["PRE_MULTIPLY_ALPHA",!1],["ENV_EDITOR",f===c]],W=l.gpuCapability.level,Z={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},q={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},K=Y>0,J={},$=0,tt=0;if(this.useSprite=A,K&&j.push(["ENABLE_VERTEX_TEXTURE",!0]),p&&(j.push(["SPEED_OVER_LIFETIME",!0]),tt|=2,J.uSpeedLifetimeValue=p.toUniform(Z)),(null==x?void 0:x.animate)&&(j.push(["USE_SPRITE",!0]),tt|=4,J.uFSprite=J.uSprite=new Float32Array([x.col,x.row,x.total,x.blend?1:0]),this.useSprite=!0),C&&C.name!==h){j.push(["USE_FILTER",!0]),tt|=8;var et=D(C,r.composition);if(!et.particle)throw new Error("particle filter ".concat(C.name," not implement"));a=et.particle,Object.keys(null!==(n=a.uniforms)&&void 0!==n?n:{}).forEach((function(t){var e,r=null===(e=a.uniforms)||void 0===e?void 0:e[t];if(J[t])throw new Error("conflict uniform name:"+t);J[t]=null==r?void 0:r.toUniform(Z)})),Object.keys(null!==(o=a.uniformValues)&&void 0!==o?o:{}).forEach((function(t){var e,r=null===(e=a.uniformValues)||void 0===e?void 0:e[t];if(J[t])throw new Error("conflict uniform name:"+t);J[t]=r}))}(null==d?void 0:d.color)&&(j.push(["COLOR_OVER_LIFETIME",!0]),tt|=16,J.uColorOverLifetime=d.color instanceof Vr?d.color:Vr.createWithData(l,Q(d.color))),(null==d?void 0:d.opacity)?J.uOpacityOverLifetimeValue=d.opacity.toUniform(Z):J.uOpacityOverLifetimeValue=be(1).toUniform(Z),["x","y","z"].forEach((function(t,e){var r=0,i=0;(null==m?void 0:m[t])&&(J["uLinear".concat(t.toUpperCase(),"ByLifetimeValue")]=m[t].toUniform(Z),r=1,tt|=1<<7+e,m.enabled=!0),j.push(["LINEAR_VEL_".concat(t.toUpperCase()),r]),(null==v?void 0:v[t])&&(J["uOrb".concat(t.toUpperCase(),"ByLifetimeValue")]=v[t].toUniform(Z),i=1,tt|=1<<10+e,u=!0,v.enabled=!0),j.push(["ORB_VEL_".concat(t.toUpperCase()),i])})),(null==m?void 0:m.asMovement)&&(j.push(["AS_LINEAR_MOVEMENT",!0]),tt|=32),u&&((null==v?void 0:v.asRotation)&&(j.push(["AS_ORBITAL_MOVEMENT",!0]),tt|=64),J.uOrbCenter=new Float32Array((null==v?void 0:v.center)||[0,0,0])),J.uSizeByLifetimeValue=null==y?void 0:y.x.toUniform(Z),(null==y?void 0:y.separateAxes)&&(j.push(["SIZE_Y_BY_LIFE",1]),tt|=16384,J.uSizeYByLifetimeValue=null===(s=null==y?void 0:y.y)||void 0===s?void 0:s.toUniform(Z)),(null==g?void 0:g.z)&&(J.uRZByLifeTimeValue=g.z.toUniform(Z),tt|=32768,j.push(["ROT_Z_LIFETIME",1])),(null==g?void 0:g.x)&&(J.uRXByLifeTimeValue=g.x.toUniform(Z),tt|=65536,j.push(["ROT_X_LIFETIME",1])),(null==g?void 0:g.y)&&(J.uRYByLifeTimeValue=g.y.toUniform(Z),tt|=1<<17,j.push(["ROT_Y_LIFETIME",1])),(null==g?void 0:g.asRotation)&&(j.push(["ROT_LIFETIME_AS_MOVEMENT",1]),tt|=1<<18),J.uGravityModifierValue=T.toUniform(Z),O&&(j.push(["FINAL_TARGET",!0]),tt|=1<<19,J.uFinalTarget=new Float32Array(O.target||[0,0,0]),J.uForceCurve=O.curve.toUniform(Z)),H&&q.max?(tt|=1<<20,J.uFCurveValueTexture=Dr(l,ge.getAllData(q,!0),q.index,1)):J.uFCurveValues=ge.getAllData(q);var rt=Z.max+Z.curves.length-32>Y;if(2===W&&(Z.max=-1,Z.index=z?z[0]:kn(Z.index),q.index>0&&(q.max=-1,q.index=z?z[1]:kn(q.index))),rt&&H&&K){var it=Dr(l,ge.getAllData(Z,!0),Z.index,1);J.uVCurveValueTexture=it,$=1}else J.uVCurveValues=ge.getAllData(Z);var nt=["-p:",U,tt,Z.index,Z.max,q.index,q.max].join("+");j.push(["VERT_CURVE_VALUE_COUNT",Z.index],["FRAG_CURVE_VALUE_COUNT",q.index],["VERT_MAX_KEY_FRAME_COUNT",Z.max],["FRAG_MAX_KEY_FRAME_COUNT",q.max]);var ot=C?Ri.replace(/#pragma\s+FILTER_FRAG/,a.fragment):Ri,st="#define LOOKUP_TEXTURE_CURVE ".concat($,"\n").concat(Oi),at=C?st.replace(/#pragma\s+FILTER_VERT/,a.vertex||"void filterMain(float t){}\n"):st,ut={fragment:br(j,ot,t.ShaderType.fragment,W),vertex:br(j,at,t.ShaderType.vertex,W),glslVersion:1===W?t.GLSLVersion.GLSL1:t.GLSLVersion.GLSL3,shared:!0,cacheId:nt,marcos:j,name:"particle#".concat(_)};C&&(ut.cacheId+=C.name);var lt={shader:ut,uniformSemantics:{effects_MatrixV:"VIEW",effects_MatrixVP:"VIEWPROJECTION",uEditorTransform:"EDITOR_TRANSFORM",effects_ObjectToWorld:"MODEL"}},ct=xr(I);J.uTexOffset=new Float32Array(G?[1/G.getWidth(),1/G.getHeight()]:[0,0]),J.uMaskTex=G,J.uColorParams=new Float32Array([G?1:0,+ct,0,+(!!M&&!N)]),J.uParams=[0,S,0,0],J.uAcceleration=[(null==R?void 0:R[0])||0,(null==R?void 0:R[1])||0,(null==R?void 0:R[2])||0,0];var ht=qr.create(l,lt);ht.blending=!0,ht.depthTest=!0,ht.depthMask=!!M,ht.stencilRef=F?[F,F]:void 0,Cr(ht,P),Ar(ht,I),_r(ht,w);var ft={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"};Object.keys(J).map((function(t){var e=J[t];if(e instanceof Vr)ht.setTexture(t,e);else{var r=[];switch(ft[t]){case"vec4":ht.setVector4(t,zt.fromArray(e));break;case"vec3":ht.setVector3(t,Mt.fromArray(e));break;case"vec2":ht.setVector2(t,wt.fromArray(e));break;case"vec4Array":for(var i=0;i<e.length;i+=4){var n=new zt(e[i],e[i+1],e[i+2],e[i+3]);r.push(n)}ht.setVector4Array(t,r),r.length=0;break;default:console.warn("uniform ".concat(t,"'s type not in typeMap"))}}})),ht.setVector3("emissionColor",new Mt(0,0,0)),ht.setFloat("emissionIntensity",0);var pt=li.create(l,function(t,e,r){var i=Float32Array.BYTES_PER_ELEMENT,n=12*i,o={aPos:{size:3,offset:0,stride:n,data:new Float32Array(0)},aVel:{size:3,offset:3*i,stride:n,dataSource:"aPos"},aDirX:{size:3,offset:6*i,stride:n,dataSource:"aPos"},aDirY:{size:3,offset:9*i,stride:n,dataSource:"aPos"},aRot:{size:3,offset:0,stride:8*i,data:new Float32Array(0)},aSeed:{size:1,offset:3*i,stride:8*i,dataSource:"aRot"},aColor:{size:4,offset:4*i,stride:8*i,dataSource:"aRot"},aOffset:{size:4,stride:4*i,data:new Float32Array(0)}};e&&(o.aSprite={size:3,data:new Float32Array(0)});return{attributes:o,indices:{data:new Uint16Array(0)},name:r,maxVertex:t}}(4*E,this.useSprite,"particle#".concat(_))),dt=gi.create(l,{name:"MParticle_".concat(_),priority:V,material:ht,geometry:pt});this.anchor=L,this.mesh=dt,this.geometry=dt.firstGeometry(),this.forceTarget=O,this.sizeOverLifetime=y,this.speedOverLifetime=p,this.linearVelOverLifetime=m,this.orbitalVelOverLifetime=v,this.orbitalVelOverLifetime=v,this.gravityModifier=T,this.maxCount=E,this.duration=S,this.textureOffsets=b?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0]}return Object.defineProperty(e.prototype,"time",{get:function(){return this.mesh.material.getVector4("uParams").x},set:function(t){this.mesh.material.setVector4("uParams",new zt(+t,this.duration,0,0))},enumerable:!1,configurable:!0}),e.prototype.getPointColor=function(t){var e=this.geometry.getAttributeData("aRot"),r=32*t+4;return[e[r],e[r+1],e[r+2],e[r+3]]},e.prototype.getPointPosition=function(t){var e=this.geometry,r=48*t,i=e.getAttributeData("aPos"),n=e.getAttributeData("aOffset"),o=this.time-n[16*t+2],s=n[16*t+3],a=this.mesh.material,u=a.getVector4("uAcceleration").toVector3(),l=Mt.fromArray(i,r),c=Mt.fromArray(i,r+3),h=Jt(new Mt,this,u,o,s,l,c);if(this.forceTarget){var f=a.getVector3("uFinalTarget"),p=this.forceTarget.curve.getValue(o/s),d=1-p;h.x=h.x*d+f.x*p,h.y=h.y*d+f.y*p,h.z=h.z*d+f.z*p}return h},e.prototype.clearPoints=function(){this.resetGeometryData(this.geometry),this.particleCount=0,this.geometry.setDrawCount(0),this.maxParticleBufferCount=0},e.prototype.resetGeometryData=function(t){for(var e=t.getAttributeNames(),r=t.getIndexData(),i=0;i<e.length;i++){var n=e[i],o=t.getAttributeData(n);o&&t.setAttributeData(n,new o.constructor(0))}t.setIndexData(new r.constructor(0))},e.prototype.minusTime=function(t){for(var e=this.geometry.getAttributeData("aOffset"),r=0;r<e.length;r+=4)e[r+2]-=t;this.geometry.setAttributeData("aOffset",e),this.time-=t},e.prototype.removePoint=function(t){t<this.particleCount&&this.geometry.setAttributeSubData("aOffset",16*t,new Float32Array(16))},e.prototype.setPoint=function(t,e){var r=this.maxCount;if(e<r){var i=e+1,n=4*i,o=this.geometry,s=i>this.maxParticleBufferCount,a=1;this.particleCount>300?a=(this.particleCount+100)/this.particleCount:this.particleCount>100?a=1.4:this.particleCount>0&&(a=2);var u={aPos:new Float32Array(48),aRot:new Float32Array(32),aOffset:new Float32Array(16)},l=this.useSprite;l&&(u.aSprite=new Float32Array(12));var c=new Mt,h=new Lt,f=new Mt(1,1,1);t.transform.assignWorldTRS(c,h,f);var p=Ke.getRotation(h,new Dt),d=c.toArray(),m=p.toArray(),v=this.textureOffsets,y=[0,0,t.delay,t.lifetime],g=[0,0,1,1],x=t.vel,T=t.color,E=[-.5,.5,-.5,-.5,.5,.5,.5,-.5],S=Math.random(),b=void 0;l&&(b=t.sprite);for(var A=0;A<4;A++){var _=2*A,C=3*A,R=4*A,O=12*A,w=8*A;u.aPos.set(d,O),x.fill(u.aPos,O+3),u.aRot.set(m,w),u.aRot[w+3]=S,u.aRot.set(T,w+4),l&&u.aSprite.set(b,C);var M=t.uv||g;if(M){var L=l?1-v[_+1]:v[_+1];y[0]=M[0]+v[_]*M[2],y[1]=M[1]+L*M[3]}u.aOffset.set(y,R);for(var I=A+A,P=(E[I]-this.anchor.x)*f.x,F=(E[I+1]-this.anchor.y)*f.y,N=0;N<3;N++)u.aPos[O+6+N]=t.dirX.getElement(N)*P,u.aPos[O+9+N]=t.dirY.getElement(N)*F}var V=new Uint16Array([0,1,2,2,1,3].map((function(t){return t+4*e})));if(s){var D=k(o.getIndexData(),6*i,a,6*r);D.set(V,6*e),o.setIndexData(D),this.maxParticleBufferCount=D.length/6}else o.setIndexSubData(6*e,V);Object.keys(u).forEach((function(t){var i=u[t],l=o.getAttributeStride(t)/Float32Array.BYTES_PER_ELEMENT;if(s){var c=k(o.getAttributeData(t),n*l,a,4*r*l);c.set(i,i.length*e),o.setAttributeData(t,c)}else o.setAttributeSubData(t,i.length*e,i)})),this.particleCount=Math.max(i,this.particleCount),o.setDrawCount(6*this.particleCount)}},e}(),Un=[10,32,64,160];function kn(t){for(var e=0;e<Un.length;e++){var r=Un[e];if(r>t)return r}return t||Un[0]}function Gn(t,e,r){var i,n,o,s,a;void 0===e&&(e="");var u=t.content,l=+((null===(i=u.renderer)||void 0===i?void 0:i.renderMode)||0),f=[["RENDER_MODE",l],["PRE_MULTIPLY_ALPHA",!1],["ENV_EDITOR",e===c]],p=r.level,d=r.detail,m={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},v={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},y=d.maxVertexUniforms>0,g=(null!==(n=u.positionOverLifetime)&&void 0!==n?n:{}).speedOverLifetime,x=0,T=0;y&&f.push(["ENABLE_VERTEX_TEXTURE",!0]),g&&(f.push(["SPEED_OVER_LIFETIME",!0]),T|=2,we(m,g));var E=u.textureSheetAnimation;E&&E.animate&&(f.push(["USE_SPRITE",!0]),T|=4);var S=void 0;if(u.filter&&u.filter.name!==h){f.push(["USE_FILTER",!0]),T|=8;var b=V(u.filter).find((function(t){return t.isParticle}));if(!b)throw Error("particle filter ".concat(u.filter.name," not implement"));S=b,null===(o=b.uniforms)||void 0===o||o.forEach((function(t){return we(m,t)}))}var A=u.colorOverLifetime;A&&A.color&&(f.push(["COLOR_OVER_LIFETIME",!0]),T|=16);var _=A&&A.opacity;_&&we(m,_);var C,R=u.positionOverLifetime;["x","y","z"].forEach((function(t,e){var r=0,i="linear"+t.toUpperCase(),n="orbital"+t.toUpperCase();(null==R?void 0:R[i])&&(we(m,R[i]),r=1,T|=1<<7+e),f.push(["LINEAR_VEL_".concat(t.toUpperCase()),r]);var o=0;(null==R?void 0:R[n])&&(we(m,R[n]),o=1,T|=1<<10+e,C=!0),f.push(["ORB_VEL_".concat(t.toUpperCase()),o])})),(null==R?void 0:R.asMovement)&&(f.push(["AS_LINEAR_MOVEMENT",!0]),T|=32),C&&(null==R?void 0:R.asRotation)&&(f.push(["AS_ORBITAL_MOVEMENT",!0]),T|=64);var O=u.sizeOverLifetime;we(m,null==O?void 0:O.x),(null==O?void 0:O.separateAxes)&&(f.push(["SIZE_Y_BY_LIFE",1]),T|=16384,we(m,null==O?void 0:O.y));var w=u.rotationOverLifetime;(null==w?void 0:w.z)&&(we(m,null==w?void 0:w.z),T|=32768,f.push(["ROT_Z_LIFETIME",1])),(null==w?void 0:w.separateAxes)&&(w.x&&(we(m,w.x),T|=65536,f.push(["ROT_X_LIFETIME",1])),w.y&&(we(m,w.y),T|=1<<17,f.push(["ROT_Y_LIFETIME",1]))),(null==w?void 0:w.asRotation)&&(f.push(["ROT_LIFETIME_AS_MOVEMENT",1]),T|=1<<18),we(m,null==R?void 0:R.gravityOverLifetime),(null==R?void 0:R.forceTarget)&&(f.push(["FINAL_TARGET",!0]),T|=1<<19,we(m,R.forceCurve));var M=d.halfFloatTexture;M&&v.max&&(T|=1<<20);var L=d.maxVertexUniforms,I=m.max+m.curves.length-32>L;di(hi)&&(I=!0),2===p&&(m.max=-1,v.index>0&&(v.max=-1)),I&&M&&y&&(x=1);var P=["-p:",l,T,m.index,m.max,v.index,v.max].join("+"),F={fragment:Ri,vertex:"#define LOOKUP_TEXTURE_CURVE ".concat(x,"\n").concat(Oi),shared:!0,cacheId:P,marcos:f,name:"particle#".concat(t.name)};return S&&(F.fragment=F.fragment.replace(/#pragma\s+FILTER_FRAG/,null!==(s=S.fragment)&&void 0!==s?s:""),F.vertex=F.vertex.replace(/#pragma\s+FILTER_VERT/,S.vertex||"void filterMain(float t){}\n"),F.cacheId+="+"+(null===(a=u.filter)||void 0===a?void 0:a.name)),f.push(["VERT_CURVE_VALUE_COUNT",m.index],["FRAG_CURVE_VALUE_COUNT",v.index],["VERT_MAX_KEY_FRAME_COUNT",m.max],["FRAG_MAX_KEY_FRAME_COUNT",v.max]),{shader:F,vertex:m.index,fragment:v.index}}function Xn(t,e,r){var i,n=null===(i=t.cacheId)||void 0===i?void 0:i.split("+");if(n[3]=e,n[5]=r,t.cacheId=n.join("+"),t.marcos)for(var o=0;o<t.marcos.length;o++){var s=t.marcos[o];if("VERT_CURVE_VALUE_COUNT"===s[0])s[1]=e;else if("FRAG_CURVE_VALUE_COUNT"===s[0]){s[1]=r;break}}}var Hn=function(t){this.content=t},Yn=function(){function t(t){this.sort=t,this.length=0}return t.prototype.findNodeByContent=function(t){var e=this.first;if(e)do{if(t(e.content))return e}while(e=e.next)},t.prototype.insertNode=function(t,e){var r=t.next;t.next=e,e.pre=t,e.next=r,r&&(r.pre=e)},t.prototype.shiftNode=function(t){var e=new Hn(t);if(this.length++,1===this.length)return this.first=this.last=e;for(var r=this.first;r;){if(!(this.sort(r.content,e.content)<=0))return r.pre?this.insertNode(r.pre,e):(this.first=e,e.next=r,r.pre=e),e;if(!r.next)return this.insertNode(r,e),this.last=e;r=r.next}},t.prototype.pushNode=function(t){var e=new Hn(t);if(this.length++,1===this.length)return this.last=this.first=e;for(var r=this.last;r;){if(!(this.sort(e.content,r.content)<=0))return this.insertNode(r,e),r===this.last&&(this.last=e),e;if(this.first===r)return r.pre=e,e.next=r,this.first=e;r=r.pre}},t.prototype.removeNode=function(t){var e=this.first;if(this.length--,e===t)(r=this.first=e.next)&&(r.pre=null);else if((e=this.last)===t){var r;(r=this.last=e.pre)&&(r.next=null)}else if(t){var i=t.pre,n=t.next;i.next=n,n&&(n.pre=i)}t.pre=null,t.next=null},t.prototype.forEach=function(t,e){var r=this.first,i=0;if(r)do{t.call(e||this,r.content,i++)}while(r=r.next)},t.prototype.forEachReverse=function(t,e){var r=this.last,i=this.length-1;if(r)do{t.call(e||this,r.content,i--)}while(r=r.pre)},t}(),jn=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.generate=function(t){var e=Wn(this.arc,this.arcMode,t)*St,r=Math.cos(e)*this.radius,i=Math.sin(e)*this.radius,n=new Mt(r,i,0),o=Math.tan(this.angle*St),s=n.clone().multiply(o);return s.z+=1,{position:n.multiply(Ye(0,1)),direction:s.normalize()}},t}();function Wn(t,e,r){if(e===ct.RANDOM)t=Ye(0,t);else if(e===ct.UNIDIRECTIONAL_CYCLE){var i=r.index%(r.total+1);t=t/r.total*i}else if(e===ct.BIDIRECTIONAL_CYCLE){var n=(i=r.index/(r.total+1))-Math.floor(i);t*=Math.floor(i)%2?1-n:n}else e===ct.UNIFORM_BURST&&(t=t*r.burstIndex/r.burstCount);return t}var Zn,qn=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.generate=function(t){var e=Wn(this.arc,this.arcMode,t)*St,r=new Mt(Math.cos(e),Math.sin(e),0),i=this.radius;return{direction:r,position:r.clone().multiply(i)}},t}(),Kn=function(){function t(t){this._d=(t.width||1)/2,this._h=(t.height||1)/2}return t.prototype.generate=function(t){var e=Ye(-this._d,this._d),r=Ye(-this._h,this._h);return{direction:new Mt(0,0,1),position:new Mt(e,r,0)}},t}(),Qn=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=Wn(this.arc,this.arcMode,t)*St,r=new Mt(Math.cos(e),Math.sin(e),0),i=this._d,n=this._h,o=Math.atan2(n,i),s=Math.tan(e),a=new Mt;return e<o?a.set(i,i*s,0):e>=o&&e<Math.PI-o?a.set(n/s,n,0):e<Math.PI+o?a.set(-i,-i*s,0):e<2*Math.PI-o?a.set(-n/s,-n,0):a.set(i,i*s,0),{direction:r,position:a}},t}(),Jn=function(){function t(t){this._d=t.width||1,this.arcMode=t.arcMode}return t.prototype.generate=function(t){var e=this.arcMode===ct.UNIFORM_BURST?t.burstIndex%t.burstCount/(t.burstCount-1):Ye(0,1);return{direction:new Mt(0,1,0),position:new Mt(this._d*(e-.5),0,0)}},t}(),$n=new Ft,to=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.generate=function(t){var e=this.donutRadius,r=this.radius-e,i=Ye(0,2*Math.PI),n=Wn(this.arc,this.arcMode,t)*St,o=$n.setFromRotationZ(n),s=new Mt(Math.cos(i),Math.sin(i),0),a=new Mt(r+Math.cos(i)*e,0,Math.sin(i)*e);return{direction:o.transformNormal(s),position:o.transformPoint(a)}},t}(),eo=new Ft,ro=function(){function t(t){var e=this;Object.keys(t).forEach((function(r){e[r]=t[r]}))}return t.prototype.getHorizontalAngle=function(){return Ye(-90,90)},t.prototype.generate=function(t){var e=Wn(this.arc,this.arcMode,t)*St,r=this.getHorizontalAngle()*St,i=this.radius,n=new Mt(Math.cos(r),0,Math.sin(r)),o=eo.setFromRotationZ(e).transformNormal(n);return{position:o.clone().multiply(i),direction:o}},t}(),io=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getHorizontalAngle=function(){return Ye(0,90)},e}(ro),no=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=Rt(t.random||0,0,1)}return t.prototype.generate=function(t){var e=this.anchors,r=e.length/2-1,i=Math.floor(Wn(r,this.arcMode,t)),n=(e[2*i]+this.block[0]*this.random*Math.random())%1-.5,o=(e[2*i+1]+this.block[1]*this.random*Math.random())%1-.5,s=new Mt(n,o,0);return{position:new Mt(n*this.width,o*this.height,0),direction:s.normalize()}},t}(),oo=function(){function t(){}return t.prototype.generate=function(){return{position:new Mt,direction:new Mt}},t}(),so=((Zn={})[_.NONE]=oo,Zn[_.CONE]=jn,Zn[_.SPHERE]=ro,Zn[_.HEMISPHERE]=io,Zn[_.CIRCLE]=qn,Zn[_.DONUT]=to,Zn[_.RECTANGLE]=Kn,Zn[_.EDGE]=Jn,Zn[_.RECTANGLE_EDGE]=Qn,Zn[_.TEXTURE]=no,Zn);function ao(t){if(!t)return new oo;var e=i({radius:1,arc:360,angle:0,arcMode:ct.RANDOM},t),r=t.type,n=so[r];if(!n)throw Error("invalid shape:"+r);var o=new n(e);if(r!==_.NONE){var s=t,a=s.alignSpeedDirection,u=s.upDirection,l=void 0===u?[0,0,1]:u;o.alignSpeedDirection=a,o.upDirection=Mt.fromArray(l).normalize()}return o}function uo(t,e,r,i,n){var o,s;if(n===function(t,e,r,i){for(var n=0,o=e,s=r-i;o<r;o+=i)n+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return n}(t,e,r,i)>0)for(o=e;o<r;o+=i)s=Ro(o,t[o],t[o+1],s);else for(o=r-i;o>=e;o-=i)s=Ro(o,t[o],t[o+1],s);return s&&Eo(s,s.next)&&(Oo(s),s=s.next),s}function lo(t,e){if(!t)return t;e||(e=t);var r,i=t;do{if(r=!1,i.steiner||!Eo(i,i.next)&&0!==To(i.prev,i,i.next))i=i.next;else{if(Oo(i),(i=e=i.prev)===i.next)break;r=!0}}while(r||i!==e);return e}function co(t){var e=t.prev,r=t,i=t.next;if(To(e,r,i)>=0)return!1;for(var n=t.next.next;n!==t.prev;){if(go(e.x,e.y,r.x,r.y,i.x,i.y,n.x,n.y)&&To(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function ho(t,e,r,i){var n=t.prev,o=t,s=t.next;if(To(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,u=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,l=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,c=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,h=vo(a,u,e,r,i),f=vo(l,c,e,r,i),p=t.prevZ,d=t.nextZ;p&&p.z>=h&&d&&d.z<=f;){if(p!==t.prev&&p!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&To(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,d!==t.prev&&d!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&To(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,p.x,p.y)&&To(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;d&&d.z<=f;){if(d!==t.prev&&d!==t.next&&go(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&To(d.prev,d,d.next)>=0)return!1;d=d.nextZ}return!0}function fo(t,e){return t.x-e.x}function po(t,e){if(e=function(t,e){var r,i=e,n=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=n&&a>s){if(s=a,a===n){if(o===i.y)return i;if(o===i.next.y)return i.next}r=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!r)return null;if(n===s)return r;var u,l=r,c=r.x,h=r.y,f=1/0;i=r;do{n>=i.x&&i.x>=c&&n!==i.x&&go(o<h?n:s,o,c,h,o<h?s:n,o,i.x,i.y)&&(u=Math.abs(o-i.y)/(n-i.x),_o(i,t)&&(u<f||u===f&&(i.x>r.x||i.x===r.x&&mo(r,i)))&&(r=i,f=u)),i=i.next}while(i!==l);return r}(t,e),e){var r=Co(e,t);lo(e,e.next),lo(r,r.next)}}function mo(t,e){return To(t.prev,t,e.prev)<0&&To(e.next,t,t.next)<0}function vo(t,e,r,i,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*n)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*n)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function yo(t){var e=t,r=t;do{(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next}while(e!==t);return r}function go(t,e,r,i,n,o,s,a){return(n-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(i-a)-(r-s)*(e-a)>=0&&(r-s)*(o-a)-(n-s)*(i-a)>=0}function xo(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&So(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}(t,e)&&(_o(t,e)&&_o(e,t)&&function(t,e){var r=t,i=!1,n=(t.x+e.x)/2,o=(t.y+e.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&n<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==t);return i}(t,e)&&(To(t.prev,t,e.prev)||To(t,e.prev,e))||Eo(t,e)&&To(t.prev,t,t.next)>0&&To(e.prev,e,e.next)>0)}function To(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function Eo(t,e){return t.x===e.x&&t.y===e.y}function So(t,e,r,i){var n=Ao(To(t,e,r)),o=Ao(To(t,e,i)),s=Ao(To(r,i,t)),a=Ao(To(r,i,e));return n!==o&&s!==a||(!(0!==n||!bo(t,r,e))||(!(0!==o||!bo(t,i,e))||(!(0!==s||!bo(r,t,i))||!(0!==a||!bo(r,e,i)))))}function bo(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function Ao(t){return t>0?1:t<0?-1:0}function _o(t,e){return To(t.prev,t,t.next)<0?To(t,e,t.next)>=0&&To(t,t.prev,e)>=0:To(t,e,t.prev)<0||To(t,t.next,e)<0}function Co(t,e){var r=new wo(t.i,t.x,t.y),i=new wo(e.i,e.x,e.y),n=t.next,o=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,i.next=r,r.prev=i,o.next=i,i.prev=o,i}function Ro(t,e,r,i){var n=new wo(t,e,r);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function Oo(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 wo(t,e,r){this.i=t,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}var Mo=0;function Lo(t,e,r,i){r=r||2,Mo=i||0;var n,o,s,a,u,l,c,h=e&&e.length,f=h?e[0]*r:t.length,p=uo(t,0,f,r,!0),d=[];if(!p||p.next===p.prev)return d;if(h&&(p=function(t,e,r,i){var n,o,s,a=[];for(n=0,o=e.length;n<o;n++)(s=uo(t,e[n]*i,n<o-1?e[n+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(yo(s));for(a.sort(fo),n=0;n<a.length;n++)po(a[n],r),r=lo(r,r.next);return r}(t,e,p,r)),t.length>80*r){n=s=t[0],o=a=t[1];for(var m=r;m<f;m+=r)(u=t[m])<n&&(n=u),(l=t[m+1])<o&&(o=l),u>s&&(s=u),l>a&&(a=l);c=0!==(c=Math.max(s-n,a-o))?1/c:0}return Io(p,d,r,n,o,c),d}function Io(t,e,r,i,n,o,s){if(t){!s&&o&&function(t,e,r,i){var n=t;do{null===n.z&&(n.z=vo(n.x,n.y,e,r,i)),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,r,i,n,o,s,a,u,l=1;do{for(r=t,t=null,o=null,s=0;r;){for(s++,i=r,a=0,e=0;e<l&&(a++,i=i.nextZ);e++);for(u=l;a>0||u>0&&i;)0!==a&&(0===u||!i||r.z<=i.z)?(n=r,r=r.nextZ,a--):(n=i,i=i.nextZ,u--),o?o.nextZ=n:t=n,n.prevZ=o,o=n;r=i}o.nextZ=null,l*=2}while(s>1)}(n)}(t,i,n,o);for(var a,u,l=t;t.prev!==t.next;)if(a=t.prev,u=t.next,o?ho(t,i,n,o):co(t))e.push(a.i/r+Mo),e.push(t.i/r+Mo),e.push(u.i/r+Mo),Oo(t),t=u.next,l=u.next;else if((t=u)===l){s?1===s?Io(t=Po(lo(t),e,r),e,r,i,n,o,2):2===s&&Fo(t,e,r,i,n,o):Io(lo(t),e,r,i,n,o,1);break}}}function Po(t,e,r){var i=t;do{var n=i.prev,o=i.next.next;!Eo(n,o)&&So(n,i,i.next,o)&&_o(n,o)&&_o(o,n)&&(e.push(n.i/r+Mo),e.push(i.i/r+Mo),e.push(o.i/r+Mo),Oo(i),Oo(i.next),i=t=o),i=i.next}while(i!==t);return lo(i)}function Fo(t,e,r,i,n,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&xo(s,a)){var u=Co(s,a);return s=lo(s,s.next),u=lo(u,u.next),Io(s,e,r,i,n,o),void Io(u,e,r,i,n,o)}a=a.next}s=s.next}while(s!==t)}var No=2;function Vo(t,e){for(var r=t.s,i=t.p,n=r[1],o=i[1],s=0,a=0;a<n.length;a++){s+=(E=n[a]).length-1}var u,c=new Float32Array(s*l),h=e.indexBase,f=void 0===h?0:h,p=e.uvTransform,d=0,m=0,v=0,y=1,g=1;p&&(m=p[0],v=p[1],u=p[4],y=u?p[3]:p[2],g=u?p[2]:p[3]);var x=[0,0],T=0===u?0:-Math.PI/2;for(a=0;a<n.length;a++)for(var E=n[a],S=o[a],b=o[a+1]||o[0],A=E,_=[0,0],C=0;C<A.length-1;C++){Bo(_,A[C],S,b,S[4],S[5],b[2],b[3]),O(_[0],_[1])}var R=Lo(Array.from(c),null,l,f);return{aPoint:c,index:new Uint16Array(R)};function O(t,e){c[d++]=t/2,c[d++]=e/2,p?(x[0]=t,x[1]=e,zo(x,x,T),c[d++]=m+(x[0]+1)/2*y,c[d++]=v+(x[1]+1)/2*g):(c[d++]=(t+1)/2,c[d++]=(e+1)/2),d+=No}}function Do(t,e){for(var r=[],i=function(t){var e=[];return t.gs?t.gs.forEach((function(t){e.push({p:[ot.SHAPE_POINTS,t.p],s:[ot.SHAPE_SPLITS,t.s]})})):t.g?e.push({p:[ot.SHAPE_POINTS,t.g.p],s:[ot.SHAPE_SPLITS,t.g.s]}):e.push(t),e}(t),n=0,o=0,s=0,a=0;a<i.length;a++){n+=(f=Vo(i[a],{indexBase:n,uvTransform:e})).aPoint.length/5,r.push(f),o+=f.aPoint.length,s+=f.index.length}if(1===r.length)return r[0];for(var u=new Float32Array(o),l=new Uint16Array(s),c=(a=0,0),h=0;a<r[a];a++){var f=r[a];u.set(f.aPoint,c),c+=f.aPoint.length,l.set(f.index,h),h+=f.index.length}return{aPoint:u,index:l}}function zo(t,e,r){var i=Math.cos(r),n=Math.sin(r),o=e[0],s=e[1];return t[0]=i*o+n*s,t[1]=-n*o+i*s,t}function Bo(t,e,r,i,n,o,s,a){var u=1-e,l=u*u*u,c=3*e*u*u,h=3*e*e*u,f=e*e*e;return t[0]=l*r[0]+c*n+h*s+f*i[0],t[1]=l*r[1]+c*o+h*a+f*i[1],t}var Uo=function(){function t(t){var e=t.time,r=t.interval,i=t.count,n=t.cycles,o=t.probability;this.time=+e||0,this.interval=+r||1,this.count=i instanceof he?i:be(i),this.cycles=+n||1/0,this.probability=isNaN(o)?1:+o,this.reset()}return t.prototype.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},t.prototype.reset=function(){this.internalCycles=this.cycles,this.index=0,this.now=0},t.prototype.clone=function(){return new t(this)},t}(),ko=new Mt,Go=new Mt,Xo=function(){function e(e,r){var i;this.pointStart=[];var n=e.colorOverLifetime,o=e.colorOverTrail,s=e.maxTrailCount,a=e.opacityOverLifetime,u=void 0===a?be(1):a,l=e.widthOverTrail,h=e.name,f=e.occlusion,p=e.blending,d=e.maskMode,m=e.order,y=e.textureMap,g=void 0===y?[0,0,1,1]:y,x=e.texture,T=e.transparentOcclusion,E=e.minimumVertexDistance,S=e.lifetime,b=e.matrix,A=r.gpuCapability,_=A.detail,C=A.level,R=Math.max(e.pointCountPerTrail,2),O={curves:[],index:0,max:0,lineSegCount:0,curveCount:0},w=_.maxVertexTextures>0,M=(null!==(i=r.renderer)&&void 0!==i?i:{}).env,L={},I=[["ENABLE_VERTEX_TEXTURE",w],["LOOKUP_TEXTURE_CURVE",0],["ENV_EDITOR",M===c]],P=s>64,F=0;n&&(I.push(["COLOR_OVER_LIFETIME",!0]),F|=1,L.uColorOverLifetime=Vr.createWithData(r,Q(n))),o&&(I.push(["COLOR_OVER_TRAIL",!0]),F|=4,L.uColorOverTrail=Vr.createWithData(r,Q(o))),P?(I.push(["ATTR_TRAIL_START",1]),F|=8):L.uTrailStart=new Float32Array(s),L.uOpacityOverLifetimeValue=u.toUniform(O);var N=l.toUniform(O);I.push(["VERT_CURVE_VALUE_COUNT",O.index],["VERT_MAX_KEY_FRAME_COUNT",O.max]),L.uVCurveValues=ge.getAllData(O);var V={shader:{vertex:br(I,wi,t.ShaderType.vertex,C),fragment:br(I,Ri,t.ShaderType.fragment,C),marcos:I,glslVersion:1===C?t.GLSLVersion.GLSL1:t.GLSLVersion.GLSL3,shared:!0,name:"trail#".concat(h),cacheId:"-t:+".concat(F,"+").concat(O.index,"+").concat(O.max)},uniformSemantics:{effects_MatrixVP:"VIEWPROJECTION",effects_MatrixInvV:"VIEWINVERSE",effects_ObjectToWorld:"MODEL",uEditorTransform:"EDITOR_TRANSFORM"}},D=R*s*2,z=(R-1)*s,B=Float32Array.BYTES_PER_ELEMENT,U=12*B,k={attributes:{aColor:{size:4,stride:U,data:new Float32Array(12*D)},aSeed:{size:1,stride:U,offset:4*B,dataSource:"aColor"},aInfo:{size:3,stride:U,offset:5*B,dataSource:"aColor"},aPos:{size:4,stride:U,offset:8*B,dataSource:"aColor"},aTime:{size:1,data:new Float32Array(D)},aDir:{size:3,data:new Float32Array(3*D)}},indices:{data:new Uint16Array(6*D)},drawCount:6*z,name:"trail#".concat(h),bufferUsage:v.DYNAMIC_DRAW};if(P)k.attributes.aTrailStart={size:1,data:new Float32Array(D)};else{var G=new Float32Array(D);k.attributes.aTrailStartIndex={size:1,data:G};for(var X=0;X<s;X++)for(var H=2*R,Y=X*H,j=0;j<H;j++)G[Y+j]=X}var W=xr(p),Z=qr.create(r,V);Z.blending=!0,Z.depthMask=f,Z.depthTest=!0,Cr(Z,d),Ar(Z,p);var q=this.mesh=gi.create(r,{name:"MTrail_".concat(h),material:Z,geometry:li.create(r,k),priority:m}),K=null!=x?x:Vr.createWithData(r);Object.keys(L).map((function(t){var e=L[t];if(e instanceof Vr)Z.setTexture(t,e);else if("uTrailStart"===t)Z.setFloats("uTrailStart",e);else if("uVCurveValues"===t){var r=[];r.push(new zt(e[0],e[1],e[2],e[3])),r.push(new zt(e[4],e[5],e[6],e[7])),Z.setVector4Array(t,r)}else Z.setVector4(t,zt.fromArray(e))})),Z.setFloat("uTime",0),Z.setVector4("uWidthOverTrail",zt.fromArray(N)),Z.setVector2("uTexOffset",new wt(0,0)),Z.setVector4("uTextureMap",zt.fromArray(g)),Z.setVector4("uParams",new zt(0,R-1,0,0)),Z.setTexture("uMaskTex",K),Z.setVector4("uColorParams",new zt(x?1:0,+W,0,+(f&&!T))),this.maxTrailCount=s,this.pointCountPerTrail=R,this.checkVertexDistance=E>0,this.minimumVertexDistance=Math.pow(E||.001,2),this.useAttributeTrailStart=P,this.lifetime=S,b&&(this.mesh.worldMatrix=b),this.geometry=q.firstGeometry(),this.trailCursors=new Uint16Array(s)}return Object.defineProperty(e.prototype,"time",{get:function(){return this.mesh.material.getFloat("uTime")||0},set:function(t){this.mesh.material.setFloat("uTime",null!=t?t:0)},enumerable:!1,configurable:!0}),e.prototype.addPoint=function(t,e,r){r=r||{};var i=this.trailCursors[t],n=this.pointCountPerTrail,o=this.geometry,s=n-1,a=i%n,u=(i-1)%n,l=(i-2)%n,c=this.getTrailPosition(t,u,ko);if(!(c&&this.checkVertexDistance&&(null==c?void 0:c.distanceSquared(e))<this.minimumVertexDistance)){var h=t*n+a,f=Wo(c,e),p=r.time||this.time,d=[Math.random(),r.lifetime||this.lifetime,i],m=r.size||1,v=6*h,y=new Float32Array(6);y.set(f,0),y.set(f,3),o.setAttributeSubData("aDir",v,y),o.setAttributeSubData("aTime",2*h,new Float32Array([p,p]));var g=r.color||[1,1,1,1],x=new Float32Array(24),T=e.toArray();if(x.set(g,0),x.set(d,4),x[7]=0,x.set(T,8),x[11]=.5*m,x.set(g,12),x.set(d,16),x[19]=1,x.set(T,20),x[23]=-.5*m,o.setAttributeSubData("aColor",24*h,x),u>=0){var E=this.getTrailPosition(t,l,Go),S=new Float32Array(Wo(E,c,e)),b=6*(t*n+u);o.setAttributeSubData("aDir",b,S),o.setAttributeSubData("aDir",b+3,S);var A=t*n*2,_=new Uint16Array([2*u+A,2*u+1+A,2*a+A,2*a+A,2*u+1+A,2*a+1+A]),C=6*(t*s+(i-1)%s);o.setIndexSubData(C,_)}i=++this.trailCursors[t];var R=this.mesh.material,O=R.getVector4("uParams"),w=d[2];if(this.useAttributeTrailStart){for(var M=2*n,L=new Float32Array(M),I=0;I<M;I++)L[I]=w;o.setAttributeSubData("aTrailStart",t*L.length,L)}else{var P=R.getFloats("uTrailStart");null!=P&&(P[t]=w,R.setFloats("uTrailStart",P))}O&&(O.y=Math.max(O.y,i-1)-Math.max(0,i-n),R.setVector4("uParams",O))}},e.prototype.getTrailPosition=function(t,e,r){var i=this.pointCountPerTrail;if(e>=0&&e<i){var n=24*(t*i+e)+8,o=this.geometry.getAttributeData("aColor");return r.x=o[n],r.y=o[1+n],r.z=o[2+n],r}},e.prototype.clearAllTrails=function(){var t=this.geometry;this.trailCursors=new Uint16Array(this.trailCursors.length),t.setIndexData(new Uint16Array(t.getIndexData().length))},e.prototype.minusTime=function(t){for(var e=this.geometry.getAttributeData("aTime"),r=0;r<e.length;r++)e[r]-=t;this.geometry.setAttributeData("aTime",e),this.time-=t},e.prototype.clearTrail=function(t){if(0!==this.trailCursors[t]){var e=6*(this.pointCountPerTrail-1),r=this.geometry.getIndexData();null==r||r.set(new Uint16Array(e),t*e),this.geometry.setIndexData(r),this.trailCursors[t]=0}},e.prototype.getPointStartPos=function(t){return this.pointStart[t]},e.prototype.setPointStartPos=function(t,e){this.pointStart[t]=e},e.prototype.onUpdate=function(t){},e}(),Ho=new Mt,Yo=new Mt,jo=new Mt;function Wo(t,e,r){var i=Ho;return t||r?(t?r?(Yo.subtractVectors(e,t).normalize(),Yo.subtractVectors(r,e),jo.copyFrom(Yo).normalize(),i.addVectors(Yo,jo)):i.subtractVectors(e,t):i.subtractVectors(r,e),i.normalize().toArray()):[0,0,0]}var Zo=function(){function t(t,e,r){var i,n,o,s,a,u,l=r.composition,c=r.endBehavior,h=r.name;if(l){var f,p=l.getEngine(),d=e.cachePrefix,m=void 0===d?"":d,v=t.options,y=t.positionOverLifetime,g=t.shape,x=r.duration||1,T=y.gravityOverLifetime,E=$t(y.gravity),_=t.textureSheetAnimation,C=_?{animationDelay:be(_.animationDelay||0),animationDuration:be(_.animationDuration||1),cycles:be(_.cycles||1),animate:_.animate,col:_.col,row:_.row,total:_.total||_.col*_.row}:void 0,R=Ft.fromIdentity(),O=!!(g&&g.turbulenceX||g.turbulenceY||g.turbulenceZ);O&&(f=[be(null!==(i=g.turbulenceX)&&void 0!==i?i:0),be(null!==(n=g.turbulenceY)&&void 0!==n?n:0),be(null!==(o=g.turbulenceZ)&&void 0!==o?o:0)]),this.name=h,this.shape=ao(g),this.emission={rateOverTime:be(t.emission.rateOverTime),burstOffsets:ns(null!==(s=t.emission.burstOffsets)&&void 0!==s?s:[]),bursts:(t.emission.bursts||[]).map((function(t){return new Uo(t)}))},this.textureSheetAnimation=C;var w,L=t.renderer||{},I={},P=t.rotationOverLifetime;P&&(I.asRotation=!!P.asRotation,I.z=P.z?be(P.z):be(0),P.separateAxes&&(I.x=P.x&&be(P.x),I.y=P.y&&be(P.y))),y.forceTarget&&(w={target:y.target||[0,0,0],curve:be(y.forceCurve||[ot.LINE,[[0,0],[1,1]]])});var F={x:y.linearX&&be(y.linearX||0),y:y.linearY&&be(y.linearY||0),z:y.linearZ&&be(y.linearZ||0),asMovement:y.asMovement},N={x:y.orbitalX&&be(y.orbitalX),y:y.orbitalY&&be(y.orbitalY),z:y.orbitalZ&&be(y.orbitalZ),center:y.orbCenter,asRotation:y.asRotation},V=t.sizeOverLifetime||{},D=t.colorOverLifetime,z=r.listIndex,B=m,U=(null==V?void 0:V.separateAxes)?{separateAxes:!0,x:be(V.x),y:be(V.y)}:{separateAxes:!1,x:be(("size"in V?V.size:V.x)||1)},k=wt.fromArray(se(L.anchor,L.particleOrigin));this.options={particleFollowParent:!!v.particleFollowParent,startLifetime:be(v.startLifetime),startDelay:be(v.startDelay||0),startSpeed:be(y.startSpeed||0),startColor:be(v.startColor),endBehavior:c,duration:x,looping:c===at.loop,maxCount:null!==(a=v.maxCount)&&void 0!==a?a:0,gravityModifier:be(T||0).scaleXCoord(x),gravity:E,start3DSize:!!v.start3DSize,startTurbulence:O,turbulence:f,speedOverLifetime:y.speedOverLifetime&&be(y.speedOverLifetime),linearVelOverLifetime:F,orbitalVelOverLifetime:N,forceTarget:w},v.startRotationZ&&(this.options.startRotation=be(v.startRotationZ||0)),(v.startRotationX||v.startRotationY)&&(this.options.start3DRotation=!0,this.options.startRotationX=be(v.startRotationX||0),this.options.startRotationY=be(v.startRotationY||0),this.options.startRotationZ=be(v.startRotationZ||0)),v.start3DSize?(this.options.startSizeX=be(v.startSizeX),this.options.startSizeY=be(v.startSizeY)):(this.options.startSize=be(v.startSize),this.options.sizeAspect=be(v.sizeAspect||1));var G={listIndex:z,meshSlots:v.meshSlots,name:h,matrix:R,filter:t.filter,shaderCachePrefix:B,renderMode:L.renderMode||M.BILLBOARD,side:L.side||b.DOUBLE,gravity:E,duration:r.duration,blending:L.blending||S.ALPHA,rotationOverLifetime:I,gravityModifier:this.options.gravityModifier,linearVelOverLifetime:this.options.linearVelOverLifetime,orbitalVelOverLifetime:this.options.orbitalVelOverLifetime,speedOverLifetime:this.options.speedOverLifetime,sprite:C,occlusion:!!L.occlusion,transparentOcclusion:!!L.transparentOcclusion,maxCount:v.maxCount,mask:L.mask,maskMode:null!==(u=L.maskMode)&&void 0!==u?u:A.NONE,forceTarget:w,diffuse:L.texture,sizeOverLifetime:U,anchor:k};if(D){var X=D.color,H=D.opacity;G.colorOverLifetime={},H&&(G.colorOverLifetime.opacity=be(D.opacity)),X&&(X[0]===ot.GRADIENT_COLOR?G.colorOverLifetime.color=D.color[1]:X[0]===ot.RGBA_COLOR?G.colorOverLifetime.color=Vr.createWithData(p,{data:new Uint8Array(X[1]),width:1,height:1}):X instanceof Vr&&(G.colorOverLifetime.color=X))}var Y,j=[],W=[0,0,1,1];if(t.splits){var Z=t.splits[0];W=(Y=Z[4])?[Z[0],Z[1],Z[3],Z[2]]:[Z[0],Z[1],Z[2],Z[3]]}if(C&&!C.animate)for(var q=Y?C.row:C.col,K=Y?C.col:C.row,Q=C.total||q*K,J=0,$=0;$<q;$++)for(var tt=0;tt<K&&J<Q;tt++,J++)j.push([$*W[2]/q+W[0],tt*W[3]/K+W[1],W[2]/q,W[3]/K]);else j.push(W);G.textureFlip=Y,this.uvs=j,this.particleMesh=new Bn(G,{composition:l});var et=t.trails;if(et){this.trails={lifetime:be(et.lifetime),dieWithParticles:!1!==et.dieWithParticles,sizeAffectsWidth:!!et.sizeAffectsWidth,sizeAffectsLifetime:!!et.sizeAffectsLifetime,inheritParticleColor:!!et.inheritParticleColor,parentAffectsPosition:!!et.parentAffectsPosition};var rt={name:r.name+"_trail",matrix:R,minimumVertexDistance:et.minimumVertexDistance||.02,maxTrailCount:v.maxCount,pointCountPerTrail:Math.round(et.maxPointPerTrail)||32,blending:et.blending,texture:et.texture,opacityOverLifetime:be(et.opacityOverLifetime||1),widthOverTrail:be(et.widthOverTrail||1),order:z+(et.orderOffset||0),shaderCachePrefix:B,lifetime:this.trails.lifetime,occlusion:!!et.occlusion,transparentOcclusion:!!et.transparentOcclusion,textureMap:et.textureMap,mask:L.mask,maskMode:L.maskMode};et.colorOverLifetime&&et.colorOverLifetime[0]===ot.GRADIENT_COLOR&&(rt.colorOverLifetime=et.colorOverLifetime[1]),et.colorOverTrail&&et.colorOverTrail[0]===ot.GRADIENT_COLOR&&(rt.colorOverTrail=et.colorOverTrail[1]),this.trailMesh=new Xo(rt,p)}this.transform=r.transform;var it,nt=this.transform.position.clone(),st=this.transform.rotation.clone(),ut=t.emitterTransform&&t.emitterTransform.path;ut&&(ut[0]===ot.CONSTANT_VEC3?nt.add(ut[1]):it=be(ut)),this.basicTransform={position:nt,rotation:st,path:it},this.updateEmitterTransform(0);var lt=[this.particleMesh.mesh];this.trailMesh&<.push(this.trailMesh.mesh),this.meshes=lt,this.reusable=r.reusable,this.setVisible(r.contentVisible);var ct=t.interaction;ct&&(this.interaction={multiple:ct.multiple,radius:ct.radius,behavior:ct.behavior})}}return Object.defineProperty(t.prototype,"timePassed",{get:function(){return this.lastUpdate-this.loopStartTime},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lifetime",{get:function(){return this.timePassed/this.options.duration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"particleCount",{get:function(){return this.particleLink.length},enumerable:!1,configurable:!0}),t.prototype.updateEmitterTransform=function(t){var e=this.transform.parentTransform,r=this.basicTransform,i=r.path,n=r.position.clone();if(i){var o=this.options.duration;n.add(i.getValue(t/o))}if(this.transform.setPosition(n.x,n.y,n.z),this.options.particleFollowParent&&e){var s=e.getWorldMatrix();this.particleMesh.mesh.worldMatrix=s,this.trailMesh&&(this.trailMesh.mesh.worldMatrix=s)}},t.prototype.addParticle=function(t,e){var r,i=this.particleLink,n=[t.delay+t.lifetime,0,t.delay,t];if(i.length<e)r=n[1]=i.length;else{var o=i.first;i.removeNode(o),r=n[1]=o.content[1]}i.pushNode(n),this.particleMesh.setPoint(t,r),this.clearPointTrail(r),this.trailMesh&&this.trailMesh.setPointStartPos(r,this.transform.parentTransform.position.clone())},t.prototype.setVisible=function(t){this.particleMesh.mesh.setVisible(t),this.trailMesh&&this.trailMesh.mesh.setVisible(t)},t.prototype.setOpacity=function(t){var e,r=this.particleMesh.mesh.material,i=this.particleMesh.mesh.geometry,n=(null===(e=r.getVector4("uOpacityOverLifetimeValue"))||void 0===e?void 0:e.toArray())||[1,1,1,1];r.setVector4("uOpacityOverLifetimeValue",new zt(n[0],n[1],n[2],t));for(var o=i.getAttributeData("aColor")||[],s=0;s<o.length;s+=32)o[8*s+7]=t},t.prototype.setColor=function(t,e,r,i){var n,o=this.particleMesh.mesh.material,s=this.particleMesh.mesh.geometry,a=(null===(n=o.getVector4("uOpacityOverLifetimeValue"))||void 0===n?void 0:n.toArray())||[1,1,1,1];o.setVector4("uOpacityOverLifetimeValue",new zt(a[0],a[1],a[2],i));for(var u=s.getAttributeData("aColor")||[],l=0;l<u.length;l+=32)u[8*l+4]=t,u[8*l+5]=e,u[8*l+6]=r,u[8*l+7]=i},t.prototype.setParentTransform=function(t){},t.prototype.getTextures=function(){var t=[],e=this.particleMesh.mesh.material.textures;if(Object.keys(e).forEach((function(r){t.push(e[r])})),this.trailMesh){var r=this.trailMesh.mesh.material.textures;Object.keys(r).forEach((function(e){t.push(r[e])}))}return t},t.prototype.start=function(){this.started&&!this.ended||(this.reset(),this.started=!0,this.ended=!1)},t.prototype.stop=function(){this.ended=!0,this.started=!1},t.prototype.reset=function(){var t;this.particleMesh.clearPoints(),null===(t=this.trailMesh)||void 0===t||t.clearAllTrails(),this.lastUpdate=0,this.loopStartTime=0,this.lastEmitTime=-1/this.emission.rateOverTime.getValue(0),this.generatedCount=0,this.particleLink=new Yn((function(t,e){return t[0]-e[0]})),this.emission.bursts.forEach((function(t){return t.reset()})),this.frozen=!1},t.prototype.onUpdate=function(t){var e,r=this;if(this.started&&!this.frozen){var i=this.lastUpdate+t/1e3,n=this.particleMesh,o=this.trailMesh,s=this.options,l=this.loopStartTime,c=this.emission;this.lastUpdate=i,this.upDirectionWorld=null,n.time=i,o&&(o.time=i,o.onUpdate(t));var h=this.particleLink,f=(i-l)/s.duration,p=this.timePassed,d=!1,m=function(){r.trails&&!d&&(d=!0,h.forEach((function(t){var e=a(t,4),i=e[0],n=e[1],o=e[2],s=e[3];i<p?r.clearPointTrail(n):p>o&&r.updatePointTrail(n,f,s,o)})))};if(this.ended){if(!s.looping)if(this.reusable);else if(0===s.endBehavior){var v=h.last;v&&v.content[0]-l<p&&(this.onUpdate=function(){return r.onDestroy()})}}else{var y=s.duration,g=this.lifetime;if(p<y){var x=1/c.rateOverTime.getValue(g),T=Math.floor((p-this.lastEmitTime)/x),E=T,S=x/T,b=i,A=s.maxCount;this.updateEmitterTransform(p);for(var _=function(){var t=h.first;return r.emissionStopped||h.length===A&&t&&t.content[0]-l>p},C=0;C<E&&C<A&&!_();C++){(F=this.createPoint(g)).delay+=b+C*S,this.addParticle(F,A),this.lastEmitTime=p}for(var R=c.bursts,O=(null==R?void 0:R.length)-1,w=0;O>=0&&w<A&&!_();O--){var M=R[O],L=!M.disabled&&M.getGeneratorOptions(p,g);if(L){var I=c.burstOffsets[O],P=I&&I[L.cycleIndex]||[0,0,0];M.once&&this.removeBurst(O);for(C=0;C<L.count&&w<A&&!_();C++){var F;(F=this.initPoint(this.shape.generate({total:L.total,index:L.index,burstIndex:C,burstCount:L.count}))).delay+=b,w++,(e=F.transform).translate.apply(e,u([],a(P),!1)),this.addParticle(F,A)}}}}else if(s.looping)m(),this.loopStartTime=i-y,this.lastEmitTime-=y,this.lastUpdate-=y,c.bursts.forEach((function(t){return t.reset()})),this.particleLink.forEach((function(t){t[0]-=y,t[2]-=y,t[3].delay-=y})),n.minusTime(y),o&&o.minusTime(y),this.onIterate(this);else{this.ended=!0,this.onEnd(this),4===s.endBehavior&&(this.frozen=!0)}}m()}},t.prototype.onDestroy=function(){},t.prototype.getParticleBoxes=function(){var t=this.particleLink,e=this.particleMesh,r=[],i=this.particleCount,n=0;if(!t||!e)return r;for(var o=t.last,s=!1;!s;){var a=o.content[0],u=o.content[3];if(a>this.timePassed){var l=this.getPointPosition(u);r.push({center:l,size:u.transform.scale}),o.pre?o=o.pre:s=!0}++n>i&&(s=!0)}return r},t.prototype.raycast=function(t){var e=this.particleLink,r=this.particleMesh;if(e&&r){var i=e.last,n=[],o=new Mt,s=!1;if(i&&i.content)do{var u=a(i.content,4),l=u[0],c=u[1];u[2];var h=u[3];if(!(l>this.timePassed))break;var f=this.getPointPosition(h),p=t.ray,d=!1;p&&(d=!!p.intersectSphere({center:f,radius:t.radius},o)),d&&(t.removeParticle&&(r.removePoint(c),this.clearPointTrail(c),i.content[0]=0),n.push(f),t.multiple||(s=!0))}while((i=i.pre)&&!s);return n}},t.prototype.clearPointTrail=function(t){var e;this.trails&&this.trails.dieWithParticles&&(null===(e=this.trailMesh)||void 0===e||e.clearTrail(t))},t.prototype.updatePointTrail=function(t,e,r,i){if(this.trailMesh){var n=this.trails,o=this.particleMesh,s=this.getPointPosition(r),a=n.inheritParticleColor?o.getPointColor(t):[1,1,1,1],u=r.transform.getWorldScale().toArray(),l=1,c=n.lifetime.getValue(e);if(n.sizeAffectsWidth&&(l*=u[0]),n.sizeAffectsLifetime&&(c*=u[0]),n.parentAffectsPosition&&this.transform.parentTransform){s.add(this.transform.parentTransform.position);var h=this.trailMesh.getPointStartPos(t);h&&s.subtract(h)}this.trailMesh.addPoint(t,s,{color:a,lifetime:c,size:l,time:i})}},t.prototype.getPointPosition=function(t){var e=t.transform,r=t.vel,i=t.lifetime,n=t.delay,o=t.gravity,s=void 0===o?[]:o,a=this.options.forceTarget,u=this.lastUpdate-n,l=new Mt,c=Mt.fromArray(s);e.assignWorldTRS(l);var h=Jt(new Mt,this.options,c,u,i,l,r);if(a){var f=a.target||[0,0,0],p=a.curve.getValue(u/i),d=1-p;h.x=h.x*d+f[0]*p,h.y=h.y*d+f[1]*p,h.z=h.z*d+f[2]*p}return h},t.prototype.onEnd=function(t){},t.prototype.onIterate=function(t){},t.prototype.initPoint=function(t){var e=this.options,r=this.lifetime,i=this.shape,n=e.startSpeed.getValue(r),o=e.particleFollowParent?this.transform.getMatrix():this.transform.getWorldMatrix(),s=o.transformPoint(t.position,new Mt),a=new Ke({position:s,valid:!0}),u=t.direction;if(u=o.transformNormal(u,qo).normalize(),e.startTurbulence&&e.turbulence){for(var l=0;l<3;l++)ts.setElement(l,e.turbulence[l].getValue(r));es.setFromVector3(ts.negate()),is.setFromEuler(es).transformNormal(u).normalize()}var c,h=Jo,f=$o;i.alignSpeedDirection?(f.copyFrom(u),this.upDirectionWorld||(i.upDirection?this.upDirectionWorld=i.upDirection.clone():this.upDirectionWorld=Mt.Z.clone(),o.transformNormal(this.upDirectionWorld)),h.crossVectors(f,this.upDirectionWorld).normalize(),h.isZero()&&h.set(1,0,0)):(h.set(1,0,0),f.set(0,1,0));var p=this.textureSheetAnimation;p&&p.animate&&((c=rs)[0]=p.animationDelay.getValue(r),c[1]=p.animationDuration.getValue(r),c[2]=p.cycles.getValue(r));var d=Qo;e.start3DRotation?d.set(e.startRotationX.getValue(r),e.startRotationY.getValue(r),e.startRotationZ.getValue(r)):e.startRotation?d.set(0,0,e.startRotation.getValue(r)):d.set(0,0,0),a.setRotation(d.x,d.y,d.z);var m=e.startColor.getValue(r);3===m.length&&(m[3]=1);var v=Ko;if(e.start3DSize)v.x=e.startSizeX.getValue(r),v.y=e.startSizeY.getValue(r);else{var y=e.startSize.getValue(r),g=e.sizeAspect.getValue(r);v.x=y,v.y=0===g?0:y/g}var x=u.clone();if(x.multiply(n),!e.particleFollowParent){var T=new Mt;this.transform.assignWorldTRS(void 0,void 0,T),v.x*=T.x,v.y*=T.y}return a.setScale(v.x,v.y,1),{size:v,vel:x,color:m,delay:e.startDelay.getValue(r),lifetime:e.startLifetime.getValue(r),uv:os(this.uvs,!0),gravity:e.gravity,sprite:c,dirY:f,dirX:h,transform:a}},t.prototype.addBurst=function(t,e){var r=!1;if(this.emission.bursts.includes(t)||(this.emission.bursts.push(t),r=!0),r&&e instanceof Array){var i=this.emission.bursts.indexOf(t);return this.emission.burstOffsets[i]=e,i}return-1},t.prototype.removeBurst=function(t){t<this.emission.bursts.length&&(this.emission.burstOffsets[t]=null,this.emission.bursts.splice(t,1))},t.prototype.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))},t}(),qo=new Mt,Ko=new wt,Qo=new Dt,Jo=new Mt,$o=new Mt,ts=new Mt,es=new Dt,rs=[0,0,0],is=new Ft;function ns(t){var e={};return Array.isArray(t)&&t.forEach((function(t){var r=t instanceof Array,i=r?t[0]:t.index,n=e[i];n||(n=e[i]=[]),r?n.push(t.slice(1,4)):n.push([+t.x,+t.y,+t.z])})),e}function os(t,e){var r=Math.floor(Math.random()*t.length),i=t[r];return e||t.splice(r,1),i}var ss=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.destroyed=!1,t}return r(i,e),Object.defineProperty(i.prototype,"type",{get:function(){return w.particle},enumerable:!1,configurable:!0}),i.prototype.onConstructed=function(t){this.particle=t.content},i.prototype.onLifetimeBegin=function(t,e){var r=this;return e&&(e.name=this.name,e.start(),e.onDestroy=function(){r.destroyed=!0}),e},i.prototype.onItemUpdate=function(t,e){var r;if(this.content){var i=!this.visible,n=this.parentId&&(null===(r=this.composition)||void 0===r?void 0:r.getItemByID(this.parentId));if(!i&&n){var o=n.getRenderData();o&&(o.visible||(i=!1))}i?this.content.setVisible(!1):(this.content.setVisible(!0),this.content.onUpdate(t))}},i.prototype.onItemRemoved=function(e,r){r&&(e.destroyTextures(r.getTextures()),r.meshes.forEach((function(e){return e.dispose({material:{textures:t.DestroyOptions.keep}})})))},i.prototype.setColor=function(t,e,r,i){this.content.setColor(t,e,r,i)},i.prototype.setOpacity=function(t){this.content.setOpacity(t)},i.prototype.stopParticleEmission=function(){this.content&&(this.content.emissionStopped=!0)},i.prototype.resumeParticleEmission=function(){this.content&&(this.content.emissionStopped=!1)},i.prototype.doCreateContent=function(t){return rt(this.particle),new Zo(this.particle,t.getRendererOptions(),this)},i.prototype.isEnded=function(t){return e.prototype.isEnded.call(this,t)&&this.destroyed},i.prototype.getBoundingBox=function(){var e=this.content;if(e){var r=e.getParticleBoxes();return{type:t.HitTestType.sphere,area:r}}},i.prototype.getHitTestParams=function(e){var r,i=this,n=null===(r=this.content)||void 0===r?void 0:r.interaction;if(e||n)return{type:t.HitTestType.custom,collect:function(t){var e;return null===(e=i.content)||void 0===e?void 0:e.raycast({radius:(null==n?void 0:n.radius)||.4,multiple:!!(null==n?void 0:n.multiple),removeParticle:(null==n?void 0:n.behavior)===lt.removeParticle,ray:t})}}},i}(Qe),as=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.meshes=[],t}return r(i,e),i.precompile=function(e,r,i){var n=e[0],o={rotationOverLifetime:{x:!1,y:!1,z:!1},positionOverLifetime:{speedOverLifetime:!1,linearX:!1,linearY:!1,linearZ:!1,orbitalX:!1,orbitalY:!1,orbitalZ:!1,forceCurve:!1},colorOverLifetime:{opacity:!1,color:!1},sizeOverLifetime:{x:!1,y:!1}},s={colorOverLifetime:{opacity:1,color:[ot.RGBA_COLOR,[255,255,255,255]]},positionOverLifetime:{speedOverLifetime:1},sizeOverLifetime:{x:1,y:1}},a=r.engine.gpuCapability,u=a.level,l=(null!=i?i:{}).env,h=r.getShaderLibrary(),f=[],p=[],d=[],m=0,v=0;return n.items.forEach((function(e){t.Item.isParticle(e)&&(p.push(e),function(e){if(t.Item.isParticle(e)){var r=e.content;r.rotationOverLifetime||(r.rotationOverLifetime={});var i=r.rotationOverLifetime;i.z||(i.z=[ot.CONSTANT,0]),i.separateAxes||(delete i.y,delete i.x),r.sizeOverLifetime||(r.sizeOverLifetime={});var n=r.sizeOverLifetime;n.separateAxes||delete n.y,n.size&&(n.x=n.size,delete n.size),n.x||(n.x=[ot.CONSTANT,1])}}(e),2===u&&Object.keys(o).forEach((function(t){var r=o[t],i=e.content[t];i&&Object.keys(r).forEach((function(e){i[e]&&(r[e]=!0,z(f,t))}))})))})),p.forEach((function(e){var r,i,n=e.content;2===u&&(f.forEach((function(t){var e=o[t],r=n[t]||(n[t]={});Object.keys(e).forEach((function(i){if(e[i]&&!r[i]){var n=s[t]&&s[t][i]||0;r[i]=isNaN(n)?n:[ot.CONSTANT,n]}}))})),o.positionOverLifetime.forceCurve&&(n.positionOverLifetime.forceTarget=!0),(o.rotationOverLifetime.x||o.rotationOverLifetime.y)&&(n.rotationOverLifetime.separateAxes=!0),o.sizeOverLifetime.y&&(n.sizeOverLifetime.separateAxes=!0));var p=Gn(e,l,a),y=p.shader,g=p.fragment,x=p.vertex;if(d.push(y),m=Math.max(m,g),v=Math.max(v,x),e.content.trails){var T=function(t,e,r,i,n){void 0===i&&(i="");var o=0,s=di(hi)?1:0,a=[["ENABLE_VERTEX_TEXTURE",n.detail.maxVertexTextures>0],["LOOKUP_TEXTURE_CURVE",s],["ENV_EDITOR",i===c]],u={curves:[],index:0,max:0,lineSegCount:0,curveCount:0};return t.colorOverLifetime&&(a.push(["COLOR_OVER_LIFETIME",!0]),o|=1),t.colorOverTrail&&(a.push(["COLOR_OVER_TRAIL",!0]),o|=4),e>64&&(a.push(["ATTR_TRAIL_START",1]),o|=8),we(u,t.opacityOverLifetime),we(u,t.widthOverTrail),a.push(["VERT_CURVE_VALUE_COUNT",u.index],["VERT_MAX_KEY_FRAME_COUNT",u.max]),{vertex:wi,fragment:Ri,marcos:a,shared:!0,name:"trail#"+r,cacheId:"-t:+".concat(o,"+").concat(u.index,"+").concat(u.max)}}(e.content.trails,e.content.options.maxCount,e.name,l,a);T.vertex=br(null!==(r=T.marcos)&&void 0!==r?r:[],T.vertex,t.ShaderType.vertex,u),T.fragment=br(null!==(i=T.marcos)&&void 0!==i?i:[],T.fragment,t.ShaderType.fragment,u),T.glslVersion=2===u?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1,h.addShader(T)}})),d.forEach((function(e){var r,i;2===u?(Xn(e,v,m),e.glslVersion=t.GLSLVersion.GLSL3):e.glslVersion=t.GLSLVersion.GLSL1,e.vertex=br(null!==(r=e.marcos)&&void 0!==r?r:[],e.vertex,t.ShaderType.vertex,u),e.fragment=br(null!==(i=e.marcos)&&void 0!==i?i:[],e.fragment,t.ShaderType.fragment,u),h.addShader(e)})),2===u&&p.forEach((function(t){t.content.options.meshSlots=[v,m]})),Promise.resolve()},i.prototype.onCompositionItemLifeBegin=function(t,e){e instanceof ss&&this.add(e.content)},i.prototype.onCompositionItemRemoved=function(t,e){e instanceof ss&&e.content&&this.remove(e.content,t.renderFrame)},i.prototype.prepareRenderFrame=function(t,e){return this.meshes.forEach((function(t){return e.addMeshToDefaultRenderPass(t)})),this.meshes.length=0,!1},i.prototype.add=function(t){var e=this;t.meshes.forEach((function(t){return z(e.meshes,t)}))},i.prototype.remove=function(t,e){var r=this;t.meshes.forEach((function(t){B(r.meshes,t),e.removeMeshFromDefaultRenderPass(t)}))},i}(sr);var us,ls=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(sr),cs=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._v_priority=1,e.childrenVisible=!0,e}return r(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return w.null},enumerable:!1,configurable:!0}),e.prototype.onConstructed=function(t){this.cal=t.content,this.relative=t.relative},e.prototype.onLifetimeBegin=function(t,e){e.active=!0},e.prototype.onItemRemoved=function(t,e){},e.prototype.onItemUpdate=function(t,e){this.content&&(this.content.updateTime(this.time),this.renderData=this.content.getRenderData(this.content.time))},e.prototype.setScale=function(t,e,r){this.content.startSize=new Mt(t,e,r)},e.prototype.scale=function(t,e,r){var i=this.content.startSize.clone();this.content.startSize=new Mt(t*i.x,e*i.y,r*i.z)},e.prototype.getHitTestParams=function(t){},e.prototype.getRenderData=function(){return this.renderData},e.prototype.getChildrenVisible=function(){return this.childrenVisible},e.prototype.setChildrenVisible=function(t){this.childrenVisible!==t&&(this.childrenVisible=!!t,this.handleVisibleChanged(this.visible))},e.prototype.doCreateContent=function(t){var e=new In(this.cal,this);return e.renderData=e.getRenderData(0,!0),e},e.prototype.handleVisibleChanged=function(t){this.content&&(this.content.visible=t||this.childrenVisible)},e}(Qe),hs=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.getItemGeometryData=function(t,e){var r=t,i=r.splits,n=r.renderer,o=r.textureSheetAnimation,s=r.startSize;r.textLayout;var a=s.x,u=s.y;if(n.shape){for(var l=n.shape,c=l.index,h=l.aPoint,f=new Float32Array(h),p=0;p<f.length;p+=6)f[p]*=a,f[p+1]*=u;return{index:c,aPoint:Array.from(f)}}var d=.5,m=.5,v=[-d,m,-d,-m,d,m,d,-m],y=[],g=[],x=2,T=2;1===i.length&&(x=1,T=1);for(var E=0;E<x;E++)for(var S=0;S<T;S++){var b=4*(2*S+E),A=o?[0,0,1,1,i[0][4]]:i[2*S+E],_=A[4]?[0,0,1,0,0,1,1,1]:[0,1,0,0,1,1,1,0],C=((E+E+1)/x-1)/2,R=((S+S+1)/T-1)/2,O=A[0],w=A[1],M=A[4]?A[3]:A[2],L=A[4]?A[2]:A[3],I=[v[0]/x+C,v[1]/T+R,v[2]/x+C,v[3]/T+R,v[4]/x+C,v[5]/T+R,v[6]/x+C,v[7]/T+R];y.push(I[0]*a,I[1]*u,_[0]*M+O,_[1]*L+w,e,0,I[2]*a,I[3]*u,_[2]*M+O,_[3]*L+w,e,0,I[4]*a,I[5]*u,_[4]*M+O,_[5]*L+w,e,0,I[6]*a,I[7]*u,_[6]*M+O,_[7]*L+w,e,0),this.lineMode?g.push(b,1+b,1+b,3+b,3+b,2+b,2+b,b):g.push(b,1+b,2+b,2+b,1+b,3+b)}return{index:g,aPoint:y}},e}(xn),fs=function(t){var e,r,i,n,o,s;this.isUnderline=!1,this.underlineHeight=1,this.isOutlined=!1,this.outlineWidth=0,this.hasShadow=!1,this.fontDesc="",this.fontScale=2,this.fontOffset=0;var a=t.textColor,u=void 0===a?[1,1,1,1]:a,l=t.fontSize,c=void 0===l?40:l,h=t.outline,f=t.shadow,p=t.fontWeight,d=void 0===p?"normal":p,m=t.fontStyle,v=void 0===m?"normal":m,y=t.fontFamily,g=void 0===y?"sans-serif":y;this.textColor=u,this.textWeight=d,this.fontStyle=v,this.fontFamily=g,this.fontSize=c,h&&(this.isOutlined=!0,this.outlineColor=null!==(e=h.outlineColor)&&void 0!==e?e:[1,1,1,1],this.outlineWidth=null!==(r=h.outlineWidth)&&void 0!==r?r:1,this.fontOffset+=this.outlineWidth),f&&(this.hasShadow=!0,this.shadowBlur=null!==(i=f.shadowBlur)&&void 0!==i?i:2,this.shadowColor=null!==(n=f.shadowColor)&&void 0!==n?n:[0,0,0,1],this.shadowOffsetX=null!==(o=f.shadowOffsetX)&&void 0!==o?o:0,this.shadowOffsetY=null!==(s=f.shadowOffsetY)&&void 0!==s?s:0),this.fontStyle!==xt.normal&&(this.fontOffset+=this.fontSize*Math.tan(.20943951))},ps=function(){function t(){}return t.measureFont=function(e){if(t._fonts[e])return t._fonts[e];var r={ascent:0,descent:0,fontSize:0},i=t._canvas,n=i.getContext("2d",{willReadFrequently:!0});n.font=e;var o=t.METRICS_STRING+t.BASELINE_SYMBOL,s=Math.ceil(n.measureText(o).width),a=Math.ceil(n.measureText(t.BASELINE_SYMBOL).width),u=Math.ceil(t.HEIGHT_MULTIPLIER*a);a=a*t.BASELINE_MULTIPLIER|0,i.width=s,i.height=u,n.fillStyle="#f00",n.fillRect(0,0,s,u),n.font=e,n.textBaseline="alphabetic",n.fillStyle="#000",n.fillText(o,0,a);var l=n.getImageData(0,0,s,u).data,c=l.length,h=4*s,f=0,p=0,d=!1;for(f=0;f<a;++f){for(var m=0;m<h;m+=4)if(255!==l[p+m]){d=!0;break}if(d)break;p+=h}for(r.ascent=a-f,p=c-h,d=!1,f=u;f>a;--f){for(m=0;m<h;m+=4)if(255!==l[p+m]){d=!0;break}if(d)break;p-=h}return r.descent=f-a,r.fontSize=r.ascent+r.descent,t._fonts[e]=r,r},Object.defineProperty(t,"_canvas",{get:function(){var e;return di(fi)?(e=window._createOffscreenCanvas(10,10),t.__canvas=e):t.__canvas||((e=document.createElement("canvas")).width=e.height=10,t.__canvas=e),t.__canvas},enumerable:!1,configurable:!0}),t._fonts={},t.METRICS_STRING="|ÉqÅ",t.BASELINE_SYMBOL="M",t.BASELINE_MULTIPLIER=1.4,t.HEIGHT_MULTIPLIER=2,t}(),ds=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];t.QTextWrapMode=void 0,(us=t.QTextWrapMode||(t.QTextWrapMode={}))[us.Default=0]="Default",us[us.Clip=1]="Clip",us[us.Ellipsis=2]="Ellipsis";var ms=function(){function e(e,r){var i,n,o,s,a,u,l,c,h,f;this.left=0,this.top=0,this.fontSize=48,this.fontFamily="Arial",this.color="black",this.letterSpacing=0,this.maxLineWidth=0,this.wrap=t.QTextWrapMode.Clip,this.scaleX=1,this.scaleY=1,this.angle=0,this.active=!0,this.padding=0,this.borderColor="#ffffffff",this.borderWidth=1,this.fontProperties={ascent:0,descent:0,fontSize:0},this.fontVariant="normal",this.originX="left",this.originY="top",this.ellipsis="…",this.text=e,this.left=null!==(i=r.left)&&void 0!==i?i:0,this.top=null!==(n=r.top)&&void 0!==n?n:0,this.maxLineWidth=null!==(o=r.maxWidth)&&void 0!==o?o:0,this.letterSpacing=null!==(s=r.letterSpacing)&&void 0!==s?s:0,this.originX="left",this.originY="top",this.color=null!==(a=r.color)&&void 0!==a?a:"black",this.fontFamily=null!==(u=r.fontFamily)&&void 0!==u?u:"Arial",this.fontSize=null!==(l=r.fontSize)&&void 0!==l?l:48,this.wrap=null!==(c=r.wrap)&&void 0!==c?c:t.QTextWrapMode.Clip,this.fontStyle=null!==(h=r.fontStyle)&&void 0!==h?h:"normal",this.textAlign="left",this.textBaseline="alphabetic",this.fontWeight="normal",this.angle=null!==(f=r.angle)&&void 0!==f?f:0,this.name=r.name||""}return e.prototype.update=function(){this.updateDimension()},e.prototype.render=function(){if(void 0!==this.viewer){var t=this.viewer.renderContext;void 0!==t&&(t.save(),this.setRenderTransform(t),this.renderText(t),this.active&&this.drawBorders(t),t.restore())}},e.prototype.init=function(t){this.viewer=t,this.updateDimension()},e.prototype.getLayout=function(){var t=this.viewer.scaleX,e=this.viewer.scaleY;return{x:this.left*t,y:this.top*e,width:this.width*t,height:this.height*e}},e.prototype.updateDimension=function(){var t=this.viewer.renderContext;this.configTextStyle(t),this.configTextLayout(t);var e=this.getFontDesc();this.fontProperties=ps.measureFont(e),0===this.fontProperties.fontSize&&(this.fontProperties.fontSize=this.fontSize,this.fontProperties.ascent=this.fontSize);var r=this.createCharsFromText(t,this.text),i=0;if(r.length>0){var n=r[r.length-1];i=n.left+n.width}this.chars=r,this.maxLineWidth=i,void 0===this.height&&(this.height=this.fontProperties.fontSize),void 0===this.width&&(this.width=this.maxLineWidth)},e.prototype.configTextStyle=function(t){t.font=this.getFontDesc(),t.fillStyle=this.color},e.prototype.getFontDesc=function(){for(var t="number"==typeof this.fontSize?"".concat(this.fontSize,"px"):this.fontSize,e=this.fontFamily.split(","),r=e.length-1;r>=0;r--){var i=e[r].trim();/([\"\'])[^\'\"]+\1/.test(i)||ds.includes(i)||(i='"'.concat(i,'"')),e[r]=i}return e.push("Arial, Helvetica, sans-serif"),"".concat(this.fontStyle," ").concat(this.fontVariant," ").concat(this.fontWeight," ").concat(t," ").concat(e.join(","))},e.prototype.configTextLayout=function(t){t.textBaseline=this.textBaseline,t.textAlign=this.textAlign},e.prototype.setRenderTransform=function(t){t.scale(this.scaleX,this.scaleY),t.translate(this.left,this.top)},e.prototype.renderText=function(t){this.drawCharsInTextBox(t,{min:[0,0],max:[0+this.width,0+this.height]})},e.prototype.drawCharsInTextBox=function(e,r){var i=this.chars,n=0;if(i.length>0){var o=i[i.length-1];n=o.left+o.width}var s=r.max[0]-r.min[0],a=0;"left"===this.textAlign?a=0:"center"===this.textAlign?a=.5*(s-n):"right"===this.textAlign&&(a=s-n),this.addOffsetToChars(i,a);var u=this.cloneChars(this.clipCharsWithTextBox(i,r)),l=u;this.wrap===t.QTextWrapMode.Ellipsis&&0===(l=this.replaceCharWithEllipsis(e,u,r)).length&&0!==i.length&&this.addEllipsisToChars(e,l,r),this.drawCharsFromLeft(e,l)},e.prototype.addEllipsisToChars=function(t,e,r){var i,n,o,s=t.measureText(this.ellipsis).width;if("left"===this.textAlign)e.push({char:this.ellipsis,left:r.min[0],top:0,width:s,heigh:null!==(i=this.height)&&void 0!==i?i:0,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!0,scale:1,index:0});else if("right"===this.textAlign)e.push({char:this.ellipsis,left:r.max[0]-s,top:0,width:s,heigh:null!==(n=this.height)&&void 0!==n?n:0,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!0,scale:1,index:0});else{var a=.5*(r.max[0]+r.min[0]);e.push({char:this.ellipsis,left:a-.5*s,top:0,width:s,heigh:null!==(o=this.height)&&void 0!==o?o:0,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!0,scale:1,index:0})}},e.prototype.createCharsFromText=function(t,e){var r=e.split(""),i=0,n=0;"top"===this.textBaseline?n=0:"middle"===this.textBaseline?n+=.5*this.fontProperties.ascent:"alphabetic"===this.textBaseline&&(n+=this.fontProperties.ascent);for(var o=[],s=0;s<r.length;++s){var a=r[s],u=Math.floor(t.measureText(a).width),l={left:i,top:n,width:u,heigh:this.fontSize,char:a,font:this.fontFamily,fontSize:this.fontSize,isEllipsis:!1,scale:1,index:s};o.push(l),i+=u+this.letterSpacing}return o},e.prototype.addOffsetToChars=function(t,e){return t.forEach((function(t){t.left+=e})),t},e.prototype.clipCharsWithTextBox=function(t,e){for(var r=[],i=0;i<t.length;++i){var n=t[i];n.left>=e.min[0]&&n.left+n.width<e.max[0]+.5&&r.push(n)}return r},e.prototype.cloneChars=function(t){return t.map((function(t){return i({},t)}))},e.prototype.replaceCharWithEllipsis=function(t,e,r){var n=t.measureText(this.ellipsis).width;if(e.length>0){if(0!==e[0].index)(o=i({},e[0])).char=this.ellipsis,o.isEllipsis=!0,o.width=n,e=this.findEllipsisPositionAndReplaceCharsFromLeft(e,o,r);var o,s=e.length-1,a=this.chars.length;if(e[s].index!==a-1)(o=i({},e[0])).char=this.ellipsis,o.isEllipsis=!0,o.width=n,e=this.findEllipsisPositionAndReplaceCharsFromRight(e,o,r)}return e},e.prototype.findEllipsisPositionAndReplaceCharsFromLeft=function(t,e,r){for(var i=0,n=0;n<t.length;++n){var o=t[n];if(i=n,o.left+o.width-e.width>=r.min[0])break}var s=t[i];e.left=s.left+s.width-e.width;for(n=0;n<i+1;++n)t.shift();return[e].concat(t)},e.prototype.findEllipsisPositionAndReplaceCharsFromRight=function(t,e,r){for(var i=t.length-1,n=i;n>=0;--n){if(i=n,t[n].left+e.width<=r.max[0])break}e.left=t[i].left;for(n=t.length-1;n>=i;--n)t.pop();return t.concat([e])},e.prototype.drawCharsFromLeft=function(t,e){var r=t.textAlign||"left";t.textAlign="left";for(var i=0;i<e.length;++i){var n=e[i];t.fillText(n.char,n.left,n.top)}t.textAlign=r},e.prototype.drawBorders=function(t){this.padding;var e=this.borderWidth;t.strokeStyle=this.borderColor,t.lineWidth=e;var r=this.width,i=this.height,n=0,o=0;"center"===this.originX?n-=this.width/2:"right"===this.originX&&(n-=this.width),"center"===this.originY?o-=this.height/2:"bottom"===this.originY&&(o-=this.height),t.strokeRect(n+e/2,o+e/2,r-e,i-e)},e}(),vs=function(){function t(t,e,r,i,n,o){var s;this.textList=[],s="string"==typeof t?document.getElementById(t):t,this.scaleX=null!=i?i:1,this.scaleY=null!=n?n:1,this.flipY=null!=o&&o,this.width=e,this.height=r,s.style.width="".concat(e*this.scaleX,"px"),s.style.height="".concat(r*this.scaleY,"px");this.devicePixelRatio=1,s.width=1*e*this.scaleX,s.height=1*r*this.scaleY,s.className="lower-canvas",this.renderCanvas=s,this.renderContext=this.renderCanvas.getContext("2d"),this.renderContext.scale(1*this.scaleX,1*this.scaleY)}return t.prototype.initDimension=function(t,e,r,i){this.width=t,this.height=e,this.scaleX=null!=r?r:1,this.scaleY=null!=i?i:1,this.renderCanvas.style.width="".concat(t*this.scaleX,"px"),this.renderCanvas.style.height="".concat(e*this.scaleY,"px");var n=this.devicePixelRatio;this.renderCanvas.width=n*t*this.scaleX,this.renderCanvas.height=n*e*this.scaleY,this.flipY&&(this.renderContext.translate(0,this.height),this.renderContext.scale(1,-1)),this.renderContext.scale(n*this.scaleX,n*this.scaleY)},t.prototype.clearText=function(){this.textList=[]},t.prototype.clearCanvasWithContext=function(t){t.clearRect(0,0,this.width,this.height)},t.prototype.clearCanvas=function(){this.clearCanvasWithContext(this.renderContext)},t.prototype.addObject=function(t){t.init(this),this.textList.push(t)},t.prototype.render=function(){this.clearCanvasWithContext(this.renderContext),this.renderContext.fillStyle="rgba(255, 255, 255, 0.0039)",this.renderContext.fillRect(0,0,this.width,this.height);var t=this.background;t&&void 0!==t.width&&void 0!==t.height&&this.renderContext.drawImage(t,0,0,t.width,t.height,0,0,this.width,this.height);for(var e=0;e<this.textList.length;++e){this.renderContext.save();var r=this.textList[e];r.update(),r.render(),this.renderContext.restore()}},t}();function ys(t,e){return e=e||{},new Promise((function(r,i){var n=new XMLHttpRequest;n.responseType=(null==e?void 0:e.responseType)||"json",n.addEventListener("load",(function(){return r(n.response)})),n.addEventListener("error",(function(){return i(Error("load ".concat(t," fail")))})),n.open((null==e?void 0:e.method)||"get",t),n.send(null==e?void 0:e.data)}))}function gs(t,e,r,i,s){return n(this,void 0,void 0,(function(){var n,a,u,l,c,h,f,p,d,m;return o(this,(function(o){switch(o.label){case 0:return n={},a=[],i=i||{},r=r||{},e.asImage?(u=e.content.replace(/\$/g,""),l=r[u]||e.variables[u],c=function(t){var r=(null==i?void 0:i.canvas)||document.createElement("canvas"),n=r.width=e.backgroundWidth,o=r.height=e.backgroundHeight,a=r.getContext("2d");return null==a||a.clearRect(0,0,n,o),s&&(null==a||a.translate(0,o),null==a||a.scale(1,-1)),null==a||a.drawImage(t,0,0,t.width,t.height,0,0,n,o),r},l?[2,Mr(l).then(c)]:[2,xs(t).then(c)]):(h=i.templateScale||1,Object.keys(e.variables).forEach((function(t){var i=e.variables[t];if(r.hasOwnProperty(t)&&(i=r[t]),/^image_/.test(t)){var o=i instanceof Array,s=o?i[0]:i;a.push(function(t,e){return r(t,(function(i){return e?r(e,(function(){return t})):t}));function r(t,e){return/^(https?:)?\/\//.test(t)?ys(t,{responseType:"blob"}).then(Ts,e):Promise.resolve(t)}}(s,o&&i[1]).then((function(e){return n[t]=e})))}else n[t]=i})),[4,Promise.all(a)]);case 1:return o.sent(),[4,Mr(t)];case 2:return f=o.sent(),p=e.content.replace(/\$([\w_]+)\$/g,(function(t,e){return n[e]})).replace('width="'.concat(e.width,'px"'),'width="'.concat(e.width*h,'px"')).replace('height="'.concat(e.height,'px"'),'height="'.concat(e.height*h,'px"')),[4,Mr("data:image/svg+xml,".concat(encodeURIComponent(p)))];case 3:return d=o.sent(),(m=(null==i?void 0:i.canvas)||document.createElement("canvas")).width=f.width*h,m.height=f.height*h,[2,new Promise((function(t,r){var i=m.getContext("2d");i.clearRect(0,0,m.width,m.height),s&&(i.translate(0,m.height),i.scale(1,-1)),i.drawImage(f,0,0,f.width,f.height,0,0,m.width,m.height),i.drawImage(d,0,0,d.width,d.height,(e.x||0)*h,(e.y||0)*h,e.width*h/e.backgroundWidth*f.width,e.height*h/e.backgroundHeight*f.height),t(m)}))]}}))}))}function xs(t){return ke(t)?Mr(t):Promise.resolve(t)}function Ts(t){return new Promise((function(e,r){var i=new FileReader;i.readAsDataURL(t),i.onload=function(){e(i.result)},i.onerror=r}))}var Es=["serif","sans-serif","monospace","courier"],Ss=800,bs=600,As=new Map,_s=new(function(){function t(){this.elements=[]}return t.prototype.dispose=function(){this.elements.forEach((function(t){return t.remove()})),this.elements=[]},t.prototype.getCanvas=function(){if(this.elements.length)return this.elements.shift();if(di(fi))return window._createOffscreenCanvas(10,10);var t=document.createElement("canvas");return t.getContext("2d",{willReadFrequently:!0}),t},t.prototype.saveCanvas=function(t){t.width=t.height=1,this.elements.length<3?z(this.elements,t):t.remove()},t}());function Cs(t,e){var r,i,n;if(null===(r=null==t?void 0:t.background)||void 0===r?void 0:r.name){var o=t.background.name;e&&e[o]?n=e[o]:(null===(i=t.background)||void 0===i?void 0:i.url)&&(n=t.background.url)}return n}function Rs(e,r,s,a,u){var l;return n(this,void 0,void 0,(function(){var n,c,h,f,p,d,m,v,y,g,x;return o(this,(function(o){switch(o.label){case 0:if(!r)throw Error("image not provided");return n=(null==u?void 0:u.templateScale)||1,c=n,h=n,f=r,p=r.width,d=r.height,s?(p=s.width,d=s.height,r.width===p&&r.height===d||(c*=r.width/s.width,h*=r.height/s.height),(m=Cs(s,a))&&m!==r.src?ke(m)?[4,Mr(m)]:[3,2]:[3,4]):[3,5];case 1:return v=o.sent(),[3,3];case 2:v=m,o.label=3;case 3:f=v,o.label=4;case 4:(y=s.content)&&(g=function(e,r,i){var n=e.fonts,o=[];return e.texts.forEach((function(s){var a,u=s.t,l=s.x,c=s.y,h={weight:400,family:"serif",size:48,style:xt.normal};void 0!==s.f&&(h=n[s.f]);var f=s.n;f&&r&&r.hasOwnProperty(f)&&(u="".concat(r[f]));var p=new ms(u,{left:l,top:c,fontSize:h.size,fontFamily:h.family,fontWeight:"".concat(h.weight),fontStyle:"normal",name:f});if(void 0!==s.r&&(p.angle=s.r*Math.PI/180),p.active=null!==(a=null==i?void 0:i.debug)&&void 0!==a&&a,void 0!==s.w&&(p.width=s.w),void 0!==h.letterSpace&&(p.letterSpacing=h.letterSpace),s.of===mt.display?p.wrap=t.QTextWrapMode.Default:s.of===mt.clip?p.wrap=t.QTextWrapMode.Clip:s.of===mt.ellipsis&&(p.wrap=t.QTextWrapMode.Ellipsis),void 0!==s.c){var d=e.colors[s.c][1],m=1;void 0!==d[3]&&(m=d[3]/255),p.color="rgba(".concat(d[0],", ").concat(d[1],", ").concat(d[2],", ").concat(m,")")}s.a===yt.left?p.textAlign="left":s.a===yt.middle?p.textAlign="center":s.a===yt.right&&(p.textAlign="right"),h.style===xt.normal?p.fontStyle="normal":h.style===xt.italic?p.fontStyle="italic":h.style===xt.oblique&&(p.fontStyle="oblique"),void 0!==h.weight&&(p.fontWeight=String(h.weight)),(null==i?void 0:i.borderColor)&&(p.borderColor=i.borderColor),void 0!==(null==i?void 0:i.borderWidth)&&(p.borderWidth=i.borderWidth),o.push(p)})),o}(y,a,i(i({},u),{scaleX:c,scaleY:h})),g.forEach((function(t){e.addObject(t)}))),o.label=5;case 5:return e.flipY=null!==(l=null==u?void 0:u.flipY)&&void 0!==l&&l,e.initDimension(p,d,c,h),e.background=f,e.render(),(x=null==u?void 0:u.textLayouts)&&(x.length=0,e.textList.forEach((function(t){var e=t.getLayout(),r={x:e.x,y:e.y,width:e.width,height:e.height};x.push(r)}))),[2]}}))}))}function Os(t){return n(this,void 0,void 0,(function(){var e,r,i;return o(this,(function(n){switch(n.label){case 0:if(!t.content||!t.content.fonts)return[3,4];e=t.content.fonts,r=function(t){var r,i,n,s,a;return o(this,(function(o){switch(o.label){case 0:return r=e[t].family,i=e[t].url,n=!1,Es.includes(r)?n=!0:void 0!==document.fonts&&document.fonts.forEach((function(t){t.family===r&&(n=!0)})),n||void 0===i||""===i?[3,2]:(s="url(".concat(i,")"),void 0===document.fonts?[3,2]:[4,(a=new FontFace("".concat(r),s)).load()]);case 1:o.sent(),document.fonts.add(a),o.label=2;case 2:return[2]}}))},i=0,n.label=1;case 1:return i<e.length?[5,r(i)]:[3,4];case 2:n.sent(),n.label=3;case 3:return++i,[3,1];case 4:return[2]}}))}))}function ws(t,e,r,s,a){return n(this,void 0,void 0,(function(){var n,u,l;return o(this,(function(o){switch(o.label){case 0:return n=i(i({},s),{flipY:a}),u=function(t,e,r){var i,n=(null==r?void 0:r.templateScale)||1,o=(null==r?void 0:r.flipY)||!1;if(null==r?void 0:r.canvas){if(!(i=As.get(r.canvas))){var s=new vs(r.canvas,t,e,n,n,o);As.set(r.canvas,s),i=s}}else{var a=_s.getCanvas();i=new vs(a,Ss,bs,n,n,o)}return i}(Ss,Ss,n),void 0===e?[3,2]:[4,Os(e)];case 1:o.sent(),o.label=2;case 2:return u.clearText(),"string"!=typeof t?[3,5]:[4,Mr(t)];case 3:return l=o.sent(),[4,Rs(u,l,e,r,n)];case 4:return o.sent(),[2,u.renderCanvas];case 5:return[4,Rs(u,t,e,r,n)];case 6:return o.sent(),[2,u.renderCanvas]}}))}))}function Ms(t,e,r,i,s){return n(this,void 0,void 0,(function(){return o(this,(function(n){return 2===e.v?[2,ws(t,e,r,{templateScale:null==i?void 0:i.templateScale,toData:!0},s)]:[2,gs(t,e,r,i,s)]}))}))}var Ls=function(){function t(t){this.width=0,this.height=0;var e=t.textHeight,r=void 0===e?100:e,i=t.textWidth,n=void 0===i?100:i,o=t.textOverflow,s=void 0===o?mt.display:o,a=t.textBaseline,u=void 0===a?vt.top:a,l=t.textAlign,c=void 0===l?yt.left:l,h=t.text,f=t.letterSpace,p=void 0===f?0:f,d=t.autoWidth,m=void 0!==d&&d,v=t.fontSize,y=t.lineHeight,g=void 0===y?v:y,x=v+p;this.autoWidth=m,this.maxTextWidth=h.length*x,this.width=n,this.height=r,this.letterSpace=p,this.overFlow=s,this.textBaseline=u,this.textAlign=c,this.lineHeight=g}return t.prototype.getOffsetY=function(t){var e=0,r=(t.fontSize+t.outlineWidth)*t.fontScale;switch(this.textBaseline){case 0:e=r;break;case 1:e=(this.height+r)/2;break;case 2:e=this.height-r/2}return e},t.prototype.getOffsetX=function(t,e){var r=0;switch(this.textAlign){case 0:r=t.outlineWidth*t.fontScale;break;case 1:r=(this.width*t.fontScale-e)/2;break;case 2:r=this.width*t.fontScale-e}return r},t.prototype.setSize=function(t,e){this.width=t,this.height=e},t}(),Is=function(t){function e(e,r,i){var n=t.call(this,e,r,i)||this;n.isDirty=!0;var o=e.options;return n.canvas=_s.getCanvas(),_s.saveCanvas(n.canvas),n.context=n.canvas.getContext("2d",{willReadFrequently:!0}),n.engine=i.composition.getEngine(),n.textStyle=new fs(o),n.textLayout=new Ls(o),n.text=o.text,n.mesh=new hs(n.engine,n.renderInfo,i.composition),n}return r(e,t),e.prototype.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.prototype.setFontWeight=function(t){this.textStyle.textWeight!==t&&(this.textStyle.textWeight=t,this.isDirty=!0)},e.prototype.setFontStyle=function(t){this.textStyle.fontStyle!==t&&(this.textStyle.fontStyle=t,this.isDirty=!0)},e.prototype.setText=function(t){this.text!==t&&(this.text=t,this.isDirty=!0)},e.prototype.setTextAlign=function(t){this.textLayout.textAlign!==t&&(this.textLayout.textAlign=t,this.isDirty=!0)},e.prototype.setTextBaseline=function(t){this.textLayout.textBaseline!==t&&(this.textLayout.textBaseline=t,this.isDirty=!0)},e.prototype.setTextColor=function(t){this.textStyle.textColor!==t&&(this.textStyle.textColor=t,this.isDirty=!0)},e.prototype.setFontFamily=function(t){this.textStyle.fontFamily!==t&&(this.textStyle.fontFamily=t,this.isDirty=!0)},e.prototype.setOutlineColor=function(t){this.textStyle.outlineColor!==t&&(this.textStyle.outlineColor=t,this.isDirty=!0)},e.prototype.setOutlineWidth=function(t){this.textStyle.outlineWidth!==t&&(this.textStyle.outlineWidth=t,this.isDirty=!0)},e.prototype.setShadowBlur=function(t){this.textStyle.shadowBlur!==t&&(this.textStyle.shadowBlur=t,this.isDirty=!0)},e.prototype.setShadowColor=function(t){this.textStyle.shadowColor!==t&&(this.textStyle.shadowColor=t,this.isDirty=!0)},e.prototype.setShadowOffsetX=function(t){this.textStyle.shadowOffsetX!==t&&(this.textStyle.shadowOffsetX=t,this.isDirty=!0)},e.prototype.setShadowOffsetY=function(t){this.textStyle.shadowOffsetY!==t&&(this.textStyle.shadowOffsetY=t,this.isDirty=!0)},e.prototype.setFontScale=function(t){this.textStyle.fontScale!==t&&(this.textStyle.fontScale=t,this.isDirty=!0)},e.prototype.updateTexture=function(){var t;if(this.isDirty&&this.context&&this.canvas){var e=this.context,r=this.textStyle,i=this.textLayout,n=r.fontScale,o=(i.width+r.fontOffset)*n,s=i.height*n,a=r.fontSize*n,u=i.lineHeight*n;this.char=(this.text||"").split(""),this.canvas.width=o,this.canvas.height=s,e.clearRect(0,0,o,this.canvas.height),e.fillStyle="rgba(255, 255, 255, 0.0039)",e.fillRect(0,0,o,this.canvas.height),r.fontDesc=this.getFontDesc(),e.font=r.fontDesc,r.hasShadow&&this.setupShadow(),r.isOutlined&&this.setupOutline(),e.fillStyle="rgba(".concat(r.textColor[0],", ").concat(r.textColor[1],", ").concat(r.textColor[2],", ").concat(r.textColor[3],")");for(var l=[],c=(u-a)/3,h=0,f=i.getOffsetY(r)+c,p=[],d=[],m=0;m<this.char.length;m++){var y=this.char[m],g=e.measureText(y);((h+=i.letterSpace*n)+g.width>o&&m>0||"\n"===y)&&(l.push({y:f,width:h,chars:p,charOffsetX:d}),h=0,f+=u,p=[],d=[]),"\n"!==y&&(p.push(y),d.push(h),h+=g.width)}l.push({y:f,width:h,chars:p,charOffsetX:d}),l.forEach((function(t){var n=i.getOffsetX(r,t.width);t.chars.forEach((function(i,o){r.isOutlined&&e.strokeText(i,n+t.charOffsetX[o],t.y),e.fillText(i,n+t.charOffsetX[o],t.y)}))})),r.hasShadow&&(e.shadowColor="transparent");var x=e.getImageData(0,0,this.canvas.width,this.canvas.height);null===(t=this.mesh)||void 0===t||t.mesh.material.setTexture("uSampler0",Vr.createWithData(this.engine,{data:new Uint8Array(x.data),width:x.width,height:x.height},{flipY:!0,magFilter:v.LINEAR,minFilter:v.LINEAR,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE})),this.isDirty=!1}},e.prototype.getFontDesc=function(){var t=this.textStyle,e="".concat((t.fontSize*t.fontScale).toString(),"px ");return Es.includes(t.fontFamily)?e+=t.fontFamily:e+='"'.concat(t.fontFamily,'"'),t.textWeight!==gt.normal&&(e="".concat(t.textWeight," ").concat(e)),t.fontStyle!==xt.normal&&(e="".concat(t.fontStyle," ").concat(e)),e},e.prototype.setupOutline=function(){var t=this.context,e=this.textStyle;t.strokeStyle="rgba(".concat(255*e.outlineColor[0],", ").concat(255*e.outlineColor[1],", ").concat(255*e.outlineColor[2],", ").concat(e.outlineColor[3],")"),t.lineWidth=2*e.outlineWidth},e.prototype.setupShadow=function(){var t=this.context,e=this.textStyle;t.shadowColor="rgba(".concat(255*e.shadowColor[0],", ").concat(255*e.shadowColor[1],", ").concat(255*e.shadowColor[2],", ").concat(e.shadowColor[3],")"),t.shadowBlur=e.shadowBlur,t.shadowOffsetX=e.shadowOffsetX,t.shadowOffsetY=-e.shadowOffsetY},e}(Nn),Ps=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.text},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){this.textContext=t.content},n.prototype.onLifetimeBegin=function(t,e){var r,i;e.active=!0,null===(i=null===(r=this.content)||void 0===r?void 0:r.mesh)||void 0===i||i.setItems([this.content]),this.content.updateTexture()},n.prototype.onItemRemoved=function(t,e){e&&(delete e.mesh,t.destroyTextures(e.getTextures()))},n.prototype.onItemUpdate=function(t,e){var r;this.content&&(null===(r=this.content)||void 0===r||r.updateTime(this.time))},n.prototype.getCurrentPosition=function(){var t=new Mt;return this.transform.assignWorldTRS(t),t},n.prototype.getBoundingBox=function(){var e=this.content;if(e&&this.transform){var r=this.transform.getWorldMatrix(),i=e.startSize,n=le(Mt.ZERO,i.x/2,i.y/2);return n.forEach((function(t){r.transformPoint(t.p0),r.transformPoint(t.p1),r.transformPoint(t.p2)})),{type:t.HitTestType.triangle,area:n}}},n.prototype.getHitTestParams=function(t){var e,r,i=this.content,n=i&&i.interaction;if((t||n)&&(null===(e=i.mesh)||void 0===e?void 0:e.mesh)&&i){var o=this.getBoundingBox();if(o)return{behavior:(null===(r=i.interaction)||void 0===r?void 0:r.behavior)||0,type:o.type,triangles:o.area,backfaceCulling:i.renderer.side===b.FRONT}}},n.prototype.getRenderData=function(){return this.content.getRenderData(this.content.time)},n.prototype.doCreateContent=function(t){var e=t.getRendererOptions().emptyTexture;return new Is(this.textContext,{emptyTexture:e},this)},n.prototype.createWireframeMesh=function(t,e){var r=new hs(this.composition.getEngine(),i({wireframe:!0},t.renderInfo),this.composition);return r.mesh.setVisible(!0),r.setItems([t]),r.mesh.material.setVector3("uFrameColor",Mt.fromArray(e)),r.mesh.priority=999,r},n}(Qe),Fs=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="text",t.addItems=[],t.removeItems=[],t.meshes=[],t}return r(i,e),i.prototype.onCompositionDestroyed=function(e){e.reusable?this.addItems.forEach((function(e){var r;null===(r=e.content.mesh)||void 0===r||r.mesh.dispose({material:{textures:t.DestroyOptions.keep}})})):this.addItems.forEach((function(t){var e;null===(e=t.content.mesh)||void 0===e||e.mesh.dispose()}))},i.prototype.onCompositionUpdate=function(t,e){this.addItems.forEach((function(t){var e,r,i;t.contentVisible?(null===(r=t.content.mesh)||void 0===r||r.mesh.setVisible(!0),t.content.updateTexture(),!t.content.ended&&t.content.mesh&&(t.content.mesh.updateItem(t.content),null===(i=t.content.mesh)||void 0===i||i.applyChange())):null===(e=t.content.mesh)||void 0===e||e.mesh.setVisible(!1)}))},i.prototype.onCompositionItemLifeBegin=function(t,e){var r;e instanceof Ps&&e.content&&(this.addItems.includes(e)||(z(this.addItems,e),!e.content.ended&&e.content.mesh&&e.content.mesh.updateItem(e.content),null===(r=e.content.mesh)||void 0===r||r.applyChange()))},i.prototype.onCompositionReset=function(t,e){},i.prototype.onCompositionItemRemoved=function(e,r){var i;r instanceof Ps&&r&&(z(this.removeItems,r),this.addItems.includes(r)&&(null===(i=r.content)||void 0===i?void 0:i.mesh)&&(B(this.addItems,r),r.content.mesh.mesh.dispose({material:{textures:t.DestroyOptions.keep}}),r.dispose()))},i.prototype.prepareRenderFrame=function(e,r){var i=this;return this.removeItems.map((function(e){var n,o;(null===(n=e.content)||void 0===n?void 0:n.mesh)&&(r.removeMeshFromDefaultRenderPass(null===(o=e.content.mesh)||void 0===o?void 0:o.mesh),B(i.addItems,e),e.content.mesh.mesh.dispose({material:{textures:t.DestroyOptions.keep}}),e.dispose())})),this.addItems.forEach((function(t){var e;t.content.mesh&&r.addMeshToDefaultRenderPass(null===(e=t.content.mesh)||void 0===e?void 0:e.mesh)})),this.removeItems.length=0,!1},i}(sr);function Ns(t,e,r){return function(t,e,r){var n=i(i({},e.material.props),{shader:r}),o=e.material.clone(n);return o.blending=!1,o.depthTest=!1,o.culling=!1,gi.create(t,{geometry:e.geometry,material:o})}(t,e,Sn(t.gpuCapability.level,{fragment:r.fragment},{ignoreBlend:!0}))}var Vs=function(e){function i(t,r,i,n,o,s){var a=e.call(this,t,s)||this;return a.uTexStep=i,a.pluginSystem=n,a.fragShader=o,a.type=r,a}return r(i,e),i.prototype.configure=function(e){if(this.prePassTexture=e.getFrameBuffer().getColorTextures()[0]?e.getFrameBuffer().getColorTextures()[0]:e.renderingData.currentFrame.transparentTexture,"H"===this.type&&(this.preDefaultPassAttachment.texture=this.prePassTexture),this.preDefaultPassTexture=this.preDefaultPassAttachment.texture,!this.mframeBuffer){var r=Vr.create(e.engine,{sourceType:t.TextureSourceType.framebuffer,minFilter:v.LINEAR,magFilter:v.LINEAR,name:this.type,internalFormat:v.RGBA,format:v.RGBA,type:v.UNSIGNED_BYTE});this.mframeBuffer=cn.create({name:this.type,storeAction:{},viewport:this.viewport,viewportScale:1,isCustomViewport:!0,attachments:[r],depthStencilAttachment:{storageType:t.RenderPassAttachmentStorageType.none}},e)}e.setFrameBuffer(this.mframeBuffer)},i.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.preDefaultPassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.preDefaultPassTexture)),this.meshes[1].material.setVector2("uTexStep",this.uTexStep),this.meshes[1].material.setTexture("uBlurSource",this.uBlurSource?this.uBlurSource:this.prePassTexture),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassTexture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture));var e=[this.meshes[0],Ns(t.engine,this.meshes[1],{fragment:this.fragShader})];t.renderMeshes(e)},i.prototype.dispose=function(t){e.prototype.dispose.call(this,t);var r=this.mframeBuffer;r&&r.dispose(t)},i}(bi),Ds=function(t){function e(e,r,i){var n=t.call(this,e,r)||this;return i&&(n.preDefaultPassAttachment=i),n}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],this.preDefaultPassAttachment||(this.preDefaultPassAttachment=new Ei(t.engine,{}),this.preDefaultPassAttachment.texture=this.prePassTexture),t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.preDefaultPassAttachment.texture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.preDefaultPassAttachment.texture)),this.meshes[1].material.setTexture("uFrameSource",this.prePassTexture),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassAttachment.texture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture));var e=[this.meshes[0],this.meshes[1]];t.renderMeshes(e)},e}(bi);function zs(t){for(var e=t.radius<=3?1:2,r=t.radius/e,i=t.maxStep||4;r>10&&e<i;)e*=2,r=t.radius/e;for(var n=1+t.radius%e/e/e,o=function(t){for(var e=(t+1)/3.329,r=[],i=-t;i<=t;i++)r.push(Bs(i,e));return r}(r=Math.floor(r)),s=[],a=-r;a<=r;a++){var u=o[a+r];s.push("color += texture2D(uBlurSource,getTexCoord(".concat(a.toFixed(1),")) * ").concat(u,";"))}return{shader:"\n uniform sampler2D uBlurSource;\n uniform vec2 uTexSize;\n uniform vec2 uTexStep;\n #define getTexCoord(i) coord + uTexStep/uTexSize * i\n vec4 filterMain(vec2 coord,sampler2D tex){\n vec4 color = vec4(0.);\n vec2 texCoord;\n ".concat(s.join("\n"),"\n\n return color;\n }\n "),step:n,downSample:e,radius:r}}function Bs(t,e){return Math.exp(-t*t/(2*e*e))/Math.sqrt(2*Math.PI)/e}var Us=function(t){function e(e,r){return t.call(this,e,r)||this}return r(e,t),e.prototype.configure=function(t){var e=t.getFrameBuffer();this.preDefaultPassAttachment.texture=e?e.getColorTextures()[0]:t.renderingData.currentFrame.transparentTexture,t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassAttachment.texture),this.meshes[1].material.setVector2("uTexSize",Ji(this.preDefaultPassAttachment.texture));var e=[Ns(t.engine,this.meshes[1],{fragment:this.fragShader})];t.renderMeshes(e)},e}(bi),ks=function(t){function e(e,r,i,n,o,s,a){var u=t.call(this,e,s)||this;return u.uTexStep=i,u.pluginSystem=n,u.fragShader=o,u.type=r,a&&(u.uBlurSource=a),u}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],this.preDefaultPassTexture=this.preDefaultPassAttachment.texture,t.setFrameBuffer(this.frameBuffer),this.uBlurSource||(this.uBlurSource=this.prePassTexture)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[1].material.setVector2("uTexStep",this.uTexStep),this.meshes[1].material.setTexture("uBlurSource",this.uBlurSource),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassTexture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),this.meshes[1].material.setVector2("uTexSize",Ji(this.uBlurSource));var e=[Ns(t.engine,this.meshes[1],{fragment:this.fragShader})];t.renderMeshes(e)},e}(bi),Gs=function(t){function e(e,r,i){var n=t.call(this,e,r)||this;return n.preDefaultPassAttachment=i,n}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.preDefaultPassAttachment.texture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.preDefaultPassAttachment.texture)),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.preDefaultPassAttachment.texture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),this.meshes[1].material.setVector2("uTexSize",Ji(this.preDefaultPassAttachment.texture));var e=[this.meshes[0],this.meshes[1]];t.renderMeshes(e)},e}(bi),Xs=function(t){function e(e,r){return t.call(this,e,r)||this}return r(e,t),e.prototype.configure=function(t){this.prePassTexture=t.getFrameBuffer().getColorTextures()[0],t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){t.clear(this.clearAction),this.meshes[0].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[0].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture)),this.meshes[1].material.setTexture("uFilterSource",this.prePassTexture),this.meshes[1].material.setTexture("uSamplerPre",this.prePassTexture),this.meshes[1].material.setVector2("uFilterSourceSize",Ji(this.prePassTexture));var e=[this.meshes[0],this.meshes[1]];t.renderMeshes(e)},e}(bi);function Hs(t,e,r){for(var i=be(e||1),n=e?256:1,o=new Uint8Array(n),s=0;s<n;s++){var a=s/(n-1);o[s]=Math.round(255*i.getValue(r?1-a:a))}return Vr.createWithData(t,{width:n,height:1,data:o},{format:v.LUMINANCE})}var Ys=new Mt(1,1,1),js=function(){function t(t,e){void 0===e&&(e={}),this.name=t,this.viewMatrix=Ft.fromIdentity(),this.projectionMatrix=Ft.fromIdentity(),this.viewProjectionMatrix=Ft.fromIdentity(),this.inverseViewMatrix=Ft.fromIdentity(),this.dirty=!0;var r=e.near,i=void 0===r?.1:r,n=e.far,o=void 0===n?20:n,s=e.fov,a=void 0===s?60:s,u=e.aspect,l=void 0===u?1:u,c=e.clipMode,h=void 0===c?it.portrait:c,f=e.position,p=void 0===f?[0,0,8]:f,d=e.rotation,m=void 0===d?[0,0,0]:d;this.options={near:i,far:o,fov:a,aspect:l,clipMode:h,position:Mt.fromArray(p),rotation:Dt.fromArray(m)},this.dirty=!0,this.updateMatrix()}return Object.defineProperty(t.prototype,"near",{get:function(){return this.options.near},set:function(t){this.options.near!==t&&(this.options.near=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"far",{get:function(){return this.options.far},set:function(t){this.options.far!==t&&(this.options.far=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fov",{get:function(){return this.options.fov},set:function(t){this.options.fov!==t&&(this.options.fov=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"aspect",{get:function(){return this.options.aspect},set:function(t){this.options.aspect!==t&&(this.options.aspect=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clipMode",{get:function(){return this.options.clipMode},set:function(t){void 0!==t&&this.options.clipMode!==t&&(this.options.clipMode=t,this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this.options.position.clone()},set:function(t){this.options.position.equals(t)||(this.options.position.copyFrom(t),this.dirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.options.rotation.clone()},set:function(t){this.options.rotation.equals(t)||(this.options.rotation.copyFrom(t),this.dirty=!0,this.options.quat=void 0)},enumerable:!1,configurable:!0}),t.prototype.getViewMatrix=function(){return this.updateMatrix(),this.viewMatrix.clone()},t.prototype.getInverseViewMatrix=function(){return this.updateMatrix(),this.inverseViewMatrix.clone()},t.prototype.getProjectionMatrix=function(){return this.updateMatrix(),this.projectionMatrix.clone()},t.prototype.getInverseProjectionMatrix=function(){var t;return this.updateMatrix(),null===(t=this.inverseProjectionMatrix)||void 0===t?void 0:t.clone()},t.prototype.getViewProjectionMatrix=function(){return this.updateMatrix(),this.viewProjectionMatrix.clone()},t.prototype.getInverseViewProjectionMatrix=function(){return this.updateMatrix(),this.inverseViewProjectionMatrix||(this.inverseViewProjectionMatrix=this.viewProjectionMatrix.clone(),this.inverseViewProjectionMatrix.invert()),this.inverseViewProjectionMatrix.clone()},t.prototype.getModelViewProjection=function(t,e){return t.multiplyMatrices(this.viewProjectionMatrix,e)},t.prototype.getInverseVPRatio=function(t){var e=new Mt(0,0,t),r=this.getViewProjectionMatrix(),i=this.getInverseViewProjectionMatrix(),n=r.projectPoint(e).z;return i.projectPoint(new Mt(1,1,n))},t.prototype.setQuat=function(t){void 0===this.options.quat?(this.options.quat=t.clone(),this.dirty=!0):this.options.quat.equals(t)||(this.options.quat.copyFrom(t),this.dirty=!0),this.dirty&&this.setRotationByQuat(t)},t.prototype.getQuat=function(){var t=this.options.quat;if(void 0===t){t=new Lt;var e=this.options.rotation;e&&t.setFromEuler(e),this.options.quat=t}return t},t.prototype.getOptions=function(){return this.options},t.prototype.copy=function(t){var e=t.near,r=t.far,i=t.fov,n=t.clipMode,o=t.aspect,s=t.position,a=t.rotation;this.near=e,this.far=r,this.fov=i,this.clipMode=n,this.aspect=o,this.position=s,this.rotation=a,this.updateMatrix()},t.prototype.updateMatrix=function(){if(this.dirty){var t=this.options,e=t.fov,r=t.aspect,i=t.near,n=t.far,o=t.clipMode,s=t.position;this.projectionMatrix.perspective(e*St,r,i,n,o===it.portrait),this.inverseViewMatrix.compose(s,this.getQuat(),Ys),this.viewMatrix.copyFrom(this.inverseViewMatrix).invert(),this.viewProjectionMatrix.multiplyMatrices(this.projectionMatrix,this.viewMatrix),this.inverseViewProjectionMatrix=null,this.dirty=!1}},t.prototype.setRotationByQuat=function(t){Ke.getRotation(t,this.options.rotation)},t}();var Ws,Zs,qs,Ks,Qs,Js,$s,ta,ea,ra,ia,na={lum:[function(e,r){var i=r.renderer,n=2===i.engine.gpuCapability.level?v.LINEAR:v.NEAREST,o=new Ds(i,{name:"lumCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:n,magFilter:n}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{fragment:Kr,uniformValues:{uFilterParams:[1,0,0,0]},materialStates:{blending:!1,depthTest:!1,culling:!1}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}]},prePasses:[o],renderPassDelegate:{}}},function(){return[{fragment:Kr}]}],alphaFrame:[function(e,r){var i=e,n=i.colorRange,o=void 0===n?[.5,1]:n,s=i.alphaRange,a=void 0===s?[0,.5]:s,u=[a[0],a[1]-a[0],o[0],o[1]-o[0]],l=r.renderer,c=2===l.engine.gpuCapability.level?v.LINEAR:v.NEAREST,h=new Ds(l,{name:"alphaFrameCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:c,magFilter:c}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{particle:{fragment:Mi,uniformValues:{uTexRange:u}},mesh:{fragment:Mi,shaderCacheId:"alpha-frame",materialStates:{blending:!1},uniformValues:{uTexRange:u}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[h]}}},function(){return[{fragment:Mi,shaderCacheId:"alpha-frame"},{fragment:Mi,isParticle:!0}]}],cameraMove:[function(e,r){var i=e.position,n=void 0===i?[0,0,0]:i,o=n;Number.isFinite(n[0])&&Number.isFinite(n[1])&&(o=[ot.CONSTANT_VEC3,n]);var s=be(o),a=new js("camera_move"),u=new Mt,l=r.renderer,c=2===l.engine.gpuCapability.level?v.LINEAR:v.NEAREST,h=new Ds(l,{name:"cameraCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:c,magFilter:c}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{vertex:Ii,fragment:Kr,shaderCacheId:"camera-move",materialStates:{blending:!1,depthTest:!1,culling:!1},variables:{uMoveCameraViewPro:function(t){a.copy(r.camera);var e=s.getValue(t);return u.addVectors(r.camera.position,new Mt(-e[0],-e[1],-e[2])),a.position=u,a.getViewProjectionMatrix().toArray()}}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[h]}}},function(){return[{vertex:Ii,fragment:Kr,shaderCacheId:"camera-move"}]}],alphaMask:[function(e,r){var i=e,n=i.xOpacity,o=i.yOpacity,s=r.renderer.engine,a=r.renderer,u=Hs(s,n),l=Hs(s,o,!0),c=2===s.gpuCapability.level?v.LINEAR:v.NEAREST,h=new Ds(a,{name:"alphaMaskCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:c,magFilter:c}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{fragment:Li,shaderCacheId:"alpha-mask",materialStates:{blending:!1,depthTest:!1,culling:!1},uniformValues:{uAlphaXSample:u,uAlphaYSample:l}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[h]}}},function(){return[{fragment:Li,shaderCacheId:"alpha-mask"}]}],distortion:[function(e,r){var i=e,n=i.center,o=void 0===n?[.5,.5]:n,s=i.direction,a=void 0===s?[1,0]:s,u=i.period,l=i.waveMovement,c=i.strength,h=re(a),f=[o[0],o[1],h[0],h[1]],p=be(u),d=be(l),m=be(c),y=2*Math.PI,g=r.renderer,x=2===g.engine.gpuCapability.level?v.LINEAR:v.NEAREST,T=new Ds(g,{name:"distortionCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:x,magFilter:x}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{particle:{fragment:Fi,vertex:Ni,uniforms:{uPeriodValue:p,uMovementValue:d,uStrengthValue:m},uniformValues:{uWaveParams:f}},mesh:{shaderCacheId:"distortion",fragment:Fi,materialStates:{blending:!1,culling:!1},variables:{vWaveParams:function(t){return[p.getValue(t)*y,d.getValue(t)*y,m.getValue(t),0]}},uniformValues:{uWaveParams:f}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[T]}}},function(t){var e=t,r=e.period,i=e.waveMovement,n=e.strength;return[{fragment:Fi,shaderCacheId:"distortion"},{fragment:Fi,vertex:Ni,isParticle:!0,uniforms:[r,i,n]}]}],bloom:[function(e,r){var i=e,n=i.radius,o=void 0===n?30:n,s=i.bloomAddon,a=void 0===s?.4:s,u=i.colorAddon,l=void 0===u?1:u,c=i.colorThreshold,h=void 0===c?[255,255,255]:c,f=r.getEngine().gpuCapability.level,p=zs({radius:o}),d=r.renderer.engine,m=r.renderer,y=Math.round(r.width/p.downSample),g=Math.round(r.width/p.downSample);1===f&&(y=ae(y),g=ae(g));var x=[0,0,y,g],T=r.renderFrame.passTextureCache.requestColorAttachmentTexture({format:v.RGBA,magFilter:v.LINEAR,minFilter:v.LINEAR,name:"gaussianV",width:y,height:g}),E=r.renderFrame.passTextureCache.requestColorAttachmentTexture({format:v.RGBA,magFilter:v.LINEAR,minFilter:v.LINEAR,name:"gaussianH",width:y,height:g}),S=be(a),b=be(l),A=new Ei(d),_=new Us(m,{name:"threshold",attachments:[{texture:T}],viewport:x,clearAction:{colorAction:t.TextureLoadAction.clear}});_.pluginSystem=r.pluginSystem,_.fragShader=Di,_.preDefaultPassAttachment=A;var C=new ks(m,"H",new wt(p.step,0),r.pluginSystem,p.shader,{name:"gaussianH",viewport:x,attachments:[{texture:E}],clearAction:{colorAction:t.TextureLoadAction.clear}},T);C.preDefaultPassAttachment=A;var R=new ks(m,"V",new wt(0,p.step),r.pluginSystem,p.shader,{name:"gaussianV",viewport:x,attachments:[{texture:T}]},E);R.preDefaultPassAttachment=A;var O=2===f?v.LINEAR:v.NEAREST,w=new Gs(m,{name:"bloomCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:O,magFilter:O}}],clearAction:{colorAction:t.TextureLoadAction.clear}},A);return{mesh:{name:"bloom-".concat(p.step),fragment:Vi,shaderCacheId:"bloom-".concat(p.step),variables:{uBloomParams:function(t){return[S.getValue(t),b.getValue(t),0,1]}},uniformValues:{uColorThreshold:[h[0]/255||1.1,h[1]/255||1.1,h[2]/255||1.1,0],uBloomBlur:T},materialStates:{blending:!1,culling:!1}},onItemRemoved:function(){T.dispose(),E.dispose()},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[_,C,R,w]}}},function(t){var e=t.radius,r=zs({radius:void 0===e?30:e});return[{fragment:Vi,shaderCacheId:"bloom-".concat(r.step)},{fragment:Di,ignoreBlend:!0},{fragment:r.shader,ignoreBlend:!0}]}],gaussian:[function(e,r){var i=e.radius,n=r.getEngine().gpuCapability.level,o=r.renderer.engine,s=r.renderer,a=zs({radius:i}),u=a.downSample,l=a.step,c=a.shader,h=Math.round(r.width/u),f=Math.round(r.height/u);1===n&&(f=ae(f),h=ae(h));var p=[0,0,h,f],d=r.renderFrame.passTextureCache.requestColorAttachmentTexture({minFilter:v.LINEAR,magFilter:v.LINEAR,name:"gaussianV",width:h,height:f}),m=r.renderFrame.passTextureCache.requestColorAttachmentTexture({minFilter:v.LINEAR,magFilter:v.LINEAR,name:"gaussianH",width:h,height:f}),y=new Ei(o,{}),g=new Vs(s,"H",new wt(0,l),r.pluginSystem,c,{name:"gaussianH",viewport:p,attachments:[{texture:m}],clearAction:{colorAction:t.TextureLoadAction.clear}});g.preDefaultPassAttachment=y;var x=new Vs(s,"V",new wt(l,0),r.pluginSystem,c,{name:"gaussianV",viewport:p,attachments:[{texture:d}],clearAction:{colorAction:t.TextureLoadAction.clear}});x.preDefaultPassAttachment=y;var T=2===n?v.LINEAR:v.NEAREST,E=new Ds(s,{name:"gaussianCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:T,magFilter:T}}],clearAction:{colorAction:t.TextureLoadAction.clear}},y);return E.preDefaultPassAttachment=y,{mesh:{fragment:Kr,shaderCacheId:"gaussian-".concat(l),uniformValues:{uTexSize:[h,f]},materialStates:{blending:!1,culling:!1}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[g,x,E]}}},function(t){var e=zs({radius:t.radius});return[{fragment:Kr,shaderCacheId:"gaussian-".concat(e.step)},{fragment:e.shader,ignoreBlend:!0}]}],delay:[function(e,r){var i=r.renderer,n=Vr.create(i.engine,{sourceType:t.TextureSourceType.framebuffer}),o=[0,.96,0,0],s=2===i.engine.gpuCapability.level?v.LINEAR:v.NEAREST,a=new Xs(i,{name:"delayCopyPass",attachments:[{texture:{format:v.RGBA,minFilter:s,magFilter:s}}],clearAction:{colorAction:t.TextureLoadAction.clear}});return{mesh:{fragment:Pi,shaderCacheId:"delay",uniformValues:{uLastSource:n},variables:{uParams:function(){return o}},materialStates:{blending:!0,blendFunction:[v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA,v.SRC_ALPHA,v.ONE_MINUS_SRC_ALPHA],depthTest:!1,culling:!1}},passSplitOptions:{attachments:[{texture:{format:v.RGBA}}],prePasses:[a]},onItemRemoved:function(){n.dispose()},renderPassDelegate:{didEndRenderPass:function(t){i.extension.copyTexture(t.attachments[0].texture,n),o[0]=2}}}},function(){return[{fragment:Pi,shaderCacheId:"delay"}]}]};
|
|
9
9
|
/*!
|
|
10
10
|
* Name: @galacean/effects-specification
|
|
11
11
|
* Description: Galacean Effects JSON Specification
|
|
12
12
|
* Author: Ant Group CO., Ltd.
|
|
13
13
|
* Version: v1.0.1
|
|
14
|
-
*/!function(t){t.S="S",t.APlus="A+",t.A="A",t.BPlus="B+",t.B="B"}(Ws||(Ws={})),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"}(Zs||(Zs={})),function(t){t[t.DOUBLE=1032]="DOUBLE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK"}(qs||(qs={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(Ks||(Ks={})),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"}(Qs||(Qs={})),function(t){t[t.GYROSCOPE=0]="GYROSCOPE",t[t.SPINE=1]="SPINE"}(Js||(Js={})),function(t){t[t.CLICK=0]="CLICK",t[t.MESSAGE=1]="MESSAGE",t[t.DRAG=2]="DRAG"}($s||($s={})),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"}(ta||(ta={})),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.filter="8",t.spine="spine",t.mesh="mesh",t.tree="tree",t.text="text",t.light="light",t.skybox="skybox"}(ea||(ea={})),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"}(ra||(ra={})),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"}(ia||(ia={}));var oa,sa,aa,ua,la,ca,ha,fa,pa,da,ma,va,ya,ga,xa,Ta,Ea,Sa=0;!function(t){t[t.portrait=1]="portrait",t[t.landscape=Sa]="landscape"}(oa||(oa={})),function(t){t[t.destroy=0]="destroy",t[t.pause=1]="pause",t[t.restart=5]="restart",t[t.forward=2]="forward",t[t.pause_destroy=3]="pause_destroy"}(sa||(sa={})),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"}(aa||(aa={})),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"}(ua||(ua={})),function(t){t[t.destroy=0]="destroy",t[t.loop=5]="loop",t[t.freeze=4]="freeze"}(la||(la={})),function(t){t[t.destroyChildren=6]="destroyChildren"}(ca||(ca={})),function(t){t[t.none=0]="none",t[t.removeParticle=1]="removeParticle"}(ha||(ha={})),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"}(fa||(fa={})),function(t){t[t.box=2]="box",t[t.sphere=3]="sphere"}(pa||(pa={})),function(t){t.unlit="unlit",t.pbr="pbr",t.hair="hair"}(da||(da={})),function(t){t[t.opaque=100]="opaque",t[t.masked=101]="masked",t[t.translucent=102]="translucent",t[t.additive=103]="additive"}(ma||(ma={})),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"}(va||(va={})),function(t){t[t.display=0]="display",t[t.clip=1]="clip",t[t.ellipsis=2]="ellipsis"}(ya||(ya={})),function(t){t[t.top=0]="top",t[t.middle=1]="middle",t[t.bottom=2]="bottom"}(ga||(ga={})),function(t){t[t.left=0]="left",t[t.middle=1]="middle",t[t.right=2]="right"}(xa||(xa={})),function(t){t.normal="normal",t.bold="bold",t.lighter="lighter"}(Ta||(Ta={})),function(t){t.normal="normal",t.italic="italic",t.oblique="oblique"}(Ea||(Ea={}));var ba=function(){return ba=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},ba.apply(this,arguments)};function Aa(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _a(t,e){if(!t.includes(e))return t.push(e),!0}function Ca(t,e,r){if(t)for(var i in t)Object.hasOwnProperty.call(t,i)&&e.call(r,t[i],i);return t}function Ra(t){if(Number.isFinite(t))return[aa.CONSTANT,t];if(t){if("lines"===t[0])return[aa.LINE,t[1]];if("curve"===t[0])return[aa.CURVE,t[1]];if("static"===t[0])return[aa.CONSTANT,t[1]]}}function Oa(t,e){return Array.isArray(t)&&"random"===t[0]?[aa.CONSTANT,t[1][e]]:Ra(t)}function wa(t){return t&&"color"===t[0]?Pa(t[1],!0):[1,1,1,1]}function Ma(t,e){if(t){if("colors"===t[0])return[aa.COLORS,t[1].map((function(t){return Pa(t,e)}))];if("gradient"===t[0])return Ia(t[1],e);if("color"===t[0])return[aa.RGBA_COLOR,Pa(t[1],e)]}}function La(t){return t&&"random"===t[0]?[aa.RANDOM,t[1]]:Ra(t)}function Ia(t,e){if(t){var r=[];return Object.getOwnPropertyNames(t).forEach((function(i){var n=function(t){var e=/^(-)?([\d+.]+)%$/.exec(t);if(e)return+e[2]/100*(e[1]?-1:1);return+t}(i),o=Pa(t[i],e);r.push([n,o[0],o[1],o[2],o[3]])})),r=r.sort((function(t,e){return t[0]-e[0]})),[aa.GRADIENT_COLOR,r]}}function Pa(t,e){var r;if("string"==typeof t){t=t.replace(/[\s\t\r\n]/g,"");var i=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(i){var n=+i[4];r=[+i[1],+i[2],+i[3],isNaN(n)?255:Math.round(255*n)]}else/^#[a-f\d]{3}$/i.test(t)?r=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(r=[parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16),255]||[0,0,0,255])}else t instanceof Array&&(r=[t[0],t[1],t[2],isNaN(t[3])?255:Math.round(255*t[3])]);return e&&(r=function(t){if(Array.isArray(t))return t.map((function(t){return Number.isFinite(t/255)?Number((t/255).toFixed(6)):0}))}(r)),r}function Fa(t,e){return Array.isArray(t)?("gradient"===t[0]||"color"===t[0])&&Ia(t[1],e):Ia(t,e)}function Na(t){if(t){if(3===t.length)return[aa.CONSTANT_VEC3,t];if("path"===t[0])return[aa.LINEAR_PATH,t[1]];if("bezier"===t[0])return[aa.BEZIER_PATH,t[1]]}}function Va(t){var e,r;try{for(var i=Aa(Object.keys(t)),n=i.next();!n.done;n=i.next()){var o=n.value;t[o]=Number(t[o])}}catch(t){e={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return t}function Da(t){var e,r;try{for(var i=Aa(Object.keys(t)),n=i.next();!n.done;n=i.next()){var o=n.value;void 0===t[o]&&delete t[o]}}catch(t){e={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return t}"function"==typeof SuppressedError&&SuppressedError;var za=Math.cos,Ba=Math.sin,Ua=Math.PI/180,ka=180/Math.PI;function Ga(t){var e,r=t.options,i=t.transform,n={type:Qs.NONE};if(t.shape){var o=null===(e=t.shape.shape)||void 0===e?void 0:e.replace(/([A-Z])/g,"_$1").toUpperCase().replace(/^_/,"");if(n=ba(ba({},t.shape),{type:Qs[o]}),t.shape.upDirection){var s=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}(t.shape.upDirection,3),a=s[0],u=s[1],l=s[2];0===a&&0===u&&0===l&&delete n.upDirection}}r.startTurbulence&&(n.turbulenceX=La(r.turbulenceX),n.turbulenceY=La(r.turbulenceY),n.turbulenceZ=La(r.turbulenceZ));var c=t.emission;c.bursts&&c.bursts.length>0&&(c.bursts=c.bursts.map((function(t){return Va(t)}))),c.burstOffsets&&c.burstOffsets.length>0&&(c.burstOffsets=c.burstOffsets.map((function(t){return Va(t)}))),c.rateOverTime&&(c.rateOverTime=La(c.rateOverTime));var h={renderer:t.renderer,shape:n,splits:t.splits,emission:c,options:{startLifetime:La(r.startLifetime),start3DSize:!!r.start3DSize,startSize:La(r.startSize),startSizeX:La(r.startSizeX),startSizeY:La(r.startSizeY),sizeAspect:La(r.sizeAspect),maxCount:r.maxCount,startDelay:La(r.startDelay),startColor:Ma(r.startColor,!0),startRotationZ:La(r.startRotation||r.startRotationZ),particleFollowParent:r.particleFollowParent}};if(r.start3DRotation&&(h.options.startRotationX=La(r.startRotationX),h.options.startRotationY=La(r.startRotationY)),t.filter){var f={};Ca(t.filter,(function(t,e){var r;f[e]=(r=t,Array.isArray(r)&&"string"==typeof r[0]&&(La(r)||Na(r)||Ma(r))||r)})),h.filter=f}i&&i.path&&(h.emitterTransform={path:Na(i.path)});var p=t.sizeOverLifetime;p&&(p.separateAxes?h.sizeOverLifetime={separateAxes:!0,x:La(p.x),y:La(p.y)}:h.sizeOverLifetime={size:La(p.size)});var d=t.velocityOverLifetime||{},m=d.speedOverLifetime;m=m?Ra(m):void 0,h.positionOverLifetime={gravity:r.gravity,gravityOverLifetime:Ra(r.gravityModifier),startSpeed:La(r.startSpeed),speedOverLifetime:m,asMovement:d.asMovement,linearX:La(d.linearX),linearY:La(d.linearY),linearZ:La(d.linearZ),asRotation:d.asRotation,orbCenter:d.orbCenter,orbitalX:La(d.orbitalX),orbitalY:La(d.orbitalY),orbitalZ:La(d.orbitalZ),forceTarget:d.forceTarget,target:d.target,forceCurve:Ra(d.forceCurve)},Da(h.positionOverLifetime);var v=t.rotationOverLifetime;v&&(h.rotationOverLifetime={separateAxes:v.separateAxes,asRotation:v.asRotation,z:La(v.separateAxes?v.z:v.angularVelocity)},v.separateAxes&&(h.rotationOverLifetime.y=Ra(v.y),h.rotationOverLifetime.x=Ra(v.x)));var y=t.colorOverLifetime;if(y){var g=h.colorOverLifetime={opacity:Ra(y.opacity)};y.color&&(g.color=Fa(y.color))}var x=t.textureSheetAnimation;x&&(h.textureSheetAnimation={row:x.row,col:x.col,total:x.total,animate:x.animate,cycles:Ra(x.cycles),animationDelay:Oa(x.animationDelay,0),animationDuration:Oa(x.animationDuration,0)});var T=t.trails;T&&(h.trails={lifetime:La(T.lifetime),dieWithParticles:T.dieWithParticles,maxPointPerTrail:T.maxPointPerTrail,minimumVertexDistance:T.minimumVertexDistance,widthOverTrail:Ra(T.widthOverTrail),colorOverTrail:T.colorOverTrail&&Fa(T.colorOverTrail,!1),blending:T.blending,colorOverLifetime:T.colorOverLifetime&&Fa(T.colorOverLifetime,!1),inheritParticleColor:T.inheritParticleColor,occlusion:T.occlusion,transparentOcclusion:T.transparentOcclusion,orderOffset:T.orderOffset,sizeAffectsLifetime:T.sizeAffectsLifetime,sizeAffectsWidth:T.sizeAffectsWidth,texture:T.texture,parentAffectsPosition:T.parentAffectsPosition,opacityOverLifetime:La(T.opacityOverLifetime)}),h.trails&&Da(h.trails);var E=t.interaction;return E&&(h.interaction={behavior:E.behavior,radius:E.radius,multiple:E.multiple}),h}function Xa(t,e){var r,i=t.options,n=t.velocityOverLifetime||{},o={path:Na(null===(r=t.transform)||void 0===r?void 0:r.path),gravity:i.gravity,gravityOverLifetime:Ra(i.gravityModifier),direction:i.direction,startSpeed:i.startSpeed,asMovement:n.asMovement,linearX:Ra(n.linearX),linearY:Ra(n.linearY),linearZ:Ra(n.linearZ),asRotation:n.asRotation,orbCenter:n.orbCenter,orbitalX:Ra(n.orbitalX),orbitalY:Ra(n.orbitalY),orbitalZ:Ra(n.orbitalZ),speedOverLifetime:Ra(n.speedOverLifetime)};Da(o);var s={options:{startColor:wa(i.startColor)},positionOverLifetime:o};i.startSize&&(e.scale=[i.startSize,i.startSize/(i.sizeAspect||1),1]),i.startRotation&&(e.rotation?e.rotation[2]+=i.startRotation:e.rotation=[0,0,i.startRotation]);var a=t.rotationOverLifetime;if(a){var u=s.rotationOverLifetime={separateAxes:a.separateAxes,asRotation:a.asRotation};u.separateAxes?(u.x=Ra(a.x),u.y=Ra(a.y),u.z=Ra(a.z)):u.z=Ra(a.angularVelocity)}var l=t.colorOverLifetime;if(l){var c=s.colorOverLifetime={opacity:Ra(l.opacity)};l.color&&(c.color=Fa(l.color))}var h=t.sizeOverLifetime;return h&&(s.sizeOverLifetime={separateAxes:h.separateAxes,size:Ra(h.size),x:Ra(h.x),y:Ra(h.y),z:Ra(h.z)}),s}function Ha(t,e){var r=Xa(t,e),i=t.textureSheetAnimation;return i&&(r.textureSheetAnimation={row:i.row,col:i.col,total:i.total||void 0,animate:i.animate}),r.renderer=t.renderer,t.splits&&(r.splits=t.splits),t.interaction&&(r.interaction=t.interaction),r}var Ya=["strength","bloomAddon","colorAddon","period","waveMovement","colorThreshold","xOpacity","yOpacity","feather"],ja=["path","position"];function Wa(t){return t.compositions.forEach((function(t){t.items.forEach((function(t){t.type===ea.null&&t.endBehavior===la.destroy&&(t.endBehavior=la.freeze)}))})),t.version="2.1",t}var Za=/^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/,qa=/^(\d+)\.(\d+)$/,Ka=!1;function Qa(t){var e,r;if(!t||"object"!=typeof t)throw Error("expect a json object");if(function(t){var e,r=null===(e=t.version)||void 0===e?void 0:e.split(".");!r||Number(r[0])>2||2===Number(r[0])&&Number(r[1])>=2||t.compositions.forEach((function(t){t.items.forEach((function(t){t.type!==ea.mesh&&t.type!==ea.light||(t.endBehavior=1===t.endBehavior?la.destroy:t.endBehavior)}))}))}(t),Za.test(t.version))return Ka="0"===(null===(e=/^(\d+)/.exec(t.version))||void 0===e?void 0:e[0]),Wa(function(t){var e,r;Ja="1.0";var i=t.plugins||[];(null===(e=t.bins)||void 0===e?void 0:e.length)&&(Ja="1.3");var n=(t.requires||[]).slice(),o=t.images.map((function(e,r){return $a(e,r,t.imageTags||[])})),s=t.textures||o.map((function(t,e){return{source:e,flipY:!0}})),a={plugins:i,shapes:t.shapes||[],type:"ge",version:Ja,playerVersion:null!==(r=t.playerVersion)&&void 0!==r?r:{web:"",native:""},compositionId:t.compositionId+"",compositions:t.compositions.map((function(t){return tu(t,{plugins:i,requires:n})})),images:o,imgUsage:t._imgs,binUsage:t.binUsage,spines:t.spines,requires:t.requires,textures:s,bins:(t.bins||[]).slice()};t._textures&&(a._textures=t._textures);return a}(t));var i=null===(r=qa.exec(t.version))||void 0===r?void 0:r[1];if(i)return Number(i)<2?Wa(t):t;throw Error("invalid json version "+t.version)}var Ja="1.0";function $a(t,e,r){var i=r[e],n=t.oriY;if("string"==typeof t)return{renderLevel:i,url:t,oriY:n};if(t.template)return{url:t.url,template:t.template,webp:t.webp,renderLevel:i,oriY:n};if(t.compressed)return{url:t.url,oriY:n,compressed:{astc:t.compressed.android,pvrtc:t.compressed.iOS},webp:t.webp,renderLevel:i};if(t.url)return{url:t.url,type:t.type,webp:t.webp,renderLevel:i,oriY:n,loop:t.loop};if(t&&t.sourceType)return t;throw Error("invalid image type")}function tu(t,e){var r;void 0===e&&(e={});var i={id:t.id+"",camera:Object.assign({clipMode:Sa},t.camera),duration:t.duration,endBehavior:t.endBehavior,items:t.items.map((function(t){return nu(t,e)})),name:t.name},n=t.startTime||t.st;n&&(i.startTime=n);var o=null===(r=t.meta)||void 0===r?void 0:r.previewSize;return o&&o[0]===o[1]&&0===o[0]&&(o=void 0),o&&(i.previewSize=o),i}var eu,ru=[0,0,0,1],iu=.5;function nu(t,e){var r,i,n;void 0===e&&(e={});var o,s,a,u,l,c,h=ea.base,f=t.endBehavior,p=NaN;if(t.content?(h=t.type||ea.plugin,c=t.pn,l=t.pluginName,a=t.content,s=t.content,isNaN(c)&&!l&&(l=a.options.type),t.duration&&(p=t.duration),o=t.transform||y(s.transform),h===ea.filter&&(Ja<"1.1"&&(Ja="1.1"),(a=Ha(s,o)).filter=function(t){var e={};return Ca(t,(function(t,r){Ya.includes(r)?e[r]=Ra(t):ja.includes(r)?e[r]=Na(t):e[r]=t})),e}(s.filter))):t.particle?(h=ea.particle,o=y((s=t.particle).transform,Ka,!0),a=Ga(s)):t.sprite?(h=ea.sprite,a=Ha(s=t.sprite,o=y(s.transform,!1,!0))):t.cal?(h=ea.null,a=Xa(s=t.cal,o=y(s.transform,!1,!0))):t.ui?(h=ea.interact,o=y((s=t.ui).transform),a=function(t){var e,r=t.options;switch(r.type){case"click":e={type:$s.CLICK,showPreview:r.showPreview,previewColor:r.previewColor&&wa(r.previewColor),behavior:r.behavior||ta.NOTIFY};break;case"drag":e={type:$s.DRAG,enableInEditor:!!r.enableInEditor,dxRange:r.dxRange,dyRange:r.dyRange,target:r.target};break;case"message":e={type:$s.MESSAGE}}return{options:e}}(s),o.scale=[s.options.width||1,s.options.height||1,1]):t.model&&(s=t.model,1===t.model.options.type&&(h=ea.camera,o=y(s.transform),a=function(t){var e,r,i=t.options,n={options:{fov:i.fov,far:i.far,near:i.near,clipMode:i.clipMode}},o=t.velocityOverLifetime;if(o||(null===(e=t.transform)||void 0===e?void 0:e.path)){var s={path:Na(null===(r=t.transform)||void 0===r?void 0:r.path),linearX:Ra(null==o?void 0:o.translateX),linearY:Ra(null==o?void 0:o.translateY),linearZ:Ra(null==o?void 0:o.translateZ)};Da(s),n.positionOverLifetime=s}var a=t.rotationOverLifetime;if(a){var u={separateAxes:a.separateAxes,x:Ra(null==a?void 0:a.rotateX),y:Ra(null==a?void 0:a.rotateY),z:a.separateAxes?Ra(null==a?void 0:a.rotateZ):Ra(a.rotation)};Da(u),n.rotationOverLifetime=u}return n}(s))),null===(r=a.renderer)||void 0===r?void 0:r.anchor){var d=new Float32Array(a.renderer.anchor);d[0]==iu&&d[1]==iu?delete a.renderer.anchor:e.requires&&_a(e.requires,"anchor")}if(s){var m=null===(i=s.options)||void 0===i?void 0:i.looping;f=m?Array.isArray(m)?m[1]?la.loop:la.destroy:la.loop:f||(null===(n=null==s?void 0:s.options)||void 0===n?void 0:n.endBehavior)||la.destroy,s.options.renderLevel&&(u=s.options.renderLevel),isNaN(p)&&(p=s.options.duration)}var v={type:h,name:t.name,delay:t.delay,duration:p,id:t.id+"",transform:o,endBehavior:f,renderLevel:u,content:a};return l?e.plugins?(_a(e.plugins,l),v.pn=e.plugins.indexOf(l)):v.pluginName=l:Number.isInteger(c)&&(v.pn=c),t.parentId&&(v.parentId=t.parentId+""),v;function y(t,e,r){if(t){var i={},n=t.rotation;if(n&&(i.rotation=e?[-n[0],-n[1],-n[2]]:[n[0],n[1],n[2]],r)){var o=(s=ru,a=i.rotation[0],u=i.rotation[1],l=i.rotation[2],c=za(a*Ua/2),h=za(u*Ua/2),f=za(l*Ua/2),p=Ba(a*Ua/2),d=Ba(u*Ua/2),m=Ba(l*Ua/2),s[0]=p*h*f+c*d*m,s[1]=c*d*f-p*h*m,s[2]=c*h*m+p*d*f,s[3]=c*h*f-p*d*m,s);i.rotation=function(t,e){var r,i,n,o=e[0],s=e[1],a=e[2],u=e[3],l=o+o,c=s+s,h=a+a,f=o*l,p=s*l,d=s*c,m=a*h,v=u*h,y=1-d-m,g=p-v,x=p+v,T=1-f-m,E=a*l-u*c,S=a*c+u*l,b=1-f-d;return t[1]=Math.asin((i=-1,(r=-E)>(n=1)?n:r<i?i:r))*ka,Math.abs(E)<.9999999?(t[0]=Math.atan2(S,b)*ka,t[2]=Math.atan2(x,y)*ka):(t[0]=0,t[2]=Math.atan2(-g,T)*ka),t}([],o)}return t.position&&(i.position=t.position),Array.isArray(t.scale)&&(i.scale=[t.scale[0]||1,t.scale[1]||1,t.scale[2]||1]),i}var s,a,u,l,c,h,f,p,d,m;return{}}}var ou=((eu={})[E.S]=[E.S,E.BPlus,E.APlus],eu[E.A]=[E.A,E.BPlus,E.APlus],eu[E.B]=[E.B,E.BPlus],eu);function su(t,e){if(!t||!e)return!0;var r=ou[e];return!!r&&r.includes(t)}var au=0,uu=function(){function t(t,e){var r,i;this.refCompositions=new Map,this.refCompositionProps=new Map,this.mask=0;var n=t.jsonScene,o=t.renderLevel,a=t.textureOptions,u=t.pluginSystem,l=t.totalTime,c=n.compositions,h=n.imgUsage,f=n.compositionId;if(!a)throw new Error("scene.textures expected");var p=a.map((function(t){return t&&(t instanceof Vr?t:Vr.create(e,t))}));t.textureOptions=p,null==p||p.forEach((function(t){return null==t?void 0:t.initialize()}));try{for(var d=s(c),m=d.next();!m.done;m=d.next()){var v=m.value;v.id===f?this.composition=v:this.refCompositions.set(v.id,v)}}catch(t){r={error:t}}finally{try{m&&!m.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(!this.composition)throw new Error("Invalid composition id: "+f);this.jsonScene=n,this.renderLevel=o,this.pluginSystem=u,this.totalTime=null!=l?l:0,this.imgUsage=null!=h?h:{},this.textures=p,au=0,this.textureOptions=a,this.sourceContent=this.getContent(this.composition)}return t.prototype.getContent=function(t){var e=t.id,r=t.duration,i=t.name,n=t.endBehavior,o=t.camera,s=t.globalVolume,a=t.startTime,u=void 0===a?0:a,l=this.assembleItems(t);return{id:e,duration:r,name:i,endBehavior:isNaN(n)?1:n,items:l,camera:o,startTime:u,globalVolume:s}},t.prototype.assembleItems=function(t){var e=this,r=[];return t.items.forEach((function(t){var n,o={},s=t.visible,a=t.renderLevel,u=t.type;if(!1!==s){var l=i({},t.content);if(l&&(o.content=i({},l),su(a,e.renderLevel))){var c=o.content;if(o.type=u,c.renderer){c.renderer=e.changeTex(c.renderer),e.processMask(c.renderer);var h=c.splits&&!c.textureSheetAnimation&&c.splits[0];Number.isInteger(c.renderer.shape)?c.renderer.shape=Do(null===(n=e.jsonScene)||void 0===n?void 0:n.shapes[c.renderer.shape],h):c.renderer.shape&&He(c.renderer.shape)&&(c.renderer.shape=Do(c.renderer.shape,h))}else o.content.renderer={order:0};c.trails&&(c.trails=e.changeTex(c.trails)),c.filter&&(c.filter=i({},c.filter));var f=t.name,p=t.delay,d=void 0===p?0:p,m=t.id,v=t.parentId,y=t.duration,g=t.endBehavior,x=t.pluginName,T=t.pn,E=t.transform,S=t.refCount,b=e.jsonScene.plugins,A=void 0===b?[]:b;if(o.name=f,o.delay=d,o.id=m,v&&(o.parentId=v),o.refCount=S,o.duration=y,o.listIndex=au++,o.endBehavior=g,x?o.pluginName=x:void 0!==T&&Number.isInteger(T)&&(o.pluginName=A[T]),E&&(o.transform=E),o.type===w.composition){e.mask++;var _=t.content.options.refId;if(!e.refCompositions.get(_))throw new Error("Invalid Ref Composition id: "+_);var C=e.getContent(e.refCompositions.get(_));e.refCompositionProps.has(_)||e.refCompositionProps.set(_,C),C.items.forEach((function(t){e.processMask(t.content)})),o.items=C.items}r.push(o)}}})),r},t.prototype.changeTex=function(t){var e=t.texture,r=i({},t);return void 0!==e&&(r.texture=this.addTextureUsage(e)||e),r},t.prototype.addTextureUsage=function(t){var e,r;if(Number.isInteger(t)){var i=null===(e=this.textures)||void 0===e?void 0:e[t],n=null==i?void 0:i.id,o=null!==(r=this.imgUsage)&&void 0!==r?r:{};if(n&&o)return o.hasOwnProperty(n)||(o[n]=0),o[n]++,i}},t.prototype.processMask=function(t){if(t.maskMode!==A.NONE&&!t.mask){var e=t.maskMode;e===A.MASK?t.mask=++this.mask:e!==A.OBSCURED&&e!==A.REVERSE_OBSCURED||(t.mask=this.mask)}},t.prototype.dispose=function(){this.textureOptions=[],this.textures=[],this.composition=void 0,this.jsonScene=void 0,this.totalTime=0,this.pluginSystem=void 0,this.sourceContent=void 0,this.refCompositions.clear(),this.refCompositionProps.clear()},t}();function lu(t){return He(t)&&"jsonScene"in t}var cu=1,hu=function(){function e(t,e){void 0===t&&(t={}),void 0===e&&(e=new Rr),this.options=t,this.downloader=e,this.assets={},this.id=cu++,this.timers=[],this.updateOptions(t)}return e.prototype.updateOptions=function(t){void 0===t&&(t={}),this.options=t,t.pluginData||(t.pluginData={});var e=t.timeout,r=void 0===e?10:e;this.timeout=r},e.prototype.loadScene=function(t,e,r){var s,u,l;return n(this,void 0,void 0,(function(){var c,h,f,p,d,m,v,y,g,x,T,E,S=this;return o(this,(function(b){return h=ke(t)?t:this.id,f=performance.now(),p=[],d=null==e?void 0:e.engine.gpuCapability,m=null!==(u=null===(s=null==d?void 0:d.detail)||void 0===s?void 0:s.asyncShaderCompile)&&void 0!==u&&u,v=null!==(l=null==d?void 0:d.detail.compressedTexture)&&void 0!==l?l:0,g=!1,x=new Promise((function(t,e){y=window.setTimeout((function(){g=!0,S.removeTimer(y);var t=performance.now()-f;e("Load time out: totalTime: ".concat(t.toFixed(4),"ms ").concat(p.join(" "),", url: ").concat(h))}),1e3*S.timeout),S.timers.push(y)})),T=function(t,e){return n(S,void 0,void 0,(function(){var r,i,n;return o(this,(function(o){switch(o.label){case 0:if(g)return[3,4];r=performance.now(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,e()];case 2:return i=o.sent(),p.push("[".concat(t,": ").concat((performance.now()-r).toFixed(2),"]")),[2,i];case 3:throw n=o.sent(),new Error("load error in ".concat(t,", ").concat(n));case 4:throw new Error("load canceled.")}}))}))},E=function(){return n(S,void 0,void 0,(function(){var n,s,u,l,d,g,x,E,S,b,A,_,C,R,O,w,M,L,I,P=this;return o(this,(function(o){switch(o.label){case 0:return He(t)?(c=t,this.baseUrl=location.href,[3,3]):[3,1];case 1:return t=new URL(t,location.href).href,this.baseUrl=t,[4,T("loadJSON",(function(){return P.loadJSON(t)}))];case 2:c=o.sent(),o.label=3;case 3:if(!lu(c))return[3,6];if(n=i({},c),!this.options||!this.options.variables||0===Object.keys(this.options.variables).length)return[3,5];for(s=c.jsonScene.images,u=n.images,d=0;d<s.length;d++)u[d]instanceof HTMLCanvasElement&&(u[d]=s[d]);return l=n,[4,T("processImages",(function(){return P.processImages(u,n.usedImages,v)}))];case 4:for(l.images=o.sent(),d=0;d<n.images.length;d++)n.textureOptions[d].image=n.images[d];o.label=5;case 5:return[3,12];case 6:return[4,T("processJSON",(function(){return P.processJSON(c)}))];case 7:return g=o.sent(),x=g.usedImages,E=g.jsonScene,S=g.pluginSystem,b=E.bins,A=void 0===b?[]:b,_=E.images,C=E.compositions,R=E.fonts,[4,Promise.all([T("processBins",(function(){return P.processBins(A)})),T("processImages",(function(){return P.processImages(_,x,v)})),T("".concat(m?"async":"sync"," compile"),(function(){return P.precompile(C,S,e,r)}))])];case 8:return O=a.apply(void 0,[o.sent(),2]),w=O[0],M=O[1],[4,T("processFontURL",(function(){return P.processFontURL(R)}))];case 9:return o.sent(),[4,T("processTextures",(function(){return P.processTextures(M,w,E)}))];case 10:return L=o.sent(),n={url:t,renderLevel:this.options.renderLevel,storage:{},pluginSystem:S,jsonScene:E,usedImages:x,images:M,textureOptions:L,bins:w},[4,T("processPlugins",(function(){return S.loadResources(n,P.options)}))];case 11:o.sent(),o.label=12;case 12:return I=performance.now()-f,Be.info("Load asset: totalTime: ".concat(I.toFixed(4),"ms ").concat(p.join(" "),", url: ").concat(h)),window.clearTimeout(y),this.removeTimer(y),n.totalTime=I,n.startTime=f,[2,n]}}))}))},[2,Promise.race([x,E()])]}))}))},e.prototype.precompile=function(t,e,r,i){return n(this,void 0,void 0,(function(){var n;return o(this,(function(o){switch(o.label){case 0:return r&&r.getShaderLibrary()?(n=null==r?void 0:r.getShaderLibrary(),[4,null==e?void 0:e.precompile(t,r,i)]):[2];case 1:return o.sent(),[4,new Promise((function(t){n.compileAllShaders((function(){t(null)}))}))];case 2:return o.sent(),[2]}}))}))},e.prototype.processJSON=function(t){return n(this,void 0,void 0,(function(){var e,r,i,n,s,a,u,l,c;return o(this,(function(o){switch(o.label){case 0:return e=Qa(t),t.compositions.forEach((function(t,r){t.globalVolume&&(e.compositions[r].globalVolume=t.globalVolume)})),r=e.plugins,i=void 0===r?[]:r,n=e.compositions,s=e.imgUsage,a=e.images,[4,(u=new ir(i)).processRawJSON(e,this.options)];case 1:return o.sent(),l=this.options.renderLevel,c={},s?function(t,e,r,i,n){for(var o=0;o<e.length;o++){var s=r[e[o].id];if(s)for(var a=0;a<s.length;a++){var u=s[a];su(i[u].renderLevel,n)&&(t[u]=!0)}}}(c,n,s,a,l):null==a||a.forEach((function(t,e){c[e]=!0})),[2,{usedImages:c,jsonScene:e,pluginSystem:u}]}}))}))},e.prototype.processBins=function(t){return n(this,void 0,void 0,(function(){var e,r,i=this;return o(this,(function(n){return e=this.options.renderLevel,r=t.map((function(r){if(r instanceof ArrayBuffer)return r;if(su(r.renderLevel,e))return i.loadBins(r.url);throw new Error("Invalid bins source: ".concat(JSON.stringify(t)))})),[2,Promise.all(r)]}))}))},e.prototype.processFontURL=function(t){return n(this,void 0,void 0,(function(){var r,i=this;return o(this,(function(s){return t?(r=t.map((function(t){return n(i,void 0,void 0,(function(){var r,i;return o(this,(function(n){switch(n.label){case 0:if(!t.fontURL||e.fonts.has(t.fontFamily))return[3,4];r=new FontFace(null!==(i=t.fontFamily)&&void 0!==i?i:"","url("+t.fontURL+")"),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,r.load()];case 2:return n.sent(),document.fonts.add(r),e.fonts.add(t.fontFamily),[3,4];case 3:return n.sent(),Be.warn("Invalid fonts source: ".concat(JSON.stringify(t.fontURL))),[3,4];case 4:return[2]}}))}))})),[2,Promise.all(r)]):[2]}))}))},e.prototype.processImages=function(e,r,i){return n(this,void 0,void 0,(function(){var s,a,u,l,c,h=this;return o(this,(function(f){return s=this.options,a=s.useCompressedTexture,u=s.variables,l=this.baseUrl,c=e.map((function(e,s){return n(h,void 0,void 0,(function(){var n,c,h,f,p,d,m,v,y,g,x,T,E,S,b,A,_,C,R;return o(this,(function(o){switch(o.label){case 0:if(!r[s])return[3,19];if(n=e.url,c=e.webp,h=new URL(n,l).href,f=c&&new URL(c,l).href,!("template"in e))return[3,16];if(p=e.template,d=void 0,!("v"in p)||2!==p.v||!p.background)return[3,9];if(!((m=Cs(p,u))instanceof Array))return[3,6];v=p.background.name,o.label=1;case 1:return o.trys.push([1,3,,5]),_={},[4,Mr(m[0])];case 2:return _.image=o.sent(),_.url=m[0],d=_,[3,5];case 3:return o.sent(),C={},[4,Mr(m[1])];case 4:return C.image=o.sent(),C.url=m[1],d=C,[3,5];case 5:return u&&(u[v]=d.url),[3,8];case 6:return"string"!=typeof m?[3,8]:(R={},[4,Mr(m)]);case 7:R.image=o.sent(),R.url=m,d=R,o.label=8;case 8:return[3,11];case 9:return[4,wr(h,f)];case 10:d=o.sent(),o.label=11;case 11:y=void 0,o.label=12;case 12:return o.trys.push([12,14,,15]),[4,Ms(d.image,p,u,this.options,-1===e.oriY)];case 13:return y=o.sent(),[3,15];case 14:throw o.sent(),new Error("image template fail: ".concat(h));case 15:return[2,y];case 16:if("type"in e&&"video"===e.type)return g=e.loop,[2,Ir(e.url,{loop:g})];if("compressed"in e&&a&&i){if(x=e.compressed,T=void 0,i===un.ASTC?T=x.astc:i===un.PVRTC&&(T=x.pvrtc),T)return E=new URL(T,l).href,this.assets[s]={url:E,type:t.TextureSourceType.compressed},[2,this.loadBins(E)]}else{if("sourceType"in e)return[2,e];if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof Vr)return[2,e]}o.label=17;case 17:return[4,wr(h,f)];case 18:return S=o.sent(),b=S.url,A=S.image,this.assets[s]={url:b,type:t.TextureSourceType.image},[2,A];case 19:return[2,void 0]}}))}))})),[2,Promise.all(c)]}))}))},e.prototype.processTextures=function(e,r,s){var a;return n(this,void 0,void 0,(function(){var n,u,l=this;return o(this,(function(o){return n=null!==(a=s.textures)&&void 0!==a?a:e.map((function(t,e){return{source:e}})),u=n.map((function(n,o){if(n instanceof Vr)return n;if("mipmaps"in n)try{return Pr(n,r,s.bins)}catch(t){throw new Error("load texture ".concat(o," fails, error message: ").concat(t))}var a=n.source,u=e[a];if(u){var c=function(e,r){if(e instanceof Vr)return e.source;if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement)return{image:e,sourceType:t.TextureSourceType.image,sourceFrom:r,keepImageSource:!0,minFilter:v.LINEAR,magFilter:v.LINEAR};if(e instanceof HTMLVideoElement)return{sourceType:t.TextureSourceType.video,video:e,minFilter:v.LINEAR,magFilter:v.LINEAR};if(e instanceof ArrayBuffer)return i(i({},Br(e)),{sourceFrom:r});if("width"in e&&"height"in e&&"data"in e)return{sourceType:t.TextureSourceType.data,data:e,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE,minFilter:v.NEAREST,magFilter:v.NEAREST};throw new Error("Invalid texture options")}(u,l.assets[o]);return c.sourceType===t.TextureSourceType.compressed?c:i(i({},c),n)}throw new Error("Invalid texture source: ".concat(a))})),[2,Promise.all(u)]}))}))},e.prototype.loadJSON=function(t){return n(this,void 0,void 0,(function(){var e=this;return o(this,(function(r){return[2,new Promise((function(r,i){e.downloader.downloadJSON(t,r,(function(e,r){i("Couldn't load JSON ".concat(JSON.stringify(t),": status ").concat(e,", ").concat(r))}))}))]}))}))},e.prototype.loadBins=function(t){return n(this,void 0,void 0,(function(){var e=this;return o(this,(function(r){return[2,new Promise((function(r,i){e.downloader.downloadBinary(t,r,(function(e,r){i("Couldn't load bins ".concat(JSON.stringify(t),": status ").concat(e,", ").concat(r))}))}))]}))}))},e.prototype.removeTimer=function(t){var e=this.timers.indexOf(t);-1!==e&&this.timers.splice(e,1)},e.prototype.dispose=function(){var t;for(var e in this.timers.length&&this.timers.map((function(t){return window.clearTimeout(t)})),this.assets){var r=this.assets[e];null===(t=null==r?void 0:r.dispose)||void 0===t||t.call(r)}this.assets={},this.timers=[]},e.fonts=new Set,e}();var fu,pu,du=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.items=[],t.itemTree=[],t.itemCacheMap=new Map,t.itemsToRemove=[],t.tempQueue=[],t}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.composition},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){var e=t.items,r=void 0===e?[]:e,i=t.startTime,n=void 0===i?0:i,o=t.content,s=t.refId;this.refId=s,this.itemProps=r,this.contentProps=o;var a=this.endBehavior;5!==a&&1!==a&&3!==a||(this.freezeOnEnd=!0),this.startTime=n,this.startTimeInms=Math.round(1e3*this.startTime)},n.prototype.createContent=function(){if(!this.items.length&&this.composition)for(var e=0;e<this.itemProps.length;e++){var r=void 0,o=this.itemProps[e];if(t.Item.isComposition(o)){var s=o.content.options.refId,a=this.composition.refCompositionProps.get(s);if(!a)throw new Error("引用的Id: ".concat(s," 的预合成不存在"));a.content=o.content,(r=new n(i(i({},a),{refId:s,delay:o.delay,id:o.id,name:o.name,duration:o.duration,endBehavior:o.endBehavior,parentId:o.parentId,transform:o.transform}),this.composition)).contentProps=o.content,r.transform.parentTransform=this.transform,this.composition.refContent.push(r),5===r.endBehavior&&(this.composition.autoRefTex=!1)}else(r=Je(this.itemProps[e],this.composition)).transform.parentTransform=Qe.isCamera(r)?new Ke:this.transform;Qe.isExtraCamera(r)&&(this.extraCamera=r),this.items.push(r),this.tempQueue.push(r)}!this.content&&this.contentProps&&(this._content=this.doCreateContent())},n.prototype.doCreateContent=function(){var t=new In(this.contentProps,this);return t.renderData=t.getRenderData(0,!0),t},n.prototype.onLifetimeBegin=function(){var t;null===(t=this.items)||void 0===t||t.forEach((function(t){t.start(),t.createContent()})),this.buildItemTree()},n.prototype.doStop=function(){this.items&&this.items.forEach((function(t){return t.stop()}))},n.prototype.onItemUpdate=function(t,e){var r,i,n=this;if(this.content&&(this.content.updateTime(this.time),this.content.getRenderData(this.content.time)),this.items){null===(r=this.composition)||void 0===r||r.updatePluginLoaders(t);var o=[];this.itemsToRemove.length&&(this.itemsToRemove.forEach((function(t){var e,r,i=n.itemCacheMap.get(t.id);if(i){var o=i.children;if(i.parentId){var s=n.itemCacheMap.get(i.parentId);s?(s.children.splice(s.children.indexOf(i),1),o.forEach((function(t){return n.setItemParent(t.item,s.item)}))):(o.forEach((function(t){return n.setItemParent(t.item,void 0)})),(e=n.itemTree).push.apply(e,u([],a(o),!1)))}else(r=n.itemTree).splice.apply(r,u([n.itemTree.indexOf(i),1],a(o),!1)),o.forEach((function(t){return n.setItemParent(t.item,void 0)}));n.itemCacheMap.delete(t.id),n.items.splice(n.items.indexOf(t),1)}})),this.itemsToRemove.length=0);for(var s=0;s<this.itemTree.length;s++){if((c=this.itemTree[s])&&c.item){var l=c.item;Qe.isComposition(l)&&l.ended&&5===l.endBehavior?l.restart():l.onUpdate(t),o.push.apply(o,u([],a(c.children),!1))}}for(;o.length;){var c;if((c=o.shift())&&c.item)(l=c.item).onUpdate(t),o.push.apply(o,u([],a(c.children),!1)),l.composition||z(this.itemsToRemove,l)}null===(i=this.extraCamera)||void 0===i||i.onUpdate(t)}},n.prototype.onItemRemoved=function(t){this.items&&(this.items.forEach((function(t){return t.dispose()})),this.items.length=0,this.itemTree.length=0,this.itemCacheMap.clear())},n.prototype.reset=function(){e.prototype.reset.call(this),this.itemTree=[],this.itemCacheMap.clear(),this.tempQueue.length=0,this.itemsToRemove.length=0},n.prototype.handleVisibleChanged=function(t){this.items.forEach((function(e){return e.setVisible(t)}))},n.prototype.getUpdateTime=function(t){var e=this.startTimeInms,r=this.timeInms;if(t<0&&r+t<e)return e-r;if(this.freezeOnEnd){var i=this.durInms-r;if(i<t)return i}return t},n.prototype.removeItem=function(t){var e,r=this;if(this.items.indexOf(t)>-1){if(z(this.itemsToRemove,t),Qe.isTree(t)||Qe.isNull(t)){var i=6===t.endBehavior,n=Qe.isNull(t)&&!!this.itemCacheMap.get(t.id);((null===(e=this.itemCacheMap.get(t.id))||void 0===e?void 0:e.children)||[]).forEach((function(t){n||r.setItemParent(t.item,void 0),i&&r.removeItem(t.item)}))}return!0}return this.items.forEach((function(e){if(Qe.isComposition(e)&&e.items.indexOf(t)>-1)return e.removeItem(t),!0})),!1},n.prototype.setItemParent=function(t,e){var r=this.itemCacheMap.get(t.id);if(r)if(e){var i=this.itemCacheMap.get(e.id);if(r.parentId){var n=this.itemCacheMap.get(r.parentId);n.children.splice(n.children.indexOf(r),1)}t.parent=e,r.parentId=e.id,i.children.push(r),t.transform.parentTransform=e.transform}else r.parentId=void 0,t.parent=void 0,t.transform.parentTransform=Qe.isExtraCamera(t)?new Ke:this.transform;else console.error("item has been remove, please set item's parent in valid lifetime")},n.prototype.getItemCurrentParent=function(t){var e=t.id,r=this.itemCacheMap.get(e);if(r){var i=r.parentId;if(i){var n=this.itemCacheMap.get(i);return i&&n?n.item:void 0}}},n.prototype.getItemByName=function(t){var e,r,i=[];try{for(var n=s(this.items),o=n.next();!o.done;o=n.next()){var l=o.value;l.name===t?i.push(l):Qe.isComposition(l)&&i.push.apply(i,u([],a(l.getItemByName(t)),!1))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return i},n.prototype.hitTest=function(e,r,i,n,o,s){for(var a=[],u=(null==s?void 0:s.stop)||Ue,l=(null==s?void 0:s.skip)||Ue,c=(null==s?void 0:s.maxCount)||this.items.length,h=0;h<this.items.length&&n.length<c;h++){var f=this.items[h];if(f.lifetime>=0&&f.lifetime<=1&&!Qe.isComposition(f)&&!l(f)){var p=f.getHitTestParams(o);if(p){var d=!1,m=new Mt;if(p.type===t.HitTestType.triangle)for(var v=p.triangles,y=p.backfaceCulling,g=0;g<v.length;g++){var x=v[g];if(e.intersectTriangle(x,m,y)){d=!0,a.push(m);break}}else if(p.type===t.HitTestType.box){var T=p.center,E=p.size,S=T.clone().addScaledVector(E,.5),b=T.clone().addScaledVector(E,-.5);e.intersectBox({min:S,max:b},m)&&(d=!0,a.push(m))}else if(p.type===t.HitTestType.sphere){T=p.center;var A=p.radius;e.intersectSphere({center:T,radius:A},m)&&(d=!0,a.push(m))}else if(p.type===t.HitTestType.custom){var _=p.collect(e,new wt(r,i));_&&_.length>0&&(_.forEach((function(t){a.push(t)})),d=!0)}if(d){var C={compContent:this,id:f.id,name:f.name,position:a[a.length-1],parentId:f.parentId,hitPositions:a,behavior:p.behavior};if(n.push(C),u(C))return n}}}}return n},n.prototype.isEnded=function(t){return t>=this.durInms},n.prototype.buildItemTree=function(){if(!this.itemTree.length&&this.composition){this.itemTree=[];for(var t=this.itemCacheMap,e=this.tempQueue,r=function(){var r=e.shift();if(void 0===r.parentId){var n={id:r.id,item:r,children:[]};i.itemTree.push(n),t.set(r.id,n)}else{var o=i.getParentIdWithoutSuffix(r.parentId),s=t.get(o);if(s){n={id:r.id,parentId:o,item:r,children:[]};r.parent=s.item,r.transform.parentTransform=s.item.getNodeTransform(r.parentId),s.children.push(n),t.set(r.id,n)}else{if(-1===i.items.findIndex((function(t){return t.id===o})))throw Error("元素引用了不存在的元素,请检查数据");e.push(r)}}},i=this;e.length;)r()}},n.prototype.getParentIdWithoutSuffix=function(t){var e=t.lastIndexOf("^");return e>-1?t.substring(0,e):t},n.prototype.restart=function(){this.reset(),this.createContent(),this.start()},n}(Qe),mu=1,vu=function(){function e(t,e){var r;this.speed=1,this.loaderData={},this.refContent=[],this.refCompositionProps=new Map,this.assigned=!1,this.destroyed=!1,this.paused=!1,this.lastVideoUpdateTime=0,this.postLoaders=[];var n=t.reusable,o=void 0!==n&&n,s=t.speed,a=void 0===s?1:s,u=t.baseRenderOrder,l=void 0===u?0:u,c=t.renderer,h=t.onPlayerPause,f=t.onMessageItem,p=t.onEnd,d=t.event,m=t.width,v=t.height;this.compositionSourceManager=new uu(e,c.engine),e.jsonScene.imgUsage=void 0,o&&(this.keepResource=!0,e.textures=void 0,e.consumed=!0);var y=this.compositionSourceManager,g=y.sourceContent,x=y.pluginSystem,T=y.imgUsage,E=y.totalTime,S=y.renderLevel,b=y.refCompositionProps;rt(g),this.refCompositionProps=b;var A=new du(g,this),_=!o&&T;this.transform=new Ke({name:this.name}),A.transform=this.transform,this.globalVolume=g.globalVolume,this.width=m,this.height=v,this.renderOrder=l,this.id=mu++,this.renderer=c,this.texInfo=null!=_?_:{},this.event=d,this.statistic={loadTime:null!=E?E:0,loadStart:null!==(r=e.startTime)&&void 0!==r?r:0,firstFrameTime:0},this.reusable=o,this.speed=a,this.renderLevel=S,this.autoRefTex=!this.keepResource&&_&&5!==A.endBehavior,this.content=A,this.name=A.name,this.pluginSystem=x,this.pluginSystem.initializeComposition(this,e),this.camera=new js(this.name,i(i({},null==g?void 0:g.camera),{aspect:m/v})),this.url=e.url,this.assigned=!0,this.onPlayerPause=h,this.onMessageItem=f,this.onEnd=p,this.createRenderFrame(),this.reset()}return Object.defineProperty(e.prototype,"handleEnd",{set:function(t){console.warn("The handleEnd property is deprecated. Use onEnd instead."),this.onEnd=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textures",{get:function(){return this.compositionSourceManager.textures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.content.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startTime",{get:function(){var t;return null!==(t=this.content.startTime)&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"time",{get:function(){return this.content.timeInms/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.getDuration=function(){return this.content.duration},e.prototype.restart=function(){this.content.reset(),this.prepareRender(),this.reset(),this.transform.setValid(!0),this.content.start(),this.forwardTime(this.startTime),this.content.onUpdate(0),this.loaderData.spriteGroup.onUpdate(0)},e.prototype.setIndex=function(t){this.renderOrder=t},e.prototype.getIndex=function(){return this.renderOrder},e.prototype.setSpeed=function(t){this.speed=t},e.prototype.getSpeed=function(){return this.speed},e.prototype.play=function(){this.content.ended&&this.reusable&&this.restart(),this.content.started?this.gotoAndPlay(this.time-this.startTime):this.gotoAndPlay(0)},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused=!1},e.prototype.gotoAndPlay=function(t){this.resume(),this.content.started||this.content.start(),this.forwardTime(t+this.startTime)},e.prototype.gotoAndStop=function(t){this.gotoAndPlay(t),this.pause()},e.prototype.createRenderFrame=function(){this.renderFrame=new Qi({camera:this.camera,renderer:this.renderer,keepColorBuffer:this.keepColorBuffer,globalVolume:this.globalVolume}),this.renderFrame.cachedTextures=this.textures},e.prototype.setTime=function(t){var e=this.paused;e&&this.resume(),this.content.started||this.content.start(),this.forwardTime(t+this.startTime,!0),e&&this.pause()},e.prototype.forwardTime=function(t,e){void 0===e&&(e=!1);for(var r=1e3*t-this.content.timeInms,i=r<0,n=Math.abs(r),o=i?-15:15;n>15;n-=15)this.update(o,e);this.update(i?-n:n,e)},e.prototype.reset=function(){var t=this;this.rendererOptions=null,this.pluginSystem.plugins.forEach((function(e){return e.onCompositionWillReset(t,t.renderFrame)})),this.content.createContent(),this.content.onEnd=function(){window.setTimeout((function(){var e;null===(e=t.onEnd)||void 0===e||e.call(t,t)}),0)},this.pluginSystem.resetComposition(this,this.renderFrame)},e.prototype.prepareRender=function(){var t=this,e=this.renderFrame;this.postLoaders.length=0,this.pluginSystem.plugins.forEach((function(r){r.prepareRenderFrame(t,e)&&t.postLoaders.push(r)})),this.postLoaders.forEach((function(r){return r.postProcessFrame(t,e)}))},e.prototype.shouldRestart=function(){var t=this.content,e=t.ended,r=t.endBehavior;return e&&5===r},e.prototype.shouldDispose=function(){if(this.reusable)return!1;var t=this.content,e=t.ended,r=t.endBehavior;return e&&(!r||3===r)},e.prototype.update=function(t,e){if(void 0===e&&(e=!1),this.assigned&&!this.paused){this.shouldRestart()&&this.restart();var r=this.content.getUpdateTime(t*this.speed);this.updateVideo(),this.content.onUpdate(r),this.loaderData.spriteGroup.onUpdate(r),this.updateCamera(),this.shouldDispose()?this.dispose():e||this.prepareRender()}},e.prototype.updateVideo=function(){var t,e=performance.now();e-this.lastVideoUpdateTime>33&&((null!==(t=this.textures)&&void 0!==t?t:[]).forEach((function(t){return null==t?void 0:t.uploadCurrentVideoFrame()})),this.lastVideoUpdateTime=e)},e.prototype.updateCamera=function(){this.camera.updateMatrix()},e.prototype.updatePluginLoaders=function(t){var e=this;this.pluginSystem.plugins.forEach((function(r){return r.onCompositionUpdate(e,t)}))},e.prototype.getItemByName=function(t,e){if(this.content&&this.content.items)return this.content.getItemByName(t)[0]},e.prototype.getItemByID=function(t){return this.content&&this.content.items&&this.content.itemCacheMap.has(t)?this.content.itemCacheMap.get(t).item:null},e.prototype.getItemCurrentParent=function(t){return this.content.getItemCurrentParent(t)},e.prototype.itemLifetimeEvent=function(t,e){var r=this,i=e?function(e){return e.onCompositionItemLifeBegin(r,t)}:function(e){return e.onCompositionItemLifeEnd(r,t)};this.pluginSystem.plugins.forEach(i)},e.prototype.getHitTestRay=function(t,e){var r=this.renderFrame.editorTransform,i=r.x,n=r.y;return ue((t-r.z)/i,(e-r.w)/n,this.camera)},e.prototype.getEngine=function(){var t;return null===(t=this.renderer)||void 0===t?void 0:t.engine},e.prototype.hitTest=function(t,e,r,i){if(this.isDestroyed)return[];var n=[],o=this.getHitTestRay(t,e);return this.content.hitTest(o,t,e,n,r,i),this.refContent.forEach((function(s){s.hitTest(o,t,e,n,r,i)})),n},e.prototype.addInteractiveItem=function(t,e){var r;if(e===R.MESSAGE)return null===(r=this.onMessageItem)||void 0===r||r.call(this,{name:t.name,phrase:2,id:t.id,compositionId:this.id}),t.id},e.prototype.removeInteractiveItem=function(t,e){var r;e===R.MESSAGE&&(null===(r=this.onMessageItem)||void 0===r||r.call(this,{name:t.name,phrase:1,id:t.id,compositionId:this.id}))},e.prototype.destroyTextures=function(e){for(var r,i=0;i<e.length;i++){var n=e[i];if(n)if(n.sourceType!==t.TextureSourceType.data||this.texInfo[n.id]){if(this.autoRefTex)--this.texInfo[n.id]||n.dispose()}else n!==(null===(r=this.rendererOptions)||void 0===r?void 0:r.emptyTexture)&&n!==this.renderFrame.transparentTexture&&n.dispose()}},e.prototype.destroyItem=function(t){var e=this;t.type==w.composition?4!==t.endBehavior&&t.items.forEach((function(t){return e.pluginSystem.plugins.forEach((function(r){return r.onCompositionItemRemoved(e,t)}))})):(this.content.removeItem(t),this.refContent.forEach((function(e){return e.removeItem(t)})),this.pluginSystem.plugins.forEach((function(r){return r.onCompositionItemRemoved(e,t)})))},e.prototype.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()},e.prototype.dispose=function(){var t,e,r=this;if(!this.destroyed){this.destroyed=!0;var i={},n=this.textures;n&&(this.keepResource?n.forEach((function(t){(null==t?void 0:t.dispose)&&(i[t.id]=t.dispose,t.dispose=Ue)})):n.forEach((function(t){return t&&t.dispose()}))),this.content.dispose(),this.renderFrame.dispose(),null===(t=this.rendererOptions)||void 0===t||t.emptyTexture.dispose(),null===(e=this.pluginSystem)||void 0===e||e.destroyComposition(this),this.update=function(){Be.error("Update disposed composition: ".concat(r.name,"."))},this.onPlayerPause=Ue,this.dispose=Ue,n&&this.keepResource&&n.forEach((function(t){return t.dispose=i[t.id]})),this.compositionSourceManager.dispose(),this.refCompositionProps.clear()}},e.prototype.setEditorTransform=function(t,e,r){this.renderFrame.editorTransform.set(t,t,e,r)},e.prototype.translateByPixel=function(t,e){this.renderer?this.content.translateByPixel(t,e):console.warn("Can not translate position when container not assigned")},e.prototype.translate=function(t,e,r){this.content.translate(t,e,r)},e.prototype.setPosition=function(t,e,r){this.content.setPosition(t,e,r)},e.prototype.rotate=function(t,e,r){this.content.rotate(t,e,r)},e.prototype.setRotation=function(t,e,r){this.content.setRotation(t,e,r)},e.prototype.scale=function(t,e,r){this.content.scale(t,e,r)},e.prototype.setScale=function(t,e,r){this.content.setScale(t,e,r)},e.prototype.offloadTexture=function(){this.textureOffloaded||(this.textures.forEach((function(t){return t&&t.offloadData()})),this.textureOffloaded=!0)},e.prototype.getRendererOptions=function(){return this.rendererOptions||(this.rendererOptions={emptyTexture:this.renderFrame.emptyTexture,cachePrefix:"-"}),this.rendererOptions},e.prototype.reloadTexture=function(){return n(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this.textureOffloaded?[4,Promise.all(this.textures.map((function(t){return null==t?void 0:t.reloadData()})))]:[3,2];case 1:t.sent(),this.textureOffloaded=!1,t.label=2;case 2:return[2]}}))}))},e}(),yu=function(){function t(){this.destroyed=!1,this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[]}return t.prototype.addTexture=function(t){this.destroyed||z(this.textures,t)},t.prototype.removeTexture=function(t){this.destroyed||B(this.textures,t)},t.prototype.addMaterial=function(t){this.destroyed||z(this.materials,t)},t.prototype.removeMaterial=function(t){this.destroyed||B(this.materials,t)},t.prototype.addGeometry=function(t){this.destroyed||z(this.geometries,t)},t.prototype.removeGeometry=function(t){this.destroyed||B(this.geometries,t)},t.prototype.addMesh=function(t){this.destroyed||z(this.meshes,t)},t.prototype.removeMesh=function(t){this.destroyed||B(this.meshes,t)},t.prototype.addRenderPass=function(t){this.destroyed||z(this.renderPasses,t)},t.prototype.removeRenderPass=function(t){this.destroyed||B(this.renderPasses,t)},Object.defineProperty(t.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),t.prototype.getShaderLibrary=function(){return this.renderer.getShaderLibrary()},t.prototype.dispose=function(){if(!this.destroyed){this.destroyed=!0;var t=[];this.renderPasses.length>0&&t.push("Pass ".concat(this.renderPasses.length)),this.meshes.length>0&&t.push("Mesh ".concat(this.meshes.length)),this.geometries.length>0&&t.push("Geom ".concat(this.geometries.length)),this.textures.length>0&&t.push("Tex ".concat(this.textures.length)),t.length>0&&Be.warn("Release GPU memory: ".concat(t.join(", "))),this.renderPasses.forEach((function(t){t.dispose()})),this.meshes.forEach((function(t){t.dispose()})),this.geometries.forEach((function(t){t.dispose()})),this.materials.forEach((function(t){t.dispose()})),this.textures.forEach((function(t){t.dispose()})),this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[],this.renderer=null}},t}(),gu=function(){function t(t){void 0===t&&(t=60),this.paused=!0,this.lastTime=0,this.setFPS(t),this.tickers=[]}return t.prototype.getFPS=function(){return this.targetFPS},t.prototype.setFPS=function(t){this.targetFPS=Rt(t,1,120),this.interval=Math.floor(1e3/t)-2},t.prototype.getPaused=function(){return this.paused},t.prototype.start=function(){var t=this;if(this.paused=!1,!this.intervalId){this.lastTime=performance.now();var e=requestAnimationFrame||function(t){return window.setTimeout(t,16.7)},r=function(){t.intervalId=e(r),t.paused||t.tick()};r()}},t.prototype.stop=function(){(cancelAnimationFrame||window.clearTimeout)(this.intervalId),this.intervalId=0,this.lastTime=0,this.paused=!0,this.tickers=[]},t.prototype.pause=function(){this.paused=!0},t.prototype.resume=function(){this.paused=!1},t.prototype.tick=function(){if(!this.paused){var t=performance.now(),e=t-this.lastTime;if(e>=this.interval){this.lastTime=t,this.resetTickers&&(this.tickers=this.tickers.filter((function(t){return t})),this.resetTickers=!1);for(var r=0,i=this.tickers.length;r<i;r++){(0,this.tickers[r])(e)}}}},t.prototype.add=function(t){if("function"!=typeof t)throw new Error("Ticker: The tick object must implement the tick method.");this.tickers.push(t)},t}();rr("camera",ur,lr,!0),rr("sprite",wn,Vn,!0),rr("particle",as,ss,!0),rr("cal",ls,cs,!0),rr("interact",vn,dn,!0),rr("filter",wn,zn,!0),rr("text",Fs,Ps,!0),N(na);var xu=((fu={})[v.RGBA]=34842,fu[v.RGB]=34843,fu[v.ALPHA]=33325,fu[v.RED]=33325,fu[v.LUMINANCE_ALPHA]=33327,fu[v.LUMINANCE]=33325,fu),Tu=((pu={})[v.RGBA]=34836,pu[v.RGB]=34837,pu[v.ALPHA]=33326,pu[v.RED]=33326,pu[v.LUMINANCE_ALPHA]=33328,pu[v.LUMINANCE]=33326,pu),Eu=function(e){function s(t,r){var i=e.call(this)||this;i.initialized=!1;var n=i.assembleOptions(r),o=n.sourceType,s=n.sourceFrom,a=n.name,u=void 0===a?"":a;return i.source=n,i.sourceType=o,i.sourceFrom=s,i.name=u,i.engine=t,i}return r(s,e),s.prototype.bind=function(t){this.pipelineContext.bindTexture(this.target,this.textureBuffer,t)},s.prototype.initialize=function(){if(!this.initialized){var t=this.engine;t.addTexture(this);var e=t.getGLPipelineContext();this.pipelineContext=e;var r=e.gl,i=this.source,n=i.target,o=void 0===n?r.TEXTURE_2D:n,s=i.name;this.textureBuffer=r.createTexture(),this.textureBuffer&&Ru(this.textureBuffer,s),this.target=o,this.update(this.source),this.release(),this.initialized=!0}},s.prototype.clone=function(){var t=new s(this.engine,this.source);return t.sourceFrom=this.sourceFrom,t.sourceType=this.sourceType,t.width=this.width,t.height=this.height,t},s.prototype.release=function(){switch(this.source.sourceType){case t.TextureSourceType.image:delete this.source.image,delete this.source.cube;break;case t.TextureSourceType.data:delete this.source.data;break;case t.TextureSourceType.compressed:case t.TextureSourceType.mipmaps:delete this.source.mipmaps}},s.prototype.update=function(e){var r,i,n,o,s=this;if(!this.pipelineContext||!this.textureBuffer)return this.width=0,void(this.height=0);var u=this.target,l=this.source,c=this.pipelineContext.gl,h=this.engine.gpuCapability.detail,f=l.sourceType,p=l.data,d=l.cube,m=l.image,y=l.video,x=l.mipmaps,T=l.mipmaps,E=e.data,S=e.cube,b=e.generateMipmap,A=e.mipmaps,_=l,C=_.format,R=_.type,O=_.internalFormat,w=0,M=0;if(this.bind(f===t.TextureSourceType.video),R===v.HALF_FLOAT?((R=h.halfFloatTexture)||Be.error("Half float texture is not support."),g(c)&&O===C&&(C===v.LUMINANCE&&(C=v.RED),O=xu[C]),h.halfFloatLinear||(l.minFilter=l.magFilter=c.NEAREST,Be.warn("Half float linear not support, change to NEAREST."))):R===c.FLOAT&&((R=h.floatTexture)||Be.error("Float texture is not support."),g(c)&&O===C&&(C===v.LUMINANCE&&(C=v.RED),O=Tu[C]),h.floatLinear||(l.minFilter=c.NEAREST,l.magFilter=c.NEAREST,Be.warn("Float linear not support, change to NEAREST."))),void 0===l.premultiplyAlpha&&(l.premultiplyAlpha=!1),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l.premultiplyAlpha),void 0===l.flipY&&(l.flipY=!1),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,l.flipY),f===t.TextureSourceType.framebuffer)E&&(w=null!==(n=E.width)&&void 0!==n?n:0,M=null!==(o=E.height)&&void 0!==o?o:0,w&&M&&(this.width!==w||this.height!==M)&&c.texImage2D(u,0,O,w,M,0,C,R,null));else if(f===t.TextureSourceType.data)u===c.TEXTURE_CUBE_MAP?S.forEach((function(t,e){var r=a(s.texImage2DData(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,O,C,R,t),2),i=r[0],n=r[1];w=Math.max(i,w),M=Math.max(n,M)})):(r=a(this.texImage2DData(c,u,0,O,C,R,p),2),w=r[0],M=r[1]);else if(f===t.TextureSourceType.image||f===t.TextureSourceType.video){if(u===c.TEXTURE_CUBE_MAP)d.forEach((function(t,e){var r=a(s.texImage2D(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,O,C,R,t),2),i=r[0],n=r[1];w=Math.max(i,w),M=Math.max(n,M)}));else if(u===c.TEXTURE_2D){var L=null!=m?m:y;i=a(this.texImage2D(c,u,0,O,C,R,L),2),w=i[0],M=i[1]}b&&(Su(w)&&Su(M)||g(c))&&c.generateMipmap(u)}else if(f===t.TextureSourceType.mipmaps){var I;u===c.TEXTURE_2D?x.forEach((function(t,e){var r;I="data"in t?s.texImage2DData(c,u,e,O,C,R,t):s.texImage2D(c,u,e,O,C,R,t),0===e&&(r=a(I,2),w=r[0],M=r[1])})):u===c.TEXTURE_CUBE_MAP&&T.forEach((function(t,e){t.forEach((function(t,r){var i;I="data"in t?s.texImage2DData(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,O,C,R,t):s.texImage2D(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,O,C,R,t),0===e&&(i=a(I,2),w=i[0],M=i[1])}))}))}else f===t.TextureSourceType.compressed&&A&&(w=A[0].width,M=A[0].height,A.forEach((function(t,e){c.compressedTexImage2D(u,e,O,t.width,t.height,0,t.data)})));this.width=w,this.height=M,this.setTextureFilters(c,u,l)},s.prototype.setTextureFilters=function(t,e,r){var i=r.anisotropic,n=void 0===i?4:i,o=r.wrapS,s=void 0===o?t.CLAMP_TO_EDGE:o,a=r.wrapT,u=void 0===a?t.CLAMP_TO_EDGE:a,l=this.engine.gpuCapability;this.target===t.TEXTURE_2D&&l.setTextureAnisotropic(t,this.target,n);var c=g(t)||Su(this.width)&&Su(this.height),h=r.minFilter?r.minFilter:t.NEAREST,f=r.magFilter?r.magFilter:t.NEAREST;t.texParameteri(e,t.TEXTURE_MIN_FILTER,h),t.texParameteri(e,t.TEXTURE_MAG_FILTER,f),t.texParameteri(e,t.TEXTURE_WRAP_S,c?s:t.CLAMP_TO_EDGE),t.texParameteri(e,t.TEXTURE_WRAP_T,c?u:t.CLAMP_TO_EDGE)},s.prototype.texImage2D=function(e,r,i,n,o,s,a){var u,l=this,c=this.source,h=c.sourceType,f=c.minFilter,p=c.magFilter;c.flipY;var d=c.wrapS,m=c.wrapT,v=null!==(u=this.engine.gpuCapability.detail.maxTextureSize)&&void 0!==u?u:2048,y=a;if(h!==t.TextureSourceType.video){var g=f!==e.NEAREST||p!==e.NEAREST||d!==e.CLAMP_TO_EDGE||m!==e.CLAMP_TO_EDGE;(g=g||a.width>v||a.height>v)&&setTimeout((function(){y=l.resizeImage(a)}))}e.texImage2D(r,i,n,o,s,y);var x=[y.width,y.height];if(h===t.TextureSourceType.video){var T=a;return[T.videoWidth,T.videoHeight]}return x},s.prototype.texImage2DData=function(t,e,r,i,n,o,s){var a=s.data,u=s.width,l=s.height,c=n===t.UNSIGNED_BYTE?new Uint8Array(a.buffer,a.byteOffset,a.byteLength/a.BYTES_PER_ELEMENT):a;return t.texImage2D(e,r,i,u,l,0,n,o,c),[u,l]},s.prototype.resizeImage=function(t,e,r){var i,n=null!==(i=this.engine.gpuCapability.detail.maxTextureSize)&&void 0!==i?i:2048;if(g(this.pipelineContext.gl)&&t.width<n&&t.height<n)return t;var o=function(t,e,r,i){var n=t.width,o=t.height,s=Math.min(e,r||ae(n)),a=Math.min(e,i||ae(o));if(a!==o||s!==n){var u=_s.getCanvas(),l=u.getContext("2d");return u.width=s,u.height=a,null==l||l.drawImage(t,0,0,n,o,0,0,s,a),Be.warn("Image resize from ".concat(n,"x").concat(o," to ").concat(s,"x").concat(a)),u}}(t,n,e,r);return o||t},s.prototype.reloadData=function(){return n(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this.offloaded?[4,Gr().reload(this)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},s.prototype.offloadData=function(){if(this.initialized&&Gr().canOffloadTexture(this.source.sourceFrom)){var t=this.target,e=this.pipelineContext.gl;if(e&&this.textureBuffer){var r=new Uint8Array([255]);if(this.bind(),t===e.TEXTURE_2D)e.texImage2D(t,0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,r);else if(t===e.TEXTURE_CUBE_MAP)for(var i=[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<i.length;n++)e.texImage2D(i[n],0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,r);e.generateMipmap(t),this.width=1,this.height=1}this.offloaded=!0}},s.prototype.uploadCurrentVideoFrame=function(){return n(this,void 0,void 0,(function(){var e;return o(this,(function(r){switch(r.label){case 0:return this.source.sourceType===t.TextureSourceType.video&&this.source.video&&this.initialized?(e=this.source.video).paused?[4,e.play()]:[3,2]:[3,3];case 1:r.sent(),r.label=2;case 2:return this.update({video:this.source.video}),[2,!0];case 3:return[2,!1]}}))}))},s.prototype.updateSource=function(t){this.source=this.assembleOptions(i(i({},this.source),t)),this.sourceType=this.source.sourceType,this.sourceFrom=this.source.sourceFrom,this.update(this.source)},s.prototype.restore=function(){},s.prototype.dispose=function(){this.pipelineContext&&this.textureBuffer&&this.pipelineContext.gl.deleteTexture(this.textureBuffer),this.source.sourceType===t.TextureSourceType.video&&this.source.video&&this.initialized&&(this.source.video.pause(),this.source.video.src="",this.source.video.load()),this.width=0,this.height=0,this.textureBuffer=null,this.destroyed=!0,this.update=function(){Be.error("This texture has been destroyed.")},this.initialize=je,void 0!==this.engine&&this.engine.removeTexture(this)},s}(Vr);function Su(t){return 0==(t&t-1)&&0!==t}var bu,Au=function(){function t(t,e){this.engine=t,this.ready=!1,this.disposed=!1,this.gl=t.getGLPipelineContext().gl,this.vaoExt=t.gpuCapability.vaoExt,this.vao=this.createVertexArray(e)}return t.prototype.bind=function(){this.bindVertexArray(this.vao)},t.prototype.unbind=function(){this.bindVertexArray(null)},t.prototype.createVertexArray=function(t){var e=null;return g(this.gl)&&(e=this.gl.createVertexArray()),!e&&this.vaoExt&&(e=this.vaoExt.createVertexArrayOES()),e&&Ru(e,t),e},t.prototype.bindVertexArray=function(t){var e;g(this.gl)?this.gl.bindVertexArray(t):null===(e=this.vaoExt)||void 0===e||e.bindVertexArrayOES(t)},t.prototype.dispose=function(){var t;g(this.gl)?this.gl.deleteVertexArray(this.vao):null===(t=this.vaoExt)||void 0===t||t.deleteVertexArrayOES(this.vao)},t}(),_u=1,Cu=function(){function e(e){this.engine=e,this.textures=[],this.renderBuffers=[],this.frameBuffers=[],this.destroyed=!1;var r={width:1,height:1,data:new Uint8Array([255])},i=e.getGLPipelineContext(),n=i.gl;this.gl=n,this.pipelineContext=i,this.emptyTexture2D=new Eu(e,{data:r,sourceType:t.TextureSourceType.data,format:n.LUMINANCE,internalFormat:n.LUMINANCE,type:n.UNSIGNED_BYTE}),this.emptyTexture2D.initialize(),this.emptyTextureCube=new Eu(e,{target:n.TEXTURE_CUBE_MAP,cube:[r,r,r,r,r,r],sourceType:t.TextureSourceType.data,format:n.LUMINANCE,internalFormat:n.LUMINANCE,type:n.UNSIGNED_BYTE}),this.emptyTextureCube.initialize(),this.name="GLGPURenderer"+_u,_u++}return Object.defineProperty(e.prototype,"height",{get:function(){var t;return null===(t=this.gl)||void 0===t?void 0:t.drawingBufferHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){var t;return null===(t=this.gl)||void 0===t?void 0:t.drawingBufferWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this.gl.canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.copy2=function(t,e){var r=this.gl;if(r){this.sourceFbo||(this.sourceFbo=r.createFramebuffer()),this.targetFbo||(this.targetFbo=r.createFramebuffer());var i=this.pipelineContext,n=r.COLOR_ATTACHMENT0;i.bindFramebuffer(r.FRAMEBUFFER,this.sourceFbo),r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_2D,t.textureBuffer,0),i.bindFramebuffer(r.FRAMEBUFFER,this.targetFbo),r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_2D,e.textureBuffer,0),i.bindFramebuffer(r.READ_FRAMEBUFFER,this.sourceFbo),i.bindFramebuffer(r.DRAW_FRAMEBUFFER,this.targetFbo);var o=t.getWidth()===t.getHeight()&&e.getWidth()==e.getHeight()?r.NEAREST:r.LINEAR;r.blitFramebuffer(0,0,t.getWidth(),t.getHeight(),0,0,e.getWidth(),e.getHeight(),r.COLOR_BUFFER_BIT,o),i.bindFramebuffer(r.FRAMEBUFFER,null),i.bindFramebuffer(r.READ_FRAMEBUFFER,null),i.bindFramebuffer(r.DRAW_FRAMEBUFFER,null)}},e.prototype.resetColorAttachments=function(t,e){t.bind(),t.resetColorTextures(e)},e.prototype.createGLRenderBuffer=function(t){var e=this.gl.createRenderbuffer();return e&&z(this.renderBuffers,t),e},e.prototype.resize=function(t,e){var r=this.gl;(r&&r.drawingBufferWidth!==t||r.drawingBufferHeight!==e)&&(r.canvas.width=t,r.canvas.height=e,r.viewport(0,0,t,e),this.frameBuffers.forEach((function(r){var i=r.viewport;r.isCustomViewport||r.resize(i[0],i[1],t*r.viewportScale,e*r.viewportScale)})))},e.prototype.drawGeometry=function(t,e){if(this.gl){var r=t,i=e,n=i.shader.program;if(n){var o=n.setupAttributes(r),s=this.gl,a=r.indicesBuffer,u=r.drawStart,l=r.mode,c=r.drawCount;if(a){var h=a.type,f=a.elementCount;(c=isNaN(c)?f:c)>0&&s.drawElements(l,c,h,null!=u?u:0)}else c>0&&s.drawArrays(l,u,c);null==o||o.unbind()}else console.warn("Material "+i.name+" 的shader着色器程序未初始化。")}else console.warn("GLGPURenderer没有绑定gl对象, 无法绘制geometry")},e.prototype.createGLFrameBuffer=function(t,e){var r=this.gl.createFramebuffer();return r&&(z(this.frameBuffers,t),Ru(r,e,e)),r},e.prototype.createVAO=function(t){return new Au(this.engine,t)},e.prototype.deleteGLTexture=function(t){t.textureBuffer&&!this.destroyed&&(this.gl.deleteTexture(t.textureBuffer),B(this.textures,t),delete t.textureBuffer)},e.prototype.deleteGPUBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteBuffer(t.glBuffer),delete t.glBuffer)},e.prototype.deleteGLFrameBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteFramebuffer(t.fbo),B(this.frameBuffers,t),delete t.fbo)},e.prototype.deleteGLRenderBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteRenderbuffer(t.buffer),B(this.renderBuffers,t),delete t.buffer)},e.prototype.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.prototype.lost=function(t){Be.error("gl lost, destroy glRenderer by default",t.target),this.deleteResource()},e.prototype.dispose=function(t){this.deleteResource();var e=this.gl;if(e&&t){var r=e.getExtension("WEBGL_lose_context");null==r||r.loseContext()}this.emptyTexture2D=this.emptyTextureCube=this.pipelineContext=this.gpu=this.gl=null,this.destroyed=!0},e}();function Ru(t,e,r){void 0!==e&&(t.__SPECTOR_Metadata={name:e},t.__SPECTOR_Object_TAG?(t.__SPECTOR_Object_TAG.displayText=e,r&&(t.__SPECTOR_Object_TAG.id=r)):t.__SPECTOR_Object_TAG={displayText:e,id:""})}var Ou,wu=function(){function t(t,e){this.pipelineContext=t,this.byteLength=0,this.destroyed=!1;var r=e.target,i=void 0===r?v.ARRAY_BUFFER:r,n=e.type,o=void 0===n?v.FLOAT:n,s=e.name,a=e.usage,u=void 0===a?v.STATIC_DRAW:a,l=e.data,c=e.elementCount,h=function(t){var e,r;return null!==(r=null===(e=Mu[t])||void 0===e?void 0:e.BYTES_PER_ELEMENT)&&void 0!==r?r:0}(o);this.target=i,this.type=o,this.usage=u,this.glBuffer=this.createGLBuffer(s),this.bytesPerElement=h,l?this.bufferData(l):c&&this.bufferData(h*c)}return Object.defineProperty(t.prototype,"elementCount",{get:function(){return this.byteLength/this.bytesPerElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),t.prototype.createGLBuffer=function(t){var e=this.pipelineContext.gl.createBuffer();return e&&Ru(e,t),e},t.prototype.bind=function(){this.pipelineContext.gl.bindBuffer(this.target,this.glBuffer)},t.prototype.bufferData=function(t){var e="number"==typeof t?t:t.byteLength;if(this.pipelineContext){this.byteLength=e;var r=this.pipelineContext.gl,i=this.target;r.bindBuffer(i,this.glBuffer),0===e?r.bufferData(i,1,this.usage):(r.bufferData(i,e,this.usage),"number"!=typeof t&&r.bufferSubData(i,0,t))}else this.byteLength=0},t.prototype.bufferSubData=function(t,e){if(this.pipelineContext){var r=this.pipelineContext.gl,i=this.target,n=t*this.bytesPerElement,o=n+e.byteLength;r.bindBuffer(i,this.glBuffer),o>this.byteLength&&(this.byteLength=o,r.bufferData(i,o,this.usage)),r.bufferSubData(i,n,e)}else this.byteLength=0},t.prototype.dispose=function(){this.pipelineContext.gl.deleteBuffer(this.glBuffer),this.glBuffer=null,this.destroyed=!0},t.prototype.readSubData=function(t,e){return!!g(this.pipelineContext.gl)&&(this.pipelineContext.gl.getBufferSubData(this.target,t*this.bytesPerElement,e),!0)},t}(),Mu=((bu={})[v.INT]=Int32Array,bu[v.FLOAT]=Float32Array,bu[v.SHORT]=Int16Array,bu[v.BYTE]=Int8Array,bu[v.UNSIGNED_BYTE]=Uint8Array,bu[v.UNSIGNED_INT]=Uint32Array,bu[v.UNSIGNED_SHORT]=Uint16Array,bu);var Lu=((Ou={})[Uint8Array.BYTES_PER_ELEMENT]=v.UNSIGNED_BYTE,Ou[Uint16Array.BYTES_PER_ELEMENT]=v.UNSIGNED_SHORT,Ou[Uint32Array.BYTES_PER_ELEMENT]=v.UNSIGNED_INT,Ou),Iu=1,Pu=function(t){function e(e,r){var i=this,n=r.drawStart,o=void 0===n?0:n,s=r.drawCount,a=r.mode,u=r.indices,l=r.name,c=void 0===l?"effectsGeometry:".concat(Iu++):l,h=r.bufferUsage,f=void 0===h?v.STATIC_DRAW:h;(i=t.call(this,c)||this).buffers={},i.vaos={},i.initialized=!1,i.indicesReleasable=!1,i.attributesName=[],i.destroyed=!1,i.engine=e;var p={},d=[],m={},y={},g={},x=f;return i.drawStart=o,i.drawCount=isNaN(+s)?NaN:s,i.mode=isNaN(a)?v.TRIANGLES:a,Object.keys(r.attributes).forEach((function(t){var e=r.attributes[t],i=e.size,n=e.stride,o=e.offset,s=e.normalize,a=e,u=a.type,l=void 0===u?v.FLOAT:u,c=a.releasable,h=e.data;if(!l||"dataSource"in e||h||(h=ci(l)),h){var f=h instanceof Float32Array?v.FLOAT:v.INT;p[t]={data:h,usage:x,target:v.ARRAY_BUFFER,name:t},m[t]={size:i,stride:n,offset:o,type:null!=l?l:f,normalize:!!s,dataSource:t},g[t]=null!=c&&c,y[t]={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0}}else{var T=e.dataSource;T&&(m[t]={size:i,stride:n,offset:o,type:l,dataSource:T,normalize:!!s})}d.push(t)})),y.index={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0},i.indices=null==u?void 0:u.data,i.indicesReleasable=!0===(null==u?void 0:u.releasable),i.bufferProps=p,i.attributes=m,i.attributesName=d,i.attributesReleasable=g,i.dirtyFlags=y,i.options=r,i}return r(e,t),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInitialized",{get:function(){return this.initialized},enumerable:!1,configurable:!0}),e.prototype.getOptions=function(){return i({},this.options)},e.prototype.initialize=function(){var t=this;if(!this.initialized){var e=this.engine;rt(e),e.addGeometry(this);var r=this.engine.getGLPipelineContext();Object.keys(this.bufferProps).forEach((function(e){t.buffers[e]=new wu(r,t.bufferProps[e])})),this.indices&&(this.indicesBuffer=this.createIndicesBuffer(r,this.indices)),this.initialized=!0,this.flush(),this.options=void 0}},e.prototype.getAttributeBuffer=function(t){if(this.initialized){var e=this.attributes[t].dataSource;return this.buffers[e]}},e.prototype.setAttributeData=function(t,e){if(null!=this.bufferProps){var r=this.getAttributeBufferOption(t),i=this.attributes[t].dataSource;if(r){var n=r.usage,o=r.target;this.bufferProps[i]={data:e,usage:n,target:o,elementCount:e.length},this.dirtyFlags[i].discard=!0,this.dirtyFlags[i].dirty=!0}}},e.prototype.getAttributeData=function(t){if(null!=this.bufferProps){var e=this.getAttributeBufferOption(t);return e?e.data:void 0}},e.prototype.setAttributeSubData=function(t,e,r){if(null!=this.bufferProps){var i=this.getAttributeBufferOption(t);if(i&&null!=i.data){var n=e,o=e+r.length;if(i.data.length<o){var s=new r.constructor(o);s.set(i.data),i.data=s,this.dirtyFlags[t].discard=!0}else if(!this.dirtyFlags[t].discard){var a=this.dirtyFlags[t];a.start=Math.min(a.start,n),a.end=Math.max(a.end,o-1)}i.data.set(r,n),this.dirtyFlags[t].dirty=!0}}},e.prototype.getIndexData=function(){return this.indices},e.prototype.setIndexData=function(t){(t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array)&&(this.indices=t,this.dirtyFlags.index.discard=!0,this.dirtyFlags.index.dirty=!0)},e.prototype.setIndexSubData=function(t,e){var r;if(this.indices){var i=t,n=t+e.length;if(this.indices.length<n){var o=new e.constructor(end);o.set(this.indices),this.indices=o,this.dirtyFlags.index.discard=!0}else if(!this.dirtyFlags.index.discard){var s=this.dirtyFlags.index;s.start=Math.min(s.start,i),s.end=Math.max(s.end,n-1)}null===(r=this.indices)||void 0===r||r.set(e,i),this.dirtyFlags.index.dirty=!0}},e.prototype.getAttributeStride=function(t){var e=this.attributes[t],r=e.stride,i=e.size,n=e.type;return r||i*ui[n]},e.prototype.getAttributeNames=function(){return this.attributesName},e.prototype.setDrawStart=function(t){this.drawStart=t},e.prototype.getDrawStart=function(){return this.drawStart},e.prototype.setDrawCount=function(t){this.drawCount=t},e.prototype.getDrawCount=function(){return this.drawCount},e.prototype.getAttributeBufferOption=function(t){var e=this.attributes[t];return e?this.bufferProps[e.dataSource]:void 0},e.prototype.createIndicesBuffer=function(t,e){var r=Lu[e.BYTES_PER_ELEMENT],i={data:e,target:v.ELEMENT_ARRAY_BUFFER,type:r,name:"".concat(this.name,"##index")};return new wu(t,i)},e.prototype.flush=function(){var t=this;if(this.initialized){var e=this.attributes,r=this.bufferProps,i=this.indices;Object.keys(this.dirtyFlags).forEach((function(n){var o,s,a=t.dirtyFlags[n];if("index"==n)o=t.indicesBuffer,s=i;else{var u=e[n].dataSource;o=t.buffers[u],s=r[u].data}if((a.dirty||a.discard)&&o&&s){if(a.discard)o.bufferData(s);else{var l=a.start*s.BYTES_PER_ELEMENT+s.byteOffset,c=a.end-a.start+1,h=new s.constructor(s.buffer,l,c);o.bufferSubData(a.start,h)}a.start=Number.POSITIVE_INFINITY,a.end=0,a.dirty=a.discard=!1}})),Object.keys(this.attributesReleasable).forEach((function(i){var n=t.attributesReleasable[i],o=e[i].dataSource;r[o]&&n&&(r[o].data=void 0)})),this.indicesReleasable}},e.prototype.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)||void 0===t||t.dispose(),Object.keys(this.vaos).forEach((function(t){var r;null===(r=e.vaos[t])||void 0===r||r.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},e}(li),Fu=function(){function t(){this.reset()}return t.prototype.setBlendColor=function(t){var e=a(t,4),r=e[0],i=e[1],n=e[2],o=e[3];this.blendColor[0]===r&&this.blendColor[1]===i&&this.blendColor[2]===n&&this.blendColor[3]===o||(this.blendColor[0]=r,this.blendColor[1]=i,this.blendColor[2]=n,this.blendColor[3]=o)},t.prototype.setBlending=function(t){this.blending!==t&&(this.blending=t)},t.prototype.setBlendFunctionParameters=function(t){var e=a(t,4),r=e[0],i=e[1],n=e[2],o=e[3];this.blendFunctionParameters[0]===r&&this.blendFunctionParameters[1]===i&&this.blendFunctionParameters[2]===n&&this.blendFunctionParameters[3]===o||(this.blendFunctionParameters[0]=r,this.blendFunctionParameters[1]=i,this.blendFunctionParameters[2]=n,this.blendFunctionParameters[3]=o)},t.prototype.setBlendEquationParameters=function(t){var e=a(t,2),r=e[0],i=e[1];this.blendEquationParameters[0]===r&&this.blendEquationParameters[1]===i||(this.blendEquationParameters[0]=r,this.blendEquationParameters[1]=i)},t.prototype.setDepthTest=function(t){this.depthTest!==t&&(this.depthTest=t)},t.prototype.setDepthMask=function(t){this.depthMask!==t&&(this.depthMask=t)},t.prototype.setDepthRange=function(t){this.depthRange[0]===t[0]&&this.depthRange[1]===t[1]||(this.depthRange[0]=t[0],this.depthRange[1]=t[1])},t.prototype.setDepthFunc=function(t){this.depthFunc!==t&&(this.depthFunc=t)},t.prototype.setPolygonOffsetFill=function(t){this.polygonOffsetFill!==t&&(this.polygonOffsetFill=t)},t.prototype.setPolygonOffset=function(t){this.polygonOffset[0]===t[0]&&this.polygonOffset[1]===t[1]||(this.polygonOffset[0]=t[0],this.polygonOffset[1]=t[1])},t.prototype.setSampleAlphaToCoverage=function(t){this.sampleAlphaToCoverage!==t&&(this.sampleAlphaToCoverage=t)},t.prototype.setColorMask=function(t){var e=a(t,4),r=e[0],i=e[1],n=e[2],o=e[3];this.colorMask[0]===r&&this.colorMask[1]===i&&this.colorMask[2]===n&&this.colorMask[3]===o||(this.colorMask[0]=r,this.colorMask[1]=i,this.colorMask[2]=n,this.colorMask[3]=o)},t.prototype.setStencilTest=function(t){this.stencilTest!==t&&(this.stencilTest=t)},t.prototype.setStencilMask=function(t){this.stencilMask[0]===t[0]&&this.stencilMask[1]===t[1]||(this.stencilMask[0]=t[0],this.stencilMask[1]=t[1])},t.prototype.setStencilRef=function(t){this.stencilRef[0]===t[0]&&this.stencilRef[1]===t[1]||(this.stencilRef[0]=t[0],this.stencilRef[1]=t[1])},t.prototype.setStencilFunc=function(t){this.stencilFunc[0]===t[0]&&this.stencilFunc[1]===t[1]||(this.stencilFunc[0]=t[0],this.stencilFunc[1]=t[1])},t.prototype.setStencilOpFail=function(t){this.stencilOpFail[0]===t[0]&&this.stencilOpFail[1]===t[1]||(this.stencilOpFail[0]=t[0],this.stencilOpFail[1]=t[1])},t.prototype.setStencilOpZFail=function(t){this.stencilOpZFail[0]===t[0]&&this.stencilOpZFail[1]===t[1]||(this.stencilOpZFail[0]=t[0],this.stencilOpZFail[1]=t[1])},t.prototype.setStencilOpZPass=function(t){this.stencilOpZPass[0]===t[0]&&this.stencilOpZPass[1]===t[1]||(this.stencilOpZPass[0]=t[0],this.stencilOpZPass[1]=t[1])},t.prototype.setCulling=function(t){this.culling!==t&&(this.culling=t)},t.prototype.setFrontFace=function(t){this.frontFace!==t&&(this.frontFace=t)},t.prototype.setCullFace=function(t){this.cullFace!==t&&(this.cullFace=t)},t.prototype.reset=function(){this.blending=!1,this.blendColor=[0,0,0,0],this.blendFunctionParameters=[v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA],this.blendEquationParameters=[v.FUNC_ADD,v.FUNC_ADD],this.depthTest=!1,this.depthMask=!1,this.depthRange=[0,1],this.depthFunc=v.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=[v.ALWAYS,v.ALWAYS],this.stencilOpFail=[v.KEEP,v.KEEP],this.stencilOpZFail=[v.KEEP,v.KEEP],this.stencilOpZPass=[v.KEEP,v.KEEP],this.culling=!1,this.frontFace=v.CW,this.cullFace=v.FRONT},t.prototype.apply=function(t){if(t.toggle(v.SAMPLE_ALPHA_TO_COVERAGE,this.sampleAlphaToCoverage),t.toggle(v.BLEND,this.blending),t.toggle(v.DEPTH_TEST,this.depthTest),t.toggle(v.STENCIL_TEST,this.stencilTest),t.toggle(v.CULL_FACE,this.culling),t.toggle(v.POLYGON_OFFSET_FILL,this.polygonOffsetFill),this.stencilTest&&(t.stencilMaskSeparate(v.BACK,this.stencilMask[1]),t.stencilMaskSeparate(v.FRONT,this.stencilMask[0]),t.stencilFuncSeparate(v.BACK,this.stencilFunc[0],this.stencilRef[0],this.stencilMask[0]),t.stencilFuncSeparate(v.FRONT,this.stencilFunc[1],this.stencilRef[1],this.stencilMask[1]),t.stencilOpSeparate(v.BACK,this.stencilOpFail[0],this.stencilOpZFail[0],this.stencilOpZPass[0]),t.stencilOpSeparate(v.FRONT,this.stencilOpFail[1],this.stencilOpZFail[1],this.stencilOpZPass[1])),this.blending){var e=this,r=e.blendColor,i=e.blendEquationParameters,n=e.blendFunctionParameters;t.blendColor(r[0],r[1],r[2],r[3]),t.blendEquationSeparate(i[0],i[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}(),Nu=zt,Vu=Ft,Du=function(e){function i(t,r){var i=e.call(this,r)||this;return i.floats={},i.ints={},i.vector2s={},i.vector3s={},i.vector4s={},i.quaternions={},i.matrices={},i.matrice3s={},i.textures={},i.floatArrays={},i.vector4Arrays={},i.matrixArrays={},i.samplers=[],i.uniforms=[],i.uniformDirtyFlag=!0,i.glMaterialState=new Fu,i.engine=t,i}return r(i,e),Object.defineProperty(i.prototype,"blending",{get:function(){return this.glMaterialState.blending},set:function(t){void 0!==t&&this.glMaterialState.setBlending(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendColor",{get:function(){return this.glMaterialState.blendColor},set:function(t){t&&this.glMaterialState.setBlendColor(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendFunction",{get:function(){return this.glMaterialState.blendFunctionParameters},set:function(t){t&&this.glMaterialState.setBlendFunctionParameters(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendEquation",{get:function(){return this.glMaterialState.blendEquationParameters},set:function(t){t&&this.glMaterialState.setBlendEquationParameters(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthTest",{get:function(){return this.glMaterialState.depthTest},set:function(t){void 0!==t&&this.glMaterialState.setDepthTest(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthMask",{get:function(){return this.glMaterialState.depthMask},set:function(t){void 0!==t&&this.glMaterialState.setDepthMask(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthRange",{get:function(){return this.glMaterialState.depthRange},set:function(t){t&&this.glMaterialState.setDepthRange(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthFunc",{get:function(){return this.glMaterialState.depthFunc},set:function(t){void 0!==t&&this.glMaterialState.setDepthFunc(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"polygonOffsetFill",{get:function(){return this.glMaterialState.polygonOffsetFill},set:function(t){void 0!==t&&this.glMaterialState.setPolygonOffsetFill(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"polygonOffset",{get:function(){return this.glMaterialState.polygonOffset},set:function(t){t&&this.glMaterialState.setPolygonOffset(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sampleAlphaToCoverage",{get:function(){return this.glMaterialState.sampleAlphaToCoverage},set:function(t){void 0!==t&&this.glMaterialState.setSampleAlphaToCoverage(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"colorMask",{get:function(){return this.glMaterialState.colorMask},set:function(t){t&&this.glMaterialState.setColorMask(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilTest",{get:function(){return this.glMaterialState.stencilTest},set:function(t){void 0!==t&&this.glMaterialState.setStencilTest(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilMask",{get:function(){return this.glMaterialState.stencilMask},set:function(t){t&&this.glMaterialState.setStencilMask(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilRef",{get:function(){return this.glMaterialState.stencilRef},set:function(t){t&&this.glMaterialState.setStencilRef(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilFunc",{get:function(){return this.glMaterialState.stencilFunc},set:function(t){t&&this.glMaterialState.setStencilFunc(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilOpFail",{get:function(){return this.glMaterialState.stencilOpFail},set:function(t){t&&this.glMaterialState.setStencilOpFail(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilOpZFail",{get:function(){return this.glMaterialState.stencilOpZFail},set:function(t){t&&this.glMaterialState.setStencilOpZFail(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilOpZPass",{get:function(){return this.glMaterialState.stencilOpZPass},set:function(t){t&&this.glMaterialState.setStencilOpZPass(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"culling",{get:function(){return this.glMaterialState.culling},set:function(t){void 0!==t&&this.glMaterialState.setCulling(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"frontFace",{get:function(){return this.glMaterialState.frontFace},set:function(t){void 0!==t&&this.glMaterialState.setFrontFace(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cullFace",{get:function(){return this.glMaterialState.cullFace},set:function(t){void 0!==t&&this.glMaterialState.setCullFace(t)},enumerable:!1,configurable:!0}),i.prototype.enableKeyword=function(t){throw new Error("Method not implemented.")},i.prototype.disableKeyword=function(t){throw new Error("Method not implemented.")},i.prototype.isKeywordEnabled=function(t){throw new Error("Method not implemented.")},i.prototype.createMaterialStates=function(t){this.sampleAlphaToCoverage=!!t.sampleAlphaToCoverage,this.depthTest=t.depthTest,this.depthMask=t.depthMask,this.depthRange=t.depthRange,this.depthFunc=t.depthFunc,this.colorMask=t.colorMask,this.polygonOffset=t.polygonOffset,this.polygonOffsetFill=t.polygonOffsetFill,this.blending=t.blending,this.blendFunction=t.blendFunction,this.stencilTest=t.stencilTest},Object.defineProperty(i.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),i.prototype.initialize=function(){var t=this;if(!this.initialized){var e=this.engine;if(e.addMaterial(this),!this.shader){var r=e.getGLPipelineContext();this.shader=r.shaderLibrary.createShader(this.shaderSource)}this.shader.initialize(e),Object.keys(this.textures).forEach((function(e){var r=t.textures[e];Xe(r.initialize)?r.initialize():Be.error("".concat(JSON.stringify(r)," is not valid Texture to initialize"))})),this.initialized=!0}},i.prototype.setupStates=function(t){this.glMaterialState.apply(t)},i.prototype.use=function(t,e){var r,i,n,o,a,u=t.engine.getGLPipelineContext();if(this.shader.program.bind(),this.setupStates(u),e){try{for(var l=s(e.uniforms),c=l.next();!c.done;c=l.next())a=c.value,this.checkUniform(a)}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}try{for(var h=s(e.samplers),f=h.next();!f.done;f=h.next())a=f.value,this.samplers.includes(a)||(this.samplers.push(a),this.uniformDirtyFlag=!0)}catch(t){n={error:t}}finally{try{f&&!f.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}if(this.uniformDirtyFlag&&(this.shader.fillShaderInformation(this.uniforms,this.samplers),this.uniformDirtyFlag=!1),e){for(a in e.floats)this.shader.setFloat(a,e.floats[a]);for(a in e.ints)this.shader.setInt(a,e.ints[a]);for(a in e.matrices)this.shader.setMatrix(a,e.matrices[a])}for(a in this.textures)this.textures[a].textureBuffer||this.textures[a].initialize();for(a in this.floats)this.shader.setFloat(a,this.floats[a]);for(a in this.ints)this.shader.setInt(a,this.ints[a]);for(a in this.floatArrays)this.shader.setFloats(a,this.floatArrays[a]);for(a in this.textures)this.shader.setTexture(a,this.textures[a]);for(a in this.vector2s)this.shader.setVector2(a,this.vector2s[a]);for(a in this.vector3s)this.shader.setVector3(a,this.vector3s[a]);for(a in this.vector4s)this.shader.setVector4(a,this.vector4s[a]);for(a in this.quaternions)this.shader.setQuaternion(a,this.quaternions[a]);for(a in this.matrices)this.shader.setMatrix(a,this.matrices[a]);for(a in this.matrice3s)this.shader.setMatrix3(a,this.matrice3s[a]);for(a in this.vector4Arrays)this.shader.setVector4Array(a,this.vector4Arrays[a]);for(a in this.matrixArrays)this.shader.setMatrixArray(a,this.matrixArrays[a])},i.prototype.getFloat=function(t){return this.floats[t]},i.prototype.setFloat=function(t,e){this.checkUniform(t),this.floats[t]=e},i.prototype.getInt=function(t){return this.ints[t]},i.prototype.setInt=function(t,e){this.checkUniform(t),this.ints[t]=e},i.prototype.getFloats=function(t){return this.floatArrays[t]},i.prototype.setFloats=function(t,e){this.checkUniform(t),this.floatArrays[t]=e},i.prototype.getVector2=function(t){return this.vector2s[t]},i.prototype.setVector2=function(t,e){this.checkUniform(t),this.vector2s[t]=e},i.prototype.getVector3=function(t){return this.vector3s[t]},i.prototype.setVector3=function(t,e){this.checkUniform(t),this.vector3s[t]=e},i.prototype.getVector4=function(t){return this.vector4s[t]},i.prototype.setVector4=function(t,e){this.checkUniform(t),this.vector4s[t]=e},i.prototype.getQuaternion=function(t){return this.quaternions[t]},i.prototype.setQuaternion=function(t,e){this.checkUniform(t),this.quaternions[t]=e},i.prototype.getMatrix=function(t){return this.matrices[t]},i.prototype.setMatrix=function(t,e){this.checkUniform(t),this.matrices[t]=e},i.prototype.setMatrix3=function(t,e){this.checkUniform(t),this.matrice3s[t]=e},i.prototype.getVector4Array=function(t){return this.vector4Arrays[t]},i.prototype.setVector4Array=function(t,e){var r,i;this.checkUniform(t),this.vector4Arrays[t]=[];try{for(var n=s(e),o=n.next();!o.done;o=n.next()){var a=o.value;this.vector4Arrays[t].push(a.x,a.y,a.z,a.w)}}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}},i.prototype.getMatrixArray=function(t){return this.matrixArrays[t]},i.prototype.setMatrixArray=function(t,e){var r,i;this.checkUniform(t),this.matrixArrays[t]=[];try{for(var n=s(e),o=n.next();!o.done;o=n.next())for(var a=o.value,u=0;u<16;u++)this.matrixArrays[t].push(a.elements[u])}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}},i.prototype.setMatrixNumberArray=function(t,e){this.checkUniform(t),this.matrixArrays[t]=e},i.prototype.getTexture=function(t){return this.textures[t]},i.prototype.setTexture=function(t,e){this.samplers.includes(t)||(this.samplers.push(t),this.uniformDirtyFlag=!0),this.textures[t]=e},i.prototype.hasUniform=function(t){return this.uniforms.includes(t)||this.samplers.includes(t)},i.prototype.clone=function(t){var e=t||this.props,r=this.engine;rt(r);var n=new i(r,e);return n.glMaterialState=Object.assign(new Fu,n.glMaterialState),n.floats=this.floats,n.ints=this.ints,n.vector2s=this.vector2s,n.vector3s=this.vector3s,n.vector4s=this.vector4s,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.uniformDirtyFlag=!0,n},i.prototype.cloneUniforms=function(t){var e,r=t;for(e in r.floats)this.setFloat(e,r.floats[e]);for(e in r.ints)this.setInt(e,r.ints[e]);for(e in r.floatArrays)this.setFloats(e,r.floatArrays[e]);for(e in r.textures)this.setTexture(e,r.textures[e]);for(e in r.vector2s)this.setVector2(e,r.vector2s[e]);for(e in r.vector3s)this.setVector3(e,r.vector3s[e]);for(e in r.vector4s)this.setVector4(e,r.vector4s[e]);for(e in r.quaternions)this.setQuaternion(e,r.quaternions[e]);for(e in r.matrices)this.setMatrix(e,r.matrices[e]);for(e in r.vector4Arrays){for(var i=[],n=0;n<r.vector4Arrays[e].length;n+=4)i.push(new Nu(r.vector4Arrays[e][n],r.vector4Arrays[e][n+1],r.vector4Arrays[e][n+2],r.vector4Arrays[e][n+3]));this.setVector4Array(e,i)}for(e in r.matrixArrays){var o=[];for(n=0;n<r.matrixArrays[e].length;n+=16){for(var s=Vu.fromIdentity(),a=0;a<16;a++)s.elements[a]=r.matrixArrays[e][n+a];o.push(s)}this.setMatrixArray(e,o)}},i.prototype.checkUniform=function(t){this.uniforms.includes(t)||(this.uniforms.push(t),this.uniformDirtyFlag=!0)},i.prototype.dispose=function(e){var r,i=this;this.destroyed||(null===(r=this.shader)||void 0===r||r.dispose(),(null==e?void 0:e.textures)!==t.DestroyOptions.keep&&Object.keys(this.textures).forEach((function(t){i.textures[t].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=je,this.destroyed=!0,void 0!==this.engine&&(this.engine.removeMaterial(this),this.engine=void 0))},i}(qr),zu=function(){function e(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)}}return e.prototype.resetColorAttachments=function(t,e){this.renderer&&t.resetColorAttachments(e)},e.prototype.copyTexture=function(e,r){this.renderer&&(e.initialize(),r.initialize(),r.updateSource({sourceType:t.TextureSourceType.framebuffer,data:{width:r.getWidth()||e.getWidth(),height:r.getHeight()||e.getHeight()}}),2===this.renderer.engine.gpuCapability.level?this.copy2(e,r):this.copy1(e,r))},e.prototype.copy2=function(t,e){var r,i=this.renderer.getFrameBuffer();null===(r=this.renderer)||void 0===r||r.glRenderer.copy2(t,e),this.renderer.setFrameBuffer(i)},e.prototype.copy1=function(t,e){var r=this.copyRenderPass;if(r){var i=this.renderer;if(i){var n=r.frameBuffer;n.viewport[2]=e.getWidth()||t.getWidth(),n.viewport[3]=e.getHeight()||t.getHeight(),i.glRenderer.resetColorAttachments(n,[e]),r.meshes[0].material.setTexture("uTex",t),i.renderRenderPass(r)}}},e.prototype.createCopyRenderPass=function(){var e="mri-copy-mesh",r={texture:{format:v.RGBA}},i=this.renderer.engine,n=new Pu(i,{name:e,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),o=i.gpuCapability.level,s=new Du(i,{name:e,shader:{cacheId:"$mri-internal-copy",name:e,vertex:br([],"\n precision highp float;\n attribute vec2 aPos;\n varying vec2 vTex;\n void main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.))/2.;\n }\n ",t.ShaderType.vertex,o),fragment:br([],"\n precision highp float;\n varying vec2 vTex;\n uniform sampler2D uTex;\n void main(){gl_FragColor = texture2D(uTex,vTex);}\n ",t.ShaderType.fragment,o),glslVersion:2===o?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1}});s.blending=!1,s.depthTest=!1,s.culling=!1;var a=new gi(i,{name:e,geometry:n,material:s,priority:0});return new Bu(this.renderer,{name:"mri-copy-rp",clearAction:{colorAction:t.TextureLoadAction.whatever},attachments:[r],meshes:[a]})},e.prototype.dispose=function(){var t;this.renderer&&(null===(t=this.copyRenderPass)||void 0===t||t.dispose(),this.renderer=void 0)},e}(),Bu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.configure=function(t){this.currentFrameBuffer=t.getFrameBuffer(),t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){this.clearAction&&t.clear(this.clearAction),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction),t.setFrameBuffer(this.currentFrameBuffer)},e}(bi),Uu=function(){function t(t,e,r){var i=this;void 0===e&&(e="webgl"),void 0===r&&(r={}),this.canvas=t,this.glType=e,this.restoreHandlers=[],this.lostHandlers=[],rt(t),this.gl=p(t,e,r),this.contextLostListener=function(t){var e,r,n;try{for(var o=s(i.lostHandlers),a=o.next();!a.done;a=o.next()){a.value.lost(t)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}null===(n=i.canvas)||void 0===n||n.removeEventListener("webglcontextlost",i.contextLostListener)},this.contextRestoredListener=function(t){var e,r,n;try{for(var o=s(i.restoreHandlers),a=o.next();!a.done;a=o.next()){a.value.restore()}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}null===(n=i.canvas)||void 0===n||n.addEventListener("webglcontextlost",i.contextLostListener)},t.addEventListener("webglcontextlost",this.contextLostListener),t.addEventListener("webglcontextrestored",this.contextRestoredListener)}return t.prototype.dispose=function(){this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.contextLostListener),this.canvas.removeEventListener("webglcontextrestored",this.contextRestoredListener)),this.gl=null,this.canvas=null},t.prototype.addLostHandler=function(t){this.lostHandlers.push(t)},t.prototype.removeLostHandler=function(t){var e=this.lostHandlers.indexOf(t);e>-1&&this.lostHandlers.splice(e,1)},t.prototype.addRestoreHandler=function(t){this.restoreHandlers.push(t)},t.prototype.removeRestoreHandler=function(t){var e=this.restoreHandlers.indexOf(t);e>-1&&this.restoreHandlers.splice(e,1)},t}(),ku=function(t){function e(e,r){var i=t.call(this,e)||this;return i.initialized=!1,void 0!==r&&i.initialize(r),i}return r(e,t),e.prototype.initialize=function(t){this.initialized||(this.initialized=!0,this.renderer=t,this.buffer=t.createGLRenderBuffer(this))},e.prototype.setSize=function(t,e){if(this.initialized){if(t!==this.size[0]||e!==this.size[1]){var r=this.renderer,i=r.gl;r.pipelineContext.bindRenderBuffer(i.RENDERBUFFER,this.buffer),t&&e?i.renderbufferStorage(i.RENDERBUFFER,this.format,this.size[0]=t,this.size[1]=e):Be.error("Invalid render buffer size: ".concat(t,"x").concat(e))}}else Be.error("Can't set size for uninitialized render buffer")},e.prototype.dispose=function(){this.renderer&&(this.renderer.deleteGLRenderBuffer(this),this.renderer=null,this.buffer=null),this.destroyed=!0,this.initialize=je},e}(en),Gu=1,Xu=function(e){function i(r,i){var n,o=e.call(this)||this;o.attachmentTextures=[],o.renderer=i,o.engine=i.engine;var s=r.depthStencilAttachment,a=r.viewport,u=r.isCustomViewport,l=r.viewportScale,c=void 0===l?1:l,h=r.storeAction,f=r.name,p=void 0===f?"GLFrameBuffer".concat(Gu++):f;return o.depthStencilStorageType=null!==(n=null==s?void 0:s.storageType)&&void 0!==n?n:t.RenderPassAttachmentStorageType.none,o.viewport=a,o.isCustomViewport=!!u,o.viewportScale=c,o.name=p,o.storeAction=h,o.updateProps(r),o}return r(i,e),Object.defineProperty(i.prototype,"stencilStorage",{get:function(){if(this.depthStencilStorageType!==t.RenderPassAttachmentStorageType.depth_16_opaque)return this.depthStencilRenderBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthStorage",{get:function(){if(this.depthStencilStorageType!==t.RenderPassAttachmentStorageType.stencil_8_opaque)return this.depthStencilRenderBuffer},enumerable:!1,configurable:!0}),i.prototype.getDepthTexture=function(){return this.depthTexture},i.prototype.getStencilTexture=function(){return this.stencilTexture},i.prototype.getColorTextures=function(){return this.colorTextures},i.prototype.updateAttachmentTextures=function(){var t=this;this.attachmentTextures.length=0,this.colorTextures.forEach((function(e){e.initialize(),z(t.attachmentTextures,e.textureBuffer)})),this.stencilTexture&&z(this.attachmentTextures,this.stencilTexture.textureBuffer),this.depthTexture&&z(this.attachmentTextures,this.depthTexture.textureBuffer)},i.prototype.updateProps=function(e){var r,i,n=this.renderer,o=this.engine.gpuCapability,s=null!==(r=e.depthStencilAttachment)&&void 0!==r?r:{storageType:t.RenderPassAttachmentStorageType.none},a=e.attachments.length>0;this.externalStorage=!1;var u=!0;if(e.attachments.length>1&&!o.detail.drawBuffers)throw Error("multiple color attachments not support");var l=null===(i=e.depthStencilAttachment)||void 0===i?void 0:i.texture,c=o.detail.readableDepthStencilTextures;if(this.colorTextures=e.attachments.slice(),!a&&s.storageType!==t.RenderPassAttachmentStorageType.none)throw Error("use depth stencil attachment without color attachments");a&&(this.fbo=n.glRenderer.createGLFrameBuffer(this,this.name));var h=s.storageType;if(h===t.RenderPassAttachmentStorageType.depth_stencil_opaque){if(s.storage){if(!(s.storage instanceof ku))throw Error("invalid depth stencil attachment storage");this.depthStencilRenderBuffer=s.storage,this.externalStorage=!0}else this.depthStencilRenderBuffer=new ku({format:v.DEPTH_STENCIL,attachment:v.DEPTH_STENCIL_ATTACHMENT,storageType:h},n.glRenderer);u=!1}else if(h===t.RenderPassAttachmentStorageType.depth_16_opaque)if(s.storage){if(!(s.storage instanceof ku))throw Error("invalid depth attachment storage");this.depthStencilRenderBuffer=s.storage,this.externalStorage=!0}else this.depthStencilRenderBuffer=new ku({attachment:v.DEPTH_ATTACHMENT,format:v.DEPTH_COMPONENT16,storageType:h},n.glRenderer);else if(h===t.RenderPassAttachmentStorageType.stencil_8_opaque)if(s.storage){if(!(s.storage instanceof ku))throw Error("invalid stencil attachment storage");this.depthStencilRenderBuffer=s.storage,this.externalStorage=!0}else this.depthStencilRenderBuffer=new ku({attachment:v.STENCIL_ATTACHMENT,format:v.STENCIL_INDEX8,storageType:h},n.glRenderer);else if(h===t.RenderPassAttachmentStorageType.depth_16_texture){if(!c)throw Error("depth texture is not support in framebuffer");this.depthTexture=null!=l?l:new Eu(this.engine,{sourceType:t.TextureSourceType.framebuffer,format:v.DEPTH_COMPONENT,internalFormat:o.internalFormatDepth16,type:v.UNSIGNED_SHORT,name:"".concat(this.name,"##depthTex")}),this.depthTexture.initialize()}else if(h===t.RenderPassAttachmentStorageType.depth_24_stencil_8_texture){if(!c)throw Error("depth stencil texture is not support in framebuffer");this.depthTexture=this.stencilTexture=null!=l?l:new Eu(this.engine,{sourceType:t.TextureSourceType.framebuffer,format:v.DEPTH_STENCIL,internalFormat:o.internalFormatDepth24_stencil8,type:o.UNSIGNED_INT_24_8,name:"".concat(this.name,"##dpthStclTex")}),this.depthTexture.initialize(),u=!0}this.storeInvalidAttachments=this.getStoreAttachments(this.storeAction,u),this.updateAttachmentTextures()},i.prototype.getStoreAttachments=function(e,r){var i=this.renderer.glRenderer.gl,n=this.colorTextures.length;if(e&&g(i)&&n>0){var o=[];if(e.depthAction===t.TextureStoreAction.clear&&this.depthStorage&&z(o,r?i.DEPTH_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),e.stencilAction===t.TextureStoreAction.clear&&this.stencilStorage&&z(o,r?i.STENCIL_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),e.colorAction===t.TextureStoreAction.clear)for(var s=0;s<n;s++)z(o,i["COLOR_ATTACHMENT".concat(s)]);return o}},i.prototype.unbind=function(){var t=this.storeInvalidAttachments;if(null==t?void 0:t.length){var e=this.renderer.glRenderer.gl;e.invalidateFramebuffer(e.FRAMEBUFFER,t)}this.renderer.pipelineContext.bindSystemFramebuffer()},i.prototype.bind=function(){var t=this,e=this.renderer.glRenderer.gl,r=this.renderer.pipelineContext;if(this.fbo){var i=e.FRAMEBUFFER,n=a(this.viewport,4),o=n[0],s=n[1],u=n[2],l=n[3];r.bindFramebuffer(i,this.fbo),r.viewport(o,s,u,l);var c=this.renderer.glRenderer.emptyTexture2D.textureBuffer;Object.keys(r.textureUnitDict).forEach((function(e){var i=r.textureUnitDict[e];i!==c&&i&&t.attachmentTextures.includes(i)&&(r.activeTexture(+e),t.renderer.glRenderer.emptyTexture2D.bind())}));for(var h=0;h<4;h++)r.activeTexture(e.TEXTURE0+h),this.renderer.glRenderer.emptyTexture2D.bind();if(!this.ready){var f=this,p=f.depthStencilRenderBuffer,d=f.depthTexture,m=f.stencilTexture;if(r.activeTexture(e.TEXTURE0),p)p.setSize(u,l),e.framebufferRenderbuffer(i,p.attachment,e.RENDERBUFFER,p.buffer);else if(d){d.source.data={width:u,height:l},d.update({data:{width:u,height:l,data:new Uint16Array(0)}});var v=d&&m?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.framebufferTexture2D(i,v,e.TEXTURE_2D,d.textureBuffer,0)}this.resetColorTextures(this.colorTextures);var y=e.checkFramebufferStatus(i);if(y!==e.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer failed, status: ".concat(y,", error: ").concat(e.getError()));this.ready=!0}}},i.prototype.resetColorTextures=function(t){var e,r,i=t,n=this.renderer.glRenderer.gl,o=this.engine.gpuCapability,a=this.viewport,u=[];if(i){try{for(var l=s(i),c=l.next();!c.done;c=l.next()){c.value.initialize()}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}this.colorTextures=i.slice()}this.renderer.pipelineContext.activeTexture(n.TEXTURE0),this.colorTextures.forEach((function(t,e){var r={width:a[2],height:a[3],data:new Uint8Array(0)};t.update({data:r}),o.framebufferTexture2D(n,n.FRAMEBUFFER,e,n.TEXTURE_2D,t.textureBuffer),u.push(!0)})),o.drawBuffers(n,u),this.updateAttachmentTextures()},i.prototype.resize=function(t,e,r,i){var n=a(this.viewport,4),o=n[0],s=n[1],u=n[2],l=n[3];o===t&&s===e&&u===r&&l===i||(this.viewport=[t,e,r,i],this.ready=!1,this.bind())},i.prototype.dispose=function(e){var r,i,n=this.renderer;if(n){n.glRenderer.deleteGLFrameBuffer(this),delete this.fbo;var o=(null==e?void 0:e.depthStencilAttachment)?e.depthStencilAttachment:t.RenderPassDestroyAttachmentType.force;(o===t.RenderPassDestroyAttachmentType.force||o===t.RenderPassDestroyAttachmentType.keepExternal&&!this.externalStorage)&&(null===(r=this.depthStencilRenderBuffer)||void 0===r||r.dispose(),null===(i=this.depthTexture)||void 0===i||i.dispose()),this.renderer=this.stencilRenderBuffer=this.depthStencilRenderBuffer=null}},i}(cn);var Hu,Yu,ju=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return e>>>0},Wu=((Hu={})[v.FLOAT]=1,Hu[v.INT]=1,Hu[v.UNSIGNED_INT]=1,Hu[v.SHORT]=1,Hu[v.BOOL]=1,Hu[v.UNSIGNED_SHORT]=1,Hu[v.FLOAT_VEC2]=2,Hu[v.FLOAT_VEC3]=3,Hu[v.FLOAT_VEC4]=4,Hu[v.FLOAT_MAT2]=4,Hu[v.FLOAT_MAT3]=9,Hu[v.FLOAT_MAT4]=16,Hu[v.FLOAT_MAT2x3]=6,Hu[v.FLOAT_MAT2x4]=8,Hu[v.FLOAT_MAT4x3]=12,Hu[v.FLOAT_MAT4x2]=8,Hu[v.FLOAT_MAT3x4]=12,Hu[v.FLOAT_MAT3x2]=6,Hu[v.INT_VEC2]=2,Hu[v.INT_VEC3]=3,Hu[v.INT_VEC4]=4,Hu[v.UNSIGNED_INT_VEC2]=2,Hu[v.UNSIGNED_INT_VEC3]=3,Hu[v.UNSIGNED_INT_VEC4]=4,Hu[v.BOOL_VEC2]=2,Hu[v.BOOL_VEC3]=3,Hu[v.BOOL_VEC4]=4,Hu),Zu=Ju(Float32Array),qu=Ju(Int32Array),Ku=Ju(Uint8Array);function Qu(t){return function(e,r,i,n){var o={start:r[1],dirty:!0};if(r[2]>1){var s=e;if(s.length){for(var a=n[1]||s.length,u=r[4]/t.BYTES_PER_ELEMENT,l=o.buffer=new t(a*u),c=n[0]||0,h=0;h<a;h++)l[h*u]=s[h+c];o.start+=c*u}}else o.buffer=new t([e]);return o}}function Ju(t){return function(e,r,i,n){for(var o=r[8],s=r[2],a=r[5],u=1===s?o:r[4],l=a?u/a:1,c=u/t.BYTES_PER_ELEMENT/l,h=o/t.BYTES_PER_ELEMENT/c,f=Wu[r[0]],p=f/l,d=(n[0]||0)*f,m=n[1]?l*n[1]:h,v=new t(c*m),y={start:r[1]+u*(n[0]||0),dirty:!0,buffer:v},g=0,x=0,T=d;g<m;g++){for(var E=0;E<p;E++)v[x+E]=e[T+E];x+=c,T+=p}return y}}function $u(t,e){for(var r=[],i=[],n=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS),o=function(n){var o=t.getActiveUniformBlockName(e,n),s={index:t.getUniformBlockIndex(e,o),usedByVertexShader:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),usedByFragmentShader:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),size:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_DATA_SIZE),uniformIndices:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),used:!1,uniforms:{},name:o,id:""};s.used=s.usedByVertexShader||s.usedByFragmentShader,r[n]=s;for(var a=s.uniformIndices,u=[],l=0;l<a.length;l++){var c=t.getActiveUniform(e,a[l]).name.replace("[0]","");s.uniforms[c]=[0,0,0,0,0,0,0,l,0],u[l]=c,i.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(r,i){t.getActiveUniforms(e,a,r).forEach((function(t,e){var r=u[e];s.uniforms[r][i]=+t}))}));for(l=0;l<u.length;l++){var h=s.uniforms[u[l]],f=s.uniforms[u[l+1]],p=f?f[1]:s.size;h[8]=p-h[1]}s.id=function(t){var e=t.name,r=t.size,i=t.uniforms,n=t.uniformIndices;return Object.keys(i).map((function(t){return"".concat(t,"[").concat(i[t].join(":"),"]")})).join("+"),ju("".concat(e,"+"),"".concat(r,"+"),"".concat(n.length,"+"))}(s)+""},s=0;s<n;++s)o(s);return{blockSpecs:r,blockUniformNames:i}}(Yu={})[v.FLOAT]=Qu(Float32Array),Yu[v.INT]=Qu(Int32Array),Yu[v.UNSIGNED_INT]=Qu(Uint32Array),Yu[v.SHORT]=Qu(Int16Array),Yu[v.BOOL]=Qu(Uint8Array),Yu[v.UNSIGNED_SHORT]=Qu(Uint16Array),Yu[v.FLOAT_VEC2]=Zu,Yu[v.FLOAT_VEC3]=Zu,Yu[v.FLOAT_VEC4]=Zu,Yu[v.FLOAT_MAT2]=Zu,Yu[v.FLOAT_MAT3]=Zu,Yu[v.FLOAT_MAT4]=Zu,Yu[v.FLOAT_MAT2x3]=Zu,Yu[v.FLOAT_MAT2x4]=Zu,Yu[v.FLOAT_MAT4x3]=Zu,Yu[v.FLOAT_MAT4x2]=Zu,Yu[v.FLOAT_MAT3x4]=Zu,Yu[v.FLOAT_MAT3x2]=Zu,Yu[v.INT_VEC2]=qu,Yu[v.INT_VEC3]=qu,Yu[v.INT_VEC4]=qu,Yu[v.UNSIGNED_INT_VEC2]=qu,Yu[v.UNSIGNED_INT_VEC3]=qu,Yu[v.UNSIGNED_INT_VEC4]=qu,Yu[v.BOOL_VEC2]=Ku,Yu[v.BOOL_VEC3]=Ku,Yu[v.BOOL_VEC4]=Ku;var tl=function(){function t(t,e,r,i){var n=this;this.engine=t,this.program=e,this.shared=r,this.id=i,this.uniformBlockMap={},this.pipelineContext=t.getGLPipelineContext();var o=this.pipelineContext.gl;if(this.pipelineContext.useProgram(e),this.attribInfoMap=this.createAttribMap(),g(o)){var s=$u(o,e),a=s.blockSpecs;s.blockUniformNames,a.forEach((function(t){return n.uniformBlockMap[t.name]=t}))}this.pipelineContext.useProgram(null)}return t.prototype.bind=function(){this.pipelineContext.useProgram(this.program)},t.prototype.setupAttributes=function(t){var e,r,i=this,n=this.id,o=this.pipelineContext.gl;return t.vaos[n]?r=t.vaos[n]:((r=new Au(this.engine,"".concat(t.name,"-").concat(n)))||console.error("创建vao对象失败"),t.vaos[n]=r),r&&(r.bind(),r.ready)||(Object.keys(this.attribInfoMap).forEach((function(e){var r=i.attribInfoMap[e],n=t.attributes[e];if(n){var s=t.buffers[n.dataSource];if(!s)throw Error("no buffer named ".concat(n.dataSource||e));s.bind(),o.enableVertexAttribArray(r.loc),o.vertexAttribPointer(r.loc,n.size,n.type,n.normalize,n.stride||0,n.offset||0)}})),null===(e=t.indicesBuffer)||void 0===e||e.bind(),r&&(r.ready=!0)),r},t.prototype.createAttribMap=function(){for(var t=this.pipelineContext.gl,e=this.program,r={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),n=0;n<i;n++){var o=t.getActiveAttrib(e,n),s=o.name,a=o.type,u=o.size,l=t.getAttribLocation(e,s);r[s]={type:a,name:s,size:u,loc:l}}return r},t.prototype.dispose=function(){this.pipelineContext&&(this.pipelineContext.gl.deleteProgram(this.program),this.pipelineContext=null)},t}(),el=function(t){function e(e){var r=t.call(this,e)||this;return r.initialized=!1,r.uniformLocations={},r.samplerChannels={},r}return r(e,t),e.prototype.initialize=function(t){this.initialized||t.getGLPipelineContext().shaderLibrary.compileShader(this)},e.prototype.setFloat=function(t,e){this.pipelineContext.setFloat(this.uniformLocations[t],e)},e.prototype.setInt=function(t,e){this.pipelineContext.setInt(this.uniformLocations[t],e)},e.prototype.setFloats=function(t,e){this.pipelineContext.setFloats(this.uniformLocations[t],e)},e.prototype.setTexture=function(t,e){this.pipelineContext.setTexture(this.uniformLocations[t],this.samplerChannels[t],e)},e.prototype.setVector2=function(t,e){this.pipelineContext.setVector2(this.uniformLocations[t],e)},e.prototype.setVector3=function(t,e){this.pipelineContext.setVector3(this.uniformLocations[t],e)},e.prototype.setVector4=function(t,e){this.pipelineContext.setVector4(this.uniformLocations[t],e)},e.prototype.setQuaternion=function(t,e){this.pipelineContext.setQuaternion(this.uniformLocations[t],e)},e.prototype.setMatrix=function(t,e){this.pipelineContext.setMatrix(this.uniformLocations[t],e)},e.prototype.setMatrix3=function(t,e){this.pipelineContext.setMatrix3(this.uniformLocations[t],e)},e.prototype.setVector4Array=function(t,e){this.pipelineContext.setVector4Array(this.uniformLocations[t],e)},e.prototype.setMatrixArray=function(t,e){this.pipelineContext.setMatrixArray(this.uniformLocations[t],e)},e.prototype.fillShaderInformation=function(t,e){var r=e.slice();t=t.concat(r);for(var i,n=this.pipelineContext.getUniforms(this.program.program,t),o=0;o<t.length;o++)this.uniformLocations[t[o]]=n[o];for(i=0;i<r.length;i++){null==this.uniformLocations[r[i]]&&(r.splice(i,1),i--)}for(i=0;i<r.length;i++){var s=r[i];this.samplerChannels[s]=i}},e.prototype.dispose=function(){var t;this.compileResult&&this.compileResult.shared||null===(t=this.program)||void 0===t||t.dispose()},e}(Qr),rl=0,il=function(){function e(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}return e.prototype.compileAllShaders=function(t){var e,r,i=this;if(this.shaderAllDone)t&&t([]);else{var n=[];try{for(var o=s(Object.keys(this.cachedShaders)),a=o.next();!a.done;a=o.next()){var u=a.value;this.cachedShaders[u].initialized||n.push(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}t?n.length?Promise.all(n.map((function(t){return new Promise((function(e){return i.compileShader(i.cachedShaders[t],e)}))}))).then(t).catch((function(){return 0})):t([]):n.map((function(t){return i.compileShader(i.cachedShaders[t])})),this.shaderAllDone=!0}},e.prototype.addShader=function(e){var r=this.computeShaderCacheId(e);if(this.cachedShaders[r])return r;this.shaderAllDone=!1;var i=e.glslVersion===t.GLSLVersion.GLSL3?"#version 300 es\n":"",n=e.vertex?i+e.vertex:"",o=e.fragment?i+e.fragment:"",s=!1;return(e.shared||e.cacheId)&&(s=!0),this.cachedShaders[r]=new el({vertex:n,fragment:o,name:e.name||r,shared:s}),this.cachedShaders[r].id=r,r},e.prototype.createShader=function(t){var e=this.addShader(t);return this.cachedShaders[e]},e.prototype.compileShader=function(e,r){var i=this,n=e.source,o=!1;(n.shared||n.cacheId)&&(o=!0);var s={vertex:n.vertex,fragment:n.fragment,name:n.name,shared:o},a=this.pipelineContext.gl,u={shared:s.shared,status:t.ShaderCompileResultStatus.compiling},l=this.createProgram(a,s.vertex,s.fragment,u),c=this.glAsyncCompileExt,h=performance.now(),f=function(r){u.status=t.ShaderCompileResultStatus.success,u.compileTime=performance.now()-h,e.program=r,e.initialized=!0,e.pipelineContext=i.pipelineContext,void 0!==i.programMap[e.id]&&console.warn("find duplicated shader id",e.id),i.programMap[e.id]=r},p=function(){var n=(!r||!c||c&&1==a.getProgramParameter(u.program,c.COMPLETION_STATUS_KHR))&&l();if(n){if(u.status!==t.ShaderCompileResultStatus.fail){Ru(n,s.name);var h=new tl(i.engine,n,o,e.id);if(a.validateProgram(n),a.getProgramParameter(n,a.VALIDATE_STATUS))f(h);else{var d=a.getProgramInfoLog(n);(null==d?void 0:d.includes("the same texture"))?f(h):(u.status=t.ShaderCompileResultStatus.fail,u.error=d,console.error("compileProgramError: "+d,"\nvertex:\n",s.vertex,"\nfragment:\n",s.fragment),a.deleteProgram(n))}}r&&r(u)}else r&&requestAnimationFrame(p)};e.compileResult=u,p()},e.prototype.computeShaderCacheId=function(t){var e,r=t.vertex?t.vertex:"",i=t.fragment?t.fragment:"";return e=t.shared||t.cacheId?t.cacheId||"shared_".concat(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,i=0;i<arguments.length;i++)for(var n=t[i],o=0;o<n.length;o++)r=Math.imul(31,r)+n.charCodeAt(o)|0;return r}(r,i)):"instanced_"+rl++,e},e.prototype.createProgram=function(e,r,i,n){var o=e.createProgram(),s=this.createGLShader(e,e.VERTEX_SHADER,r),a=this.createGLShader(e,e.FRAGMENT_SHADER,i);return o&&s&&a?(e.attachShader(o,s),e.attachShader(o,a),e.linkProgram(o),n.program=o,n.status=t.ShaderCompileResultStatus.compiling,function(){if(delete n.program,!e.getProgramParameter(o,e.LINK_STATUS)){var u=nl(e,s,"vertex",r),l=nl(e,a,"fragment",i);return n.status=t.ShaderCompileResultStatus.fail,u&&(n.error=u.error,n.status=u.status),l&&(n.error=l.error,n.status=l.status),o}return o}):(n.status=t.ShaderCompileResultStatus.fail,function(){return null})},e.prototype.createGLShader=function(t,e,r){var i=e===t.VERTEX_SHADER?this.glVertShaderMap:this.glFragShaderMap,n=ju(null!=r?r:""),o=i.get(n);if(o)return o;var s=t.createShader(e);return s&&(t.shaderSource(s,r),t.compileShader(s),i.set(n,s)),s},e.prototype.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.prototype.restore=function(){},e.prototype.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}},e}();function nl(e,r,i,n){if(!e.getShaderParameter(r,e.COMPILE_STATUS)){var o=e.getShaderInfoLog(r);return console.error("compile "+i+" error: "+o,(null!=n?n:"").split("\n").map((function(t,e){return"".concat(e+1," ").concat(t)})).join("\n")),{error:o,status:t.ShaderCompileResultStatus.fail}}}var ol=function(){function t(t,e){this.engine=t,this.gl=e,this.gl=e,this.shaderLibrary=new il(t,this),this.maxTextureCount=this.gl.TEXTURE0+this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1,this.reset()}return t.prototype.dispose=function(){this.shaderLibrary.dispose(),this.reset()},t.prototype.reset=function(){this.glCapabilityCache={},this.activeTextureIndex=v.TEXTURE0,this.textureUnitDict={},this.currentFramebuffer={},this.pixelStorei={},this.currentRenderBuffer={}},t.prototype.toggle=function(t,e){e?this.enable(t):this.disable(t)},t.prototype.enable=function(t){!0!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!0,this.gl.enable(t))},t.prototype.disable=function(t){!1!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!1,this.gl.disable(t))},t.prototype.bindFramebuffer=function(t,e){this.currentFramebuffer[t]!==e&&(this.currentFramebuffer[t]=e,this.gl.bindFramebuffer(t,e))},t.prototype.bindRenderBuffer=function(t,e){this.currentRenderBuffer[t]!==e&&(this.currentRenderBuffer[t]=e,this.gl.bindRenderbuffer(t,e))},t.prototype.bindSystemFramebuffer=function(){this.bindFramebuffer(this.gl.FRAMEBUFFER,null)},t.prototype.useProgram=function(t){this.set1("useProgram",t)},t.prototype.clear=function(t){this.gl.clear(t)},t.prototype.clearDepth=function(t){this.set1("clearDepth",t)},t.prototype.depthFunc=function(t){this.set1("depthFunc",t)},t.prototype.depthMask=function(t){this.set1("depthMask",t)},t.prototype.polygonOffset=function(t,e){this.set2("polygonOffset",t,e)},t.prototype.depthRange=function(t,e){this.set2("depthRange",t,e)},t.prototype.clearStencil=function(t){this.set1("clearStencil",t)},t.prototype.stencilMask=function(t){this.stencilMaskSeparate(this.gl.FRONT,t),this.stencilMaskSeparate(this.gl.BACK,t)},t.prototype.stencilFunc=function(t,e,r){this.stencilFuncSeparate(this.gl.FRONT,t,e,r),this.stencilFuncSeparate(this.gl.BACK,t,e,r)},t.prototype.stencilFuncSeparate=function(t,e,r,i){this.set4("stencilFuncSeparate",t,e,r,i)},t.prototype.stencilMaskSeparate=function(t,e){this.set2("stencilMaskSeparate",t,e)},t.prototype.stencilOp=function(t,e,r){this.stencilOpSeparate(this.gl.FRONT,t,e,r),this.stencilOpSeparate(this.gl.BACK,t,e,r)},t.prototype.stencilOpSeparate=function(t,e,r,i){this.set4("stencilOpSeparate",t,e,r,i)},t.prototype.cullFace=function(t){this.set1("cullFace",t)},t.prototype.frontFace=function(t){this.set1("frontFace",t)},t.prototype.clearColor=function(t,e,r,i){this.set4("clearColor",t,e,r,i)},t.prototype.colorMask=function(t,e,r,i){this.set4("colorMask",t,e,r,i)},t.prototype.blendColor=function(t,e,r,i){this.set4("blendColor",t,e,r,i)},t.prototype.blendFunc=function(t,e){this.blendFuncSeparate(t,e,t,e)},t.prototype.blendFuncSeparate=function(t,e,r,i){this.set4("blendFuncSeparate",t,e,r,i)},t.prototype.blendEquation=function(t){this.set1("blendEquation",t)},t.prototype.blendEquationSeparate=function(t,e){this.set2("blendEquationSeparate",t,e)},t.prototype.setPixelStorei=function(t,e){this.pixelStorei[t]!==e&&(this.pixelStorei[t]=e,this.gl.pixelStorei(t,e))},t.prototype.viewport=function(t,e,r,i){this.set4("viewport",t,e,r,i)},t.prototype.activeTexture=function(t){t=Math.min(t,this.maxTextureCount),this.activeTextureIndex!==t&&(this.activeTextureIndex=t,this.gl.activeTexture(t))},t.prototype.bindTexture=function(t,e,r){(this.currentTextureBinding!==e||r)&&(this.gl.bindTexture(t,e),this.currentTextureBinding=e),this.textureUnitDict[this.activeTextureIndex]=e},t.prototype.set1=function(t,e){this.glCapabilityCache[t]!==e&&(this.glCapabilityCache[t]=e,this.gl[t](e))},t.prototype.set2=function(t,e,r){var i=this.glCapabilityCache[t];i||(i=this.glCapabilityCache[t]={x:NaN,y:NaN}),i.x===e&&i.y===r||this.gl[t](i.x=e,i.y=r)},t.prototype.set3=function(t,e,r,i){var n=this.glCapabilityCache[t];n||(n=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN}),n.x===e&&n.y===r&&n.z===i||this.gl[t](n.x=e,n.y=r,n.z=i)},t.prototype.set4=function(t,e,r,i,n){var o=this.glCapabilityCache[t];o||(o=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN,w:NaN}),o.x===e&&o.y===r&&o.z===i&&o.w===n||this.gl[t](o.x=e,o.y=r,o.z=i,o.w=n)},t.prototype.get=function(t){return this.glCapabilityCache[t]},t.prototype.setFloat=function(t,e){t&&this.gl.uniform1f(t,e)},t.prototype.setInt=function(t,e){t&&this.gl.uniform1i(t,e)},t.prototype.setFloats=function(t,e){t&&this.gl.uniform1fv(t,e)},t.prototype.setVector2=function(t,e){this.setFloat2(t,e.x,e.y)},t.prototype.setVector3=function(t,e){this.setFloat3(t,e.x,e.y,e.z)},t.prototype.setVector4=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},t.prototype.setQuaternion=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},t.prototype.setVector4Array=function(t,e){t&&e.length%4==0&&this.gl.uniform4fv(t,e)},t.prototype.setMatrix=function(t,e){t&&this.gl.uniformMatrix4fv(t,!1,e.elements)},t.prototype.setMatrix3=function(t,e){t&&this.gl.uniformMatrix3fv(t,!1,e.elements)},t.prototype.setMatrixArray=function(t,e){t&&e.length%16==0&&this.gl.uniformMatrix4fv(t,!1,e)},t.prototype.setTexture=function(t,e,r){if(t){this.gl.activeTexture(this.gl.TEXTURE0+e);var i=r.target;this.gl.bindTexture(i,r.textureBuffer),this.gl.uniform1i(t,e)}},t.prototype.getUniforms=function(t,e){for(var r=[],i=0;i<e.length;i++)r.push(this.gl.getUniformLocation(t,e[i]));return r},t.prototype.setFloat4=function(t,e,r,i,n){t&&this.gl.uniform4f(t,e,r,i,n)},t.prototype.setFloat3=function(t,e,r,i){t&&this.gl.uniform3f(t,e,r,i)},t.prototype.setFloat2=function(t,e,r){t&&this.gl.uniform2f(t,e,r)},t}(),sl=function(t){function e(e){var r=t.call(this)||this;return r.gpuCapability=new nn(e),r}return r(e,t),e.prototype.dispose=function(){this.isDestroyed||t.prototype.dispose.call(this)},e.prototype.getGLRenderer=function(){return this.renderer},e.prototype.getGLRendererInternal=function(){return this.getGLRenderer().glRenderer},e.prototype.getGLPipelineContext=function(){return this.getGLRenderer().pipelineContext},e}(yu),al=function(e){function n(r,n,o){var s=e.call(this)||this;s.canvas=r,s.temporaryRTs={};var a=i({preserveDrawingBuffer:void 0,alpha:!0,stencil:!0,antialias:!0,depth:!0,premultipliedAlpha:!0},o);s.context=new Uu(r,n,a);var u=s.context.gl;return rt(u),s.engine=new sl(u),s.engine.renderer=s,s.pipelineContext=new ol(s.engine,u),s.glRenderer=new Cu(s.engine),s.extension=new zu(s),s.renderingData={currentFrame:{}},s.frameBuffer=new Xu({storeAction:{},viewport:[0,0,s.width,s.height],attachments:[new Eu(s.engine,{sourceType:t.TextureSourceType.framebuffer,data:{width:s.width,height:s.height}})],depthStencilAttachment:{storageType:t.RenderPassAttachmentStorageType.none}},s),s}return r(n,e),Object.defineProperty(n.prototype,"isDestroyed",{get:function(){var t=this.glRenderer;return!t||t.isDestroyed},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){var t,e;return null!==(e=null===(t=this.glRenderer)||void 0===t?void 0:t.height)&&void 0!==e?e:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){var t,e;return null!==(e=null===(t=this.glRenderer)||void 0===t?void 0:t.width)&&void 0!==e?e:0},enumerable:!1,configurable:!0}),n.prototype.renderRenderFrame=function(t){var e,r,i,n,o,a,u=t;u.resource&&u.resource.color_b.initialize(),u.emptyTexture.initialize(),u.transparentTexture.initialize();var l=u._renderPasses;if(this.isDestroyed)return console.error("renderer is destroyed",this);u.renderer.getShaderLibrary().compileAllShaders(),this.setFrameBuffer(null),this.clear(u.clearAction),this.renderingData.currentFrame=u,this.renderingData.currentCamera=u.camera,J(l);try{for(var c=s(l),h=c.next();!h.done;h=c.next()){var f=(m=h.value).delegate;null===(o=f.willBeginRenderPass)||void 0===o||o.call(f,m,this.renderingData),this.renderRenderPass(m),null===(a=f.didEndRenderPass)||void 0===a||a.call(f,m,this.renderingData)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}try{for(var p=s(l),d=p.next();!d.done;d=p.next()){var m;(m=d.value).frameCleanup(this)}}catch(t){i={error:t}}finally{try{d&&!d.done&&(n=p.return)&&n.call(p)}finally{if(i)throw i.error}}},n.prototype.renderRenderPass=function(t){this.renderingData.currentPass=t,t.initialize(this),t.configure(this),t.execute(this)},n.prototype.renderMeshes=function(t){var e,r,i,n,o=this.renderingData.currentPass.delegate;try{for(var a=s(t),u=a.next();!u.done;u=a.next()){var l=u.value;l.isDestroyed||l.getVisible()&&(l.material?(l.material.initialize(),l.geometry.initialize(),null===(i=o.willRenderMesh)||void 0===i||i.call(o,l,this.renderingData),l.render(this),null===(n=o.didRenderMesh)||void 0===n||n.call(o,l,this.renderingData)):console.warn("Mesh "+l.name+" 没有绑定材质。"))}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}},n.prototype.setGlobalFloat=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.floats[t]=e},n.prototype.setGlobalInt=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.ints[t]=e},n.prototype.setGlobalMatrix=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.matrices[t]=e},n.prototype.drawGeometry=function(t,e){this.glRenderer.drawGeometry(t,e)},n.prototype.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()))},n.prototype.getFrameBuffer=function(){return this.frameBuffer},n.prototype.getTemporaryRT=function(e,r,i,n,o,s){if(this.temporaryRTs[e])return this.temporaryRTs[e];var a,u,l=t.RenderPassAttachmentStorageType.none;o===t.FilterMode.Linear?a=v.LINEAR:o===t.FilterMode.Nearest&&(a=v.NEAREST),s===t.RenderTextureFormat.RGBA32?u=v.UNSIGNED_BYTE:s===t.RenderTextureFormat.RGBAHalf&&(u=v.HALF_FLOAT),0===n?l=t.RenderPassAttachmentStorageType.none:16===n?l=t.RenderPassAttachmentStorageType.depth_16_opaque:24===n&&(l=t.RenderPassAttachmentStorageType.depth_24_stencil_8_texture);var c=new Eu(this.engine,{sourceType:t.TextureSourceType.framebuffer,minFilter:a,magFilter:a,internalFormat:v.RGBA,format:v.RGBA,type:u}),h=new Xu({name:e,storeAction:{},viewport:[0,0,r,i],viewportScale:1,isCustomViewport:!0,attachments:[c],depthStencilAttachment:{storageType:l}},this);return this.temporaryRTs[e]=h,h},n.prototype.setViewport=function(t,e,r,i){this.pipelineContext.viewport(t,e,r,i)},n.prototype.clear=function(e){var r=this.pipelineContext,i=0;if(e.colorAction===t.TextureLoadAction.clear){var n=e.clearColor;n&&r.clearColor(n[0],n[1],n[2],n[3]),r.colorMask(!0,!0,!0,!0),i=v.COLOR_BUFFER_BIT}if(e.stencilAction===t.TextureLoadAction.clear&&(r.stencilMask(255),r.clearStencil(e.clearStencil||0),i|=v.STENCIL_BUFFER_BIT),e.depthAction===t.TextureLoadAction.clear){var o=e.clearDepth;r.depthMask(!0),r.clearDepth(Number.isFinite(o)?o:1),i|=v.DEPTH_BUFFER_BIT}i&&r.clear(i)},n.prototype.addLostHandler=function(t){this.context.addLostHandler(t)},n.prototype.addRestoreHandler=function(t){this.context.addRestoreHandler(t)},n.prototype.getShaderLibrary=function(){return this.pipelineContext.shaderLibrary},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},n.prototype.dispose=function(t){var e;this.context.dispose(),this.extension.dispose(),this.pipelineContext.dispose(),null===(e=this.glRenderer)||void 0===e||e.dispose(t),this.canvas=null,this.engine.dispose()},n.prototype.lost=function(t){t.preventDefault(),this.pipelineContext.dispose(),this.extension.dispose(),this.glRenderer.lost(t)},n.prototype.restore=function(){var t=this.context.gl;if(!t)throw new Error("Can not restore automatically because losing gl context");this.engine=new sl(t),this.engine.renderer=this,this.pipelineContext=new ol(this.engine,t),this.glRenderer=new Cu(this.engine),this.extension=new zu(this)},n.prototype.resize=function(t,e){var r=this.glRenderer;r&&(this.width===t&&this.height===e||r.resize(t,e))},n.prototype.checkGlobalUniform=function(t){var e=this.renderingData.currentFrame.globalUniforms;e.uniforms.includes(t)||e.uniforms.push(t)},n}(hn),ul="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",ll="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",cl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",hl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",fl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",pl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg";var dl=new Map,ml=!1,vl=1,yl=function(){function e(t){var e,r,a=this;this.compositions=[],this.displayScale=1,this.resumePending=!1,this.disposed=!1,this.speed=1,this.baseCompositionIndex=0,this.lost=function(t){var e,r;null===(e=a.ticker)||void 0===e||e.pause(),a.compositions.forEach((function(e){return e.lost(t)})),a.renderer.lost(t),null===(r=a.handleWebGLContextLost)||void 0===r||r.call(a,t),xl(a,!1)},this.restore=function(){return n(a,void 0,void 0,(function(){var t,e,r,i=this;return o(this,(function(s){switch(s.label){case 0:return this.renderer.restore(),t=this,[4,Promise.all(this.compositions.map((function(t){return n(i,void 0,void 0,(function(){var e,r,i,n,s,a,u,l,c,h,f,p;return o(this,(function(o){switch(o.label){case 0:return e=t.time,r=t.url,i=t.speed,n=t.keepResource,s=t.reusable,a=t.renderOrder,u=t.transform,l=t.videoState,[4,this.loadScene(r)];case 1:(c=o.sent()).speed=i,c.reusable=s,c.keepResource=n,c.renderOrder=a,c.transform=u,h=0,o.label=2;case 2:return h<l.length?l[h]?((f=c.textures[h].source.video).currentTime=null!==(p=l[h])&&void 0!==p?p:0,[4,f.play()]):[3,4]:[3,5];case 3:o.sent(),o.label=4;case 4:return h++,[3,2];case 5:return c.content.start(),c.gotoAndPlay(e),[2,c]}}))}))})))];case 1:return t.compositions=s.sent(),null===(e=this.handleWebGLContextRestored)||void 0===e||e.call(this),null===(r=this.ticker)||void 0===r||r.resume(),[2]}}))}))},this.handleResume=function(){var t;null===(t=a.handlePlayableUpdate)||void 0===t||t.call(a,{player:a,playing:!0})},this.handleClick=function(t){var e=t.x,r=t.y;a.compositions.forEach((function(t){var n,o=t.hitTest(e,r);if(o.length)for(var s=0;s<o.length;s++){var u=o[s].behavior||O.NOTIFY;u===O.NOTIFY?null===(n=a.handleItemClicked)||void 0===n||n.call(a,i(i({},o[s]),{composition:t.name,player:a})):u===O.RESUME_PLAYER&&a.resume()}}))};var u=t.container,l=t.canvas,c=t.gl,h=t.fps,f=t.name,p=t.pixelRatio,d=t.manualRender,v=t.interactive,y=t.reportGPUTime,g=t.onMessageItem,x=t.onPausedByItem,T=t.onItemClicked,E=t.onPlayableUpdate,S=t.onRenderError,b=t.onWebGLContextLost,A=t.onWebGLContextRestored,_=t.renderFramework,C=t.env,R=void 0===C?"":C,w=t.notifyTouch;if(m.length)throw new Error("Errors before player create: ".concat(m.map((function(t,e){return"\n ".concat(e+1,": ").concat(t)}))));var M=null!==(r=null!==(e=t.renderOptions)&&void 0!==e?e:t)&&void 0!==r?r:{},L=M.willCaptureImage,I=M.premultiplyAlpha;if(!ml&&"debug-disable"!==_){var P,F=Z()||(P=/iPhone OS (\d+)_(\d+)/.exec(navigator.userAgent))&&("13"===P[1]||"16"===P[1]&&"5"===P[2])?"webgl":"webgl2";if(_&&(F="webgl"===_?"webgl":"webgl2"),this.handleWebGLContextLost=b,this.handleWebGLContextRestored=A,this.reportGPUTime=y,this.handleItemClicked=T,this.handleMessageItem=g,this.handlePlayableUpdate=E,this.handleRenderError=S,this.handlePlayerPause=function(t){a.pause(),null==x||x({name:t.name,player:a})},this.pixelRatio=Number.isFinite(p)?p:W(),this.offscreenMode=!0,this.env=R,l)this.canvas=l;else if(c){this.canvas=c.canvas;var N=c instanceof WebGLRenderingContext?"webgl":"webgl2";F!==N&&(Be.error("The gl context(".concat(N,") is inconsistent with renderFramework or default version(").concat(F,")")),F=N)}else Tl(u),this.canvas=document.createElement("canvas"),u.appendChild(this.canvas);this.renderer=hn.create(this.canvas,F,{preserveDrawingBuffer:L,premultipliedAlpha:I}),this.renderer.env=R,this.renderer.addLostHandler({lost:this.lost}),this.renderer.addRestoreHandler({restore:this.restore}),this.gpuCapability=this.renderer.engine.gpuCapability,dl.forEach((function(t){t.gpuCapability.type!==a.gpuCapability.type&&Be.warn("Create player with different webgl version: old=".concat(t.gpuCapability.type,", new=").concat(a.gpuCapability.type))})),d||(this.ticker=new gu(h),this.ticker.add(this.tick.bind(this))),this.event=new yr(this.canvas,!!w),this.event.bindListeners(),this.event.addEventListener(fr,this.handleClick),this.interactive=null!=v&&v,this.name=f||"".concat(vl++),c||this.resize(),Tn(this.gpuCapability.detail),this.container=this.canvas.parentElement,dl.set(this.canvas,this),function(){var t,e,r=[];try{for(var i=s(dl.values()),n=i.next();!n.done;n=i.next()){var o=n.value;o.paused||r.push(o)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}r.length>1&&Be.error("Current running player count: ".concat(r.length,", see ").concat(pl),r)}(),xl(this,!0)}}return e.prototype.setSpeed=function(t){isNaN(t)||(this.speed=t)},e.prototype.getSpeed=function(){return this.speed},e.prototype.getCompositionByName=function(t){return this.compositions.find((function(e){return e.name===t}))},e.prototype.getCompositions=function(){return this.compositions},Object.defineProperty(e.prototype,"hasPlayable",{get:function(){return this.compositions.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){var t;return null===(t=this.ticker)||void 0===t?void 0:t.getPaused()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"interactive",{get:function(){return this.event.enabled},set:function(t){this.event.enabled=t},enumerable:!1,configurable:!0}),e.prototype.loadScene=function(t,e){var r;return n(this,void 0,void 0,(function(){var i,s,a=this;return o(this,(function(u){switch(u.label){case 0:return s=this.baseCompositionIndex,Ge(t)?(this.baseCompositionIndex+=t.length,[4,Promise.all(t.map((function(t,r){return n(a,void 0,void 0,(function(){var i;return o(this,(function(n){switch(n.label){case 0:return[4,this.createComposition(t,e)];case 1:return(i=n.sent()).setIndex(s+r),[2,i]}}))}))})))]):[3,2];case 1:return i=u.sent(),[3,4];case 2:return this.baseCompositionIndex+=1,[4,this.createComposition(t,e)];case 3:(i=u.sent()).setIndex(s),u.label=4;case 4:return null===(r=this.ticker)||void 0===r||r.start(),[2,i]}}))}))},e.prototype.createComposition=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var r,n,s,a,u,l,c,h=this;return o(this,(function(o){switch(o.label){case 0:return r=this.renderer,n=performance.now(),s=i({autoplay:!0},e),gl(t)?(a=t.scene,s=i(i({},s),t.options||{})):a=t,this.assetManager?this.assetManager.updateOptions(s):this.assetManager=new hu(s),[4,this.assetManager.loadScene(a,this.renderer,{env:this.env})];case 1:if(u=o.sent(),this.disposed)throw new Error("Disposed player can not used to create Composition");return l=new vu(i(i({},s),{renderer:r,width:r.getWidth(),height:r.getHeight(),event:this.event,onPlayerPause:this.handlePlayerPause,onMessageItem:this.handleMessageItem}),u),this.ticker&&l.renderLevel===E.B&&this.ticker.setFPS(Math.min(this.ticker.getFPS(),30)),[4,new Promise((function(t){h.renderer.getShaderLibrary().compileAllShaders((function(){t(null)}))}))];case 2:return o.sent(),s.autoplay?(this.autoPlaying=!0,l.play()):l.pause(),c=performance.now()-n+l.statistic.loadTime,l.statistic.firstFrameTime=c,Be.info("first frame: [".concat(l.name,"]").concat(c.toFixed(4),"ms")),this.compositions.push(l),[2,l]}}))}))},e.prototype.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)||void 0===t||t.start()},e.prototype.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)},e.prototype.gotoAndStop=function(t){var e,r;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?void 0:e.getPaused())||this.doTick(0,!0),null===(r=this.handlePlayableUpdate)||void 0===r||r.call(this,{player:this,playing:!1})},e.prototype.playSequence=function(t){for(var e,r=function(e){var r=t[e],i=r.onEnd;r.onEnd=function(){null==i||i.call(r,r),t[e+1].play()}},i=0;i<t.length-1;i++)r(i);t[0].play(),null===(e=this.ticker)||void 0===e||e.start()},e.prototype.pause=function(t){var e,r;this.paused||(null===(e=this.ticker)||void 0===e||e.pause(),null===(r=this.handlePlayableUpdate)||void 0===r||r.call(this,{player:this,playing:!1}),t&&t.offloadTexture&&this.offloadTexture())},e.prototype.resume=function(){var t;return n(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.resumePending?[2]:this.paused?(this.resumePending=!0,[4,Promise.all(this.compositions.map((function(t){return t.reloadTexture()})))]):[3,2];case 1:e.sent(),this.resumePending=!1,this.handleResume(),e.label=2;case 2:return null===(t=this.ticker)||void 0===t||t.resume(),[2]}}))}))},e.prototype.tick=function(t){this.doTick(t,this.forceRenderNextFrame),this.forceRenderNextFrame=!1},e.prototype.doTick=function(e,r){var i,n,o,s=this;e=Math.min(e,33)*this.speed;var a=this.compositions,u=!1;a.sort((function(t,e){return t.getIndex()-e.getIndex()})),this.compositions=[];for(var l=0;l<a.length;l++){var c=a[l];c.textureOffloaded?(u=!0,Be.error("Composition ".concat(c.name," texture offloaded, skip render.")),this.compositions.push(c)):(!c.isDestroyed&&c.renderer&&c.update(e),c.isDestroyed||this.compositions.push(c))}if(this.baseCompositionIndex=this.compositions.length,u)return null===(i=this.handleRenderError)||void 0===i||i.call(this,new Error("play when texture offloaded")),null===(n=this.ticker)||void 0===n?void 0:n.pause();if(!this.paused||r){var h=this.gpuCapability.level,f=this.renderer.context.gl,p=2===h&&this.reportGPUTime?d(f):void 0;if(null==p||p.begin(),this.compositions.length||this.compositions.length<a.length||r){this.renderer.setFrameBuffer(null),this.renderer.clear({stencilAction:t.TextureLoadAction.clear,clearStencil:0,depthAction:t.TextureLoadAction.clear,clearDepth:1,colorAction:t.TextureLoadAction.clear,clearColor:[0,0,0,0]});for(l=0;l<a.length;l++)!a[l].renderFrame.isDestroyed&&this.renderer.renderRenderFrame(a[l].renderFrame)}null==p||p.end(),null==p||p.getTime().then((function(t){var e;return null===(e=s.reportGPUTime)||void 0===e?void 0:e.call(s,null!=t?t:0)})).catch,this.autoPlaying&&(null===(o=this.handlePlayableUpdate)||void 0===o||o.call(this,{player:this,playing:!0}))}},e.prototype.resizeToAspect=function(t,e){void 0===e&&(e=1),t!==this.displayAspect&&(this.displayAspect=t),e!==this.displayScale&&(this.displayScale=e),this.resize()},e.prototype.resize=function(){var t,e,r,i,n,o=this.canvas.parentElement;if(o){var s=this.getTargetSize(o);e=s[0],r=s[1],i=s[2],n=s[3]}else e=i=this.canvas.width,r=n=this.canvas.height;var a=e/r;if(e&&r){var u=document.documentElement.clientWidth;i>2*u&&Be.error("DPI overflowed, width ".concat(i," is more than 2x document width ").concat(u,", see ").concat(ll));var l=this.env?this.gpuCapability.detail.maxTextureSize:2048;(i>l||n>l)&&(Be.error("Container size overflowed ".concat(i,"x").concat(n,", see ").concat(ul)),a>1?(i=Math.round(l),n=Math.round(l/a)):(n=Math.round(l),i=Math.round(l*a))),this.renderer.resize(i,n),this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",Be.info("Resize player ".concat(this.name," [").concat(i,",").concat(n,",").concat(e,",").concat(r,"].")),null===(t=this.compositions)||void 0===t||t.forEach((function(t){t.camera.aspect=a}))}},e.prototype.clearCanvas=function(e){e?this.renderer.clear({stencilAction:t.TextureLoadAction.clear,clearStencil:0,depthAction:t.TextureLoadAction.clear,clearDepth:1,colorAction:t.TextureLoadAction.clear,clearColor:[0,0,0,0]}):this.forceRenderNextFrame=!0},e.prototype.destroyItem=function(t,e){},e.prototype.destroyCurrentCompositions=function(){this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.baseCompositionIndex=0},e.prototype.dispose=function(t){var e,r;if(Be.info("call player destroy: ".concat(this.name)),!this.disposed){dl.delete(this.canvas),this.pause(),null===(e=this.ticker)||void 0===e||e.stop(),null===(r=this.assetManager)||void 0===r||r.dispose(),this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.renderer.context.removeLostHandler({lost:this.lost}),this.renderer.context.removeRestoreHandler({restore:this.restore}),this.event.dispose(),this.renderer.dispose(!t),xl(this,!1),this.canvas instanceof HTMLCanvasElement&&!t&&this.renderer.context&&(_s.dispose(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas.remove());var i,n=(i=this.name,"Never use destroyed player: ".concat(i," again, see ").concat(fl)),o=function(){return function(t){throw new Error(t)}(n)},s=function(){return t=n,Promise.reject(t);var t};this.tick=o,this.resize=o,this.loadScene=s,this.play=s,this.gotoAndPlay=s,this.gotoAndStop=s,this.playSequence=o,this.destroyCurrentCompositions=o,this.resume=s,this.disposed=!0}},e.prototype.offloadTexture=function(){this.compositions.forEach((function(t){return t.offloadTexture()}))},e.prototype.getTargetSize=function(t){Tl(t);var e,r,i=this.displayAspect;i?t.clientWidth/t.clientHeight>i?e=(r=t.clientHeight*this.displayScale)*i:r=(e=t.clientWidth*this.displayScale)/i:(e=t.clientWidth,r=t.clientHeight);var n=this.pixelRatio,o=e,s=r;if(e=Math.round(e*n),(r=Math.round(r*n))<1||r<1){if(!this.offscreenMode)throw Error("Invalid container size ".concat(e,"x").concat(r,", see ").concat(cl));e=r=o=s=1}return[o,s,e,r]},e}();function gl(t){return He(t)&&"scene"in t&&"options"in t}function xl(t,e){Object.keys($e).forEach((function(r){var i=$e[r],n=e?i.onPlayerCreated:i.onPlayerDestroy;null==n||n(t)}))}function Tl(t){if(null==t)throw new Error("Container is not an HTMLElement, see ".concat(hl))}Vr.create=function(t,e){return new Eu(t,e)},Vr.createWithData=function(e,r,i){void 0===r&&(r=K("#fff")),void 0===i&&(i={});var n=i,o=n.type,s=void 0===o?v.UNSIGNED_BYTE:o,a=n.format,u=void 0===a?v.RGBA:a,l=n.internalFormat,c=n.wrapS,h=void 0===c?v.MIRRORED_REPEAT:c,f=n.wrapT,p=void 0===f?v.MIRRORED_REPEAT:f,d=n.minFilter,m=void 0===d?v.NEAREST:d,y=n.magFilter,g=void 0===y?v.NEAREST:y,x=n.flipY,T=void 0!==x&&x;return new Eu(e,{data:r,type:s,sourceType:t.TextureSourceType.data,format:u,internalFormat:l||u,wrapS:h,wrapT:p,minFilter:m,magFilter:g,flipY:T})},qr.create=function(t,e){return new Du(t,e)},li.create=function(t,e){return new Pu(t,e)},gi.create=function(t,e){return new gi(t,e)},en.create=function(t){return new ku(t)},cn.create=function(t,e){return new Xu(t,e)},hn.create=function(t,e,r){return new al(t,e,r)},yu.create=function(t){return new sl(t)};var El="1.2.2";Be.info("player version: "+El),t.AbstractPlugin=sr,t.AssetManager=hu,t.BYTES_TYPE_MAP=ui,t.BezierSegments=Ee,t.COMPRESSED_TEXTURE=un,t.COPY_FRAGMENT_SHADER=ei,t.COPY_MESH_SHADER_ID=$r,t.COPY_VERTEX_SHADER=ti,t.CalculateItem=In,t.CalculateLoader=ls,t.CalculateVFXItem=cs,t.Camera=js,t.CameraController=ar,t.CameraVFXItem=lr,t.CameraVFXItemLoader=ur,t.Composition=vu,t.CompositionSourceManager=uu,t.CurveValue=ge,t.DEFAULT_FONTS=Es,t.Downloader=Rr,t.EFFECTS_COPY_MESH_NAME=Jr,t.EVENT_TYPE_CLICK=fr,t.EVENT_TYPE_TOUCH_END=mr,t.EVENT_TYPE_TOUCH_MOVE=dr,t.EVENT_TYPE_TOUCH_START=pr,t.Engine=yu,t.EventSystem=yr,t.FILTER_NAME_NONE=h,t.FilterSpriteVFXItem=zn,t.Float16ArrayWrapper=Zt,t.FrameBuffer=cn,t.GLEngine=sl,t.GLGeometry=Pu,t.GLRenderer=al,t.GPUCapability=nn,t.Geometry=li,t.GlobalUniforms=tn,t.GradientValue=ye,t.HELP_LINK=f,t.InteractBehavior=vr,t.InteractItem=yn,t.InteractLoader=vn,t.InteractMesh=pn,t.InteractVFXItem=dn,t.KTXTexture=zr,t.LineSegments=xe,t.LinearValue=ve,t.Material=qr,t.MaterialDataBlock=Hr,t.Mesh=gi,t.PLAYER_OPTIONS_ENV_EDITOR=c,t.POST_PROCESS_SETTINGS="post_process_settings",t.ParticleLoader=as,t.ParticleMesh=Bn,t.ParticleSystem=Zo,t.ParticleVFXItem=ss,t.PassTextureCache=si,t.PathSegments=Te,t.Player=yl,t.PluginSystem=ir,t.QCanvasViewer=vs,t.QText=ms,t.RENDER_PASS_NAME_PREFIX=qi,t.RENDER_PREFER_LOOKUP_TEXTURE=hi,t.RUNTIME_ENV="runtime_env",t.RandomSetValue=pe,t.RandomValue=de,t.RandomVectorValue=me,t.RenderBuffer=en,t.RenderFrame=Qi,t.RenderPass=bi,t.RenderPassPriorityNormal=xi,t.RenderPassPriorityPostprocess=3e3,t.RenderPassPriorityPrepare=0,t.RenderTargetHandle=Ei,t.Renderer=hn,t.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0="PRE_MAIN_COLOR_0",t.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0="PRE_MAIN_COLOR_SIZE_0",t.SEMANTIC_PRE_COLOR_ATTACHMENT_0="PRE_COLOR_0",t.SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0="PRE_COLOR_SIZE_0",t.SPRITE_VERTEX_STRIDE=l,t.SemanticMap=ai,t.Shader=Qr,t.SpriteItem=Nn,t.SpriteLoader=wn,t.SpriteMesh=xn,t.SpriteVFXItem=Vn,t.StaticValue=fe,t.TEMPLATE_USE_OFFSCREEN_CANVAS=fi,t.TextItem=Is,t.TextLoader=Fs,t.TextMesh=hs,t.TextVFXItem=Ps,t.Texture=Vr,t.TextureFactory=kr,t.Ticker=gu,t.TimelineComponent=Ne,t.Transform=Ke,t.VFXItem=Qe,t.ValueGetter=he,t.addByOrder=$,t.addItem=z,t.addItemWithOrder=U,t.alphaFrameFrag=Mi,t.alphaMaskFrag=Li,t.assertExist=rt,t.asserts=function(t,e){if(void 0===e&&(e="asserts failed"),!t)throw new Error(e)}
|
|
14
|
+
*/!function(t){t.S="S",t.APlus="A+",t.A="A",t.BPlus="B+",t.B="B"}(Ws||(Ws={})),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"}(Zs||(Zs={})),function(t){t[t.DOUBLE=1032]="DOUBLE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK"}(qs||(qs={})),function(t){t[t.NONE=0]="NONE",t[t.MASK=1]="MASK",t[t.OBSCURED=2]="OBSCURED",t[t.REVERSE_OBSCURED=3]="REVERSE_OBSCURED"}(Ks||(Ks={})),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"}(Qs||(Qs={})),function(t){t[t.GYROSCOPE=0]="GYROSCOPE",t[t.SPINE=1]="SPINE"}(Js||(Js={})),function(t){t[t.CLICK=0]="CLICK",t[t.MESSAGE=1]="MESSAGE",t[t.DRAG=2]="DRAG"}($s||($s={})),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"}(ta||(ta={})),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.filter="8",t.spine="spine",t.mesh="mesh",t.tree="tree",t.text="text",t.light="light",t.skybox="skybox"}(ea||(ea={})),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"}(ra||(ra={})),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"}(ia||(ia={}));var oa,sa,aa,ua,la,ca,ha,fa,pa,da,ma,va,ya,ga,xa,Ta,Ea,Sa=0;!function(t){t[t.portrait=1]="portrait",t[t.landscape=Sa]="landscape"}(oa||(oa={})),function(t){t[t.destroy=0]="destroy",t[t.pause=1]="pause",t[t.restart=5]="restart",t[t.forward=2]="forward",t[t.pause_destroy=3]="pause_destroy"}(sa||(sa={})),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"}(aa||(aa={})),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"}(ua||(ua={})),function(t){t[t.destroy=0]="destroy",t[t.loop=5]="loop",t[t.freeze=4]="freeze"}(la||(la={})),function(t){t[t.destroyChildren=6]="destroyChildren"}(ca||(ca={})),function(t){t[t.none=0]="none",t[t.removeParticle=1]="removeParticle"}(ha||(ha={})),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"}(fa||(fa={})),function(t){t[t.box=2]="box",t[t.sphere=3]="sphere"}(pa||(pa={})),function(t){t.unlit="unlit",t.pbr="pbr",t.hair="hair"}(da||(da={})),function(t){t[t.opaque=100]="opaque",t[t.masked=101]="masked",t[t.translucent=102]="translucent",t[t.additive=103]="additive"}(ma||(ma={})),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"}(va||(va={})),function(t){t[t.display=0]="display",t[t.clip=1]="clip",t[t.ellipsis=2]="ellipsis"}(ya||(ya={})),function(t){t[t.top=0]="top",t[t.middle=1]="middle",t[t.bottom=2]="bottom"}(ga||(ga={})),function(t){t[t.left=0]="left",t[t.middle=1]="middle",t[t.right=2]="right"}(xa||(xa={})),function(t){t.normal="normal",t.bold="bold",t.lighter="lighter"}(Ta||(Ta={})),function(t){t.normal="normal",t.italic="italic",t.oblique="oblique"}(Ea||(Ea={}));var ba=function(){return ba=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},ba.apply(this,arguments)};function Aa(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function _a(t,e){if(!t.includes(e))return t.push(e),!0}function Ca(t,e,r){if(t)for(var i in t)Object.hasOwnProperty.call(t,i)&&e.call(r,t[i],i);return t}function Ra(t){if(Number.isFinite(t))return[aa.CONSTANT,t];if(t){if("lines"===t[0])return[aa.LINE,t[1]];if("curve"===t[0])return[aa.CURVE,t[1]];if("static"===t[0])return[aa.CONSTANT,t[1]]}}function Oa(t,e){return Array.isArray(t)&&"random"===t[0]?[aa.CONSTANT,t[1][e]]:Ra(t)}function wa(t){return t&&"color"===t[0]?Pa(t[1],!0):[1,1,1,1]}function Ma(t,e){if(t){if("colors"===t[0])return[aa.COLORS,t[1].map((function(t){return Pa(t,e)}))];if("gradient"===t[0])return Ia(t[1],e);if("color"===t[0])return[aa.RGBA_COLOR,Pa(t[1],e)]}}function La(t){return t&&"random"===t[0]?[aa.RANDOM,t[1]]:Ra(t)}function Ia(t,e){if(t){var r=[];return Object.getOwnPropertyNames(t).forEach((function(i){var n=function(t){var e=/^(-)?([\d+.]+)%$/.exec(t);if(e)return+e[2]/100*(e[1]?-1:1);return+t}(i),o=Pa(t[i],e);r.push([n,o[0],o[1],o[2],o[3]])})),r=r.sort((function(t,e){return t[0]-e[0]})),[aa.GRADIENT_COLOR,r]}}function Pa(t,e){var r;if("string"==typeof t){t=t.replace(/[\s\t\r\n]/g,"");var i=/rgba?\(([.\d]+),([.\d]+),([.\d]+),?([.\d]+)?\)/.exec(t);if(i){var n=+i[4];r=[+i[1],+i[2],+i[3],isNaN(n)?255:Math.round(255*n)]}else/^#[a-f\d]{3}$/i.test(t)?r=[parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),parseInt(t[3]+t[3],16),255]:(i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t))&&(r=[parseInt(i[1],16),parseInt(i[2],16),parseInt(i[3],16),255]||[0,0,0,255])}else t instanceof Array&&(r=[t[0],t[1],t[2],isNaN(t[3])?255:Math.round(255*t[3])]);return e&&(r=function(t){if(Array.isArray(t))return t.map((function(t){return Number.isFinite(t/255)?Number((t/255).toFixed(6)):0}))}(r)),r}function Fa(t,e){return Array.isArray(t)?("gradient"===t[0]||"color"===t[0])&&Ia(t[1],e):Ia(t,e)}function Na(t){if(t){if(3===t.length)return[aa.CONSTANT_VEC3,t];if("path"===t[0])return[aa.LINEAR_PATH,t[1]];if("bezier"===t[0])return[aa.BEZIER_PATH,t[1]]}}function Va(t){var e,r;try{for(var i=Aa(Object.keys(t)),n=i.next();!n.done;n=i.next()){var o=n.value;t[o]=Number(t[o])}}catch(t){e={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return t}function Da(t){var e,r;try{for(var i=Aa(Object.keys(t)),n=i.next();!n.done;n=i.next()){var o=n.value;void 0===t[o]&&delete t[o]}}catch(t){e={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return t}"function"==typeof SuppressedError&&SuppressedError;var za=Math.cos,Ba=Math.sin,Ua=Math.PI/180,ka=180/Math.PI;function Ga(t){var e,r=t.options,i=t.transform,n={type:Qs.NONE};if(t.shape){var o=null===(e=t.shape.shape)||void 0===e?void 0:e.replace(/([A-Z])/g,"_$1").toUpperCase().replace(/^_/,"");if(n=ba(ba({},t.shape),{type:Qs[o]}),t.shape.upDirection){var s=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,n,o=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){n={error:t}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return s}(t.shape.upDirection,3),a=s[0],u=s[1],l=s[2];0===a&&0===u&&0===l&&delete n.upDirection}}r.startTurbulence&&(n.turbulenceX=La(r.turbulenceX),n.turbulenceY=La(r.turbulenceY),n.turbulenceZ=La(r.turbulenceZ));var c=t.emission;c.bursts&&c.bursts.length>0&&(c.bursts=c.bursts.map((function(t){return Va(t)}))),c.burstOffsets&&c.burstOffsets.length>0&&(c.burstOffsets=c.burstOffsets.map((function(t){return Va(t)}))),c.rateOverTime&&(c.rateOverTime=La(c.rateOverTime));var h={renderer:t.renderer,shape:n,splits:t.splits,emission:c,options:{startLifetime:La(r.startLifetime),start3DSize:!!r.start3DSize,startSize:La(r.startSize),startSizeX:La(r.startSizeX),startSizeY:La(r.startSizeY),sizeAspect:La(r.sizeAspect),maxCount:r.maxCount,startDelay:La(r.startDelay),startColor:Ma(r.startColor,!0),startRotationZ:La(r.startRotation||r.startRotationZ),particleFollowParent:r.particleFollowParent}};if(r.start3DRotation&&(h.options.startRotationX=La(r.startRotationX),h.options.startRotationY=La(r.startRotationY)),t.filter){var f={};Ca(t.filter,(function(t,e){var r;f[e]=(r=t,Array.isArray(r)&&"string"==typeof r[0]&&(La(r)||Na(r)||Ma(r))||r)})),h.filter=f}i&&i.path&&(h.emitterTransform={path:Na(i.path)});var p=t.sizeOverLifetime;p&&(p.separateAxes?h.sizeOverLifetime={separateAxes:!0,x:La(p.x),y:La(p.y)}:h.sizeOverLifetime={size:La(p.size)});var d=t.velocityOverLifetime||{},m=d.speedOverLifetime;m=m?Ra(m):void 0,h.positionOverLifetime={gravity:r.gravity,gravityOverLifetime:Ra(r.gravityModifier),startSpeed:La(r.startSpeed),speedOverLifetime:m,asMovement:d.asMovement,linearX:La(d.linearX),linearY:La(d.linearY),linearZ:La(d.linearZ),asRotation:d.asRotation,orbCenter:d.orbCenter,orbitalX:La(d.orbitalX),orbitalY:La(d.orbitalY),orbitalZ:La(d.orbitalZ),forceTarget:d.forceTarget,target:d.target,forceCurve:Ra(d.forceCurve)},Da(h.positionOverLifetime);var v=t.rotationOverLifetime;v&&(h.rotationOverLifetime={separateAxes:v.separateAxes,asRotation:v.asRotation,z:La(v.separateAxes?v.z:v.angularVelocity)},v.separateAxes&&(h.rotationOverLifetime.y=Ra(v.y),h.rotationOverLifetime.x=Ra(v.x)));var y=t.colorOverLifetime;if(y){var g=h.colorOverLifetime={opacity:Ra(y.opacity)};y.color&&(g.color=Fa(y.color))}var x=t.textureSheetAnimation;x&&(h.textureSheetAnimation={row:x.row,col:x.col,total:x.total,animate:x.animate,cycles:Ra(x.cycles),animationDelay:Oa(x.animationDelay,0),animationDuration:Oa(x.animationDuration,0)});var T=t.trails;T&&(h.trails={lifetime:La(T.lifetime),dieWithParticles:T.dieWithParticles,maxPointPerTrail:T.maxPointPerTrail,minimumVertexDistance:T.minimumVertexDistance,widthOverTrail:Ra(T.widthOverTrail),colorOverTrail:T.colorOverTrail&&Fa(T.colorOverTrail,!1),blending:T.blending,colorOverLifetime:T.colorOverLifetime&&Fa(T.colorOverLifetime,!1),inheritParticleColor:T.inheritParticleColor,occlusion:T.occlusion,transparentOcclusion:T.transparentOcclusion,orderOffset:T.orderOffset,sizeAffectsLifetime:T.sizeAffectsLifetime,sizeAffectsWidth:T.sizeAffectsWidth,texture:T.texture,parentAffectsPosition:T.parentAffectsPosition,opacityOverLifetime:La(T.opacityOverLifetime)}),h.trails&&Da(h.trails);var E=t.interaction;return E&&(h.interaction={behavior:E.behavior,radius:E.radius,multiple:E.multiple}),h}function Xa(t,e){var r,i=t.options,n=t.velocityOverLifetime||{},o={path:Na(null===(r=t.transform)||void 0===r?void 0:r.path),gravity:i.gravity,gravityOverLifetime:Ra(i.gravityModifier),direction:i.direction,startSpeed:i.startSpeed,asMovement:n.asMovement,linearX:Ra(n.linearX),linearY:Ra(n.linearY),linearZ:Ra(n.linearZ),asRotation:n.asRotation,orbCenter:n.orbCenter,orbitalX:Ra(n.orbitalX),orbitalY:Ra(n.orbitalY),orbitalZ:Ra(n.orbitalZ),speedOverLifetime:Ra(n.speedOverLifetime)};Da(o);var s={options:{startColor:wa(i.startColor)},positionOverLifetime:o};i.startSize&&(e.scale=[i.startSize,i.startSize/(i.sizeAspect||1),1]),i.startRotation&&(e.rotation?e.rotation[2]+=i.startRotation:e.rotation=[0,0,i.startRotation]);var a=t.rotationOverLifetime;if(a){var u=s.rotationOverLifetime={separateAxes:a.separateAxes,asRotation:a.asRotation};u.separateAxes?(u.x=Ra(a.x),u.y=Ra(a.y),u.z=Ra(a.z)):u.z=Ra(a.angularVelocity)}var l=t.colorOverLifetime;if(l){var c=s.colorOverLifetime={opacity:Ra(l.opacity)};l.color&&(c.color=Fa(l.color))}var h=t.sizeOverLifetime;return h&&(s.sizeOverLifetime={separateAxes:h.separateAxes,size:Ra(h.size),x:Ra(h.x),y:Ra(h.y),z:Ra(h.z)}),s}function Ha(t,e){var r=Xa(t,e),i=t.textureSheetAnimation;return i&&(r.textureSheetAnimation={row:i.row,col:i.col,total:i.total||void 0,animate:i.animate}),r.renderer=t.renderer,t.splits&&(r.splits=t.splits),t.interaction&&(r.interaction=t.interaction),r}var Ya=["strength","bloomAddon","colorAddon","period","waveMovement","colorThreshold","xOpacity","yOpacity","feather"],ja=["path","position"];function Wa(t){return t.compositions.forEach((function(t){t.items.forEach((function(t){t.type===ea.null&&t.endBehavior===la.destroy&&(t.endBehavior=la.freeze)}))})),t.version="2.1",t}var Za=/^(\d+)\.(\d+)\.(\d+)(-(\w+)\.\d+)?$/,qa=/^(\d+)\.(\d+)$/,Ka=!1;function Qa(t){var e,r;if(!t||"object"!=typeof t)throw Error("expect a json object");if(function(t){var e,r=null===(e=t.version)||void 0===e?void 0:e.split(".");!r||Number(r[0])>2||2===Number(r[0])&&Number(r[1])>=2||t.compositions.forEach((function(t){t.items.forEach((function(t){t.type!==ea.mesh&&t.type!==ea.light||(t.endBehavior=1===t.endBehavior?la.destroy:t.endBehavior)}))}))}(t),Za.test(t.version))return Ka="0"===(null===(e=/^(\d+)/.exec(t.version))||void 0===e?void 0:e[0]),Wa(function(t){var e,r;Ja="1.0";var i=t.plugins||[];(null===(e=t.bins)||void 0===e?void 0:e.length)&&(Ja="1.3");var n=(t.requires||[]).slice(),o=t.images.map((function(e,r){return $a(e,r,t.imageTags||[])})),s=t.textures||o.map((function(t,e){return{source:e,flipY:!0}})),a={plugins:i,shapes:t.shapes||[],type:"ge",version:Ja,playerVersion:null!==(r=t.playerVersion)&&void 0!==r?r:{web:"",native:""},compositionId:t.compositionId+"",compositions:t.compositions.map((function(t){return tu(t,{plugins:i,requires:n})})),images:o,imgUsage:t._imgs,binUsage:t.binUsage,spines:t.spines,requires:t.requires,textures:s,bins:(t.bins||[]).slice()};t._textures&&(a._textures=t._textures);return a}(t));var i=null===(r=qa.exec(t.version))||void 0===r?void 0:r[1];if(i)return Number(i)<2?Wa(t):t;throw Error("invalid json version "+t.version)}var Ja="1.0";function $a(t,e,r){var i=r[e],n=t.oriY;if("string"==typeof t)return{renderLevel:i,url:t,oriY:n};if(t.template)return{url:t.url,template:t.template,webp:t.webp,renderLevel:i,oriY:n};if(t.compressed)return{url:t.url,oriY:n,compressed:{astc:t.compressed.android,pvrtc:t.compressed.iOS},webp:t.webp,renderLevel:i};if(t.url)return{url:t.url,type:t.type,webp:t.webp,renderLevel:i,oriY:n,loop:t.loop};if(t&&t.sourceType)return t;throw Error("invalid image type")}function tu(t,e){var r;void 0===e&&(e={});var i={id:t.id+"",camera:Object.assign({clipMode:Sa},t.camera),duration:t.duration,endBehavior:t.endBehavior,items:t.items.map((function(t){return nu(t,e)})),name:t.name},n=t.startTime||t.st;n&&(i.startTime=n);var o=null===(r=t.meta)||void 0===r?void 0:r.previewSize;return o&&o[0]===o[1]&&0===o[0]&&(o=void 0),o&&(i.previewSize=o),i}var eu,ru=[0,0,0,1],iu=.5;function nu(t,e){var r,i,n;void 0===e&&(e={});var o,s,a,u,l,c,h=ea.base,f=t.endBehavior,p=NaN;if(t.content?(h=t.type||ea.plugin,c=t.pn,l=t.pluginName,a=t.content,s=t.content,isNaN(c)&&!l&&(l=a.options.type),t.duration&&(p=t.duration),o=t.transform||y(s.transform),h===ea.filter&&(Ja<"1.1"&&(Ja="1.1"),(a=Ha(s,o)).filter=function(t){var e={};return Ca(t,(function(t,r){Ya.includes(r)?e[r]=Ra(t):ja.includes(r)?e[r]=Na(t):e[r]=t})),e}(s.filter))):t.particle?(h=ea.particle,o=y((s=t.particle).transform,Ka,!0),a=Ga(s)):t.sprite?(h=ea.sprite,a=Ha(s=t.sprite,o=y(s.transform,!1,!0))):t.cal?(h=ea.null,a=Xa(s=t.cal,o=y(s.transform,!1,!0))):t.ui?(h=ea.interact,o=y((s=t.ui).transform),a=function(t){var e,r=t.options;switch(r.type){case"click":e={type:$s.CLICK,showPreview:r.showPreview,previewColor:r.previewColor&&wa(r.previewColor),behavior:r.behavior||ta.NOTIFY};break;case"drag":e={type:$s.DRAG,enableInEditor:!!r.enableInEditor,dxRange:r.dxRange,dyRange:r.dyRange,target:r.target};break;case"message":e={type:$s.MESSAGE}}return{options:e}}(s),o.scale=[s.options.width||1,s.options.height||1,1]):t.model&&(s=t.model,1===t.model.options.type&&(h=ea.camera,o=y(s.transform),a=function(t){var e,r,i=t.options,n={options:{fov:i.fov,far:i.far,near:i.near,clipMode:i.clipMode}},o=t.velocityOverLifetime;if(o||(null===(e=t.transform)||void 0===e?void 0:e.path)){var s={path:Na(null===(r=t.transform)||void 0===r?void 0:r.path),linearX:Ra(null==o?void 0:o.translateX),linearY:Ra(null==o?void 0:o.translateY),linearZ:Ra(null==o?void 0:o.translateZ)};Da(s),n.positionOverLifetime=s}var a=t.rotationOverLifetime;if(a){var u={separateAxes:a.separateAxes,x:Ra(null==a?void 0:a.rotateX),y:Ra(null==a?void 0:a.rotateY),z:a.separateAxes?Ra(null==a?void 0:a.rotateZ):Ra(a.rotation)};Da(u),n.rotationOverLifetime=u}return n}(s))),null===(r=a.renderer)||void 0===r?void 0:r.anchor){var d=new Float32Array(a.renderer.anchor);d[0]==iu&&d[1]==iu?delete a.renderer.anchor:e.requires&&_a(e.requires,"anchor")}if(s){var m=null===(i=s.options)||void 0===i?void 0:i.looping;f=m?Array.isArray(m)?m[1]?la.loop:la.destroy:la.loop:f||(null===(n=null==s?void 0:s.options)||void 0===n?void 0:n.endBehavior)||la.destroy,s.options.renderLevel&&(u=s.options.renderLevel),isNaN(p)&&(p=s.options.duration)}var v={type:h,name:t.name,delay:t.delay,duration:p,id:t.id+"",transform:o,endBehavior:f,renderLevel:u,content:a};return l?e.plugins?(_a(e.plugins,l),v.pn=e.plugins.indexOf(l)):v.pluginName=l:Number.isInteger(c)&&(v.pn=c),t.parentId&&(v.parentId=t.parentId+""),v;function y(t,e,r){if(t){var i={},n=t.rotation;if(n&&(i.rotation=e?[-n[0],-n[1],-n[2]]:[n[0],n[1],n[2]],r)){var o=(s=ru,a=i.rotation[0],u=i.rotation[1],l=i.rotation[2],c=za(a*Ua/2),h=za(u*Ua/2),f=za(l*Ua/2),p=Ba(a*Ua/2),d=Ba(u*Ua/2),m=Ba(l*Ua/2),s[0]=p*h*f+c*d*m,s[1]=c*d*f-p*h*m,s[2]=c*h*m+p*d*f,s[3]=c*h*f-p*d*m,s);i.rotation=function(t,e){var r,i,n,o=e[0],s=e[1],a=e[2],u=e[3],l=o+o,c=s+s,h=a+a,f=o*l,p=s*l,d=s*c,m=a*h,v=u*h,y=1-d-m,g=p-v,x=p+v,T=1-f-m,E=a*l-u*c,S=a*c+u*l,b=1-f-d;return t[1]=Math.asin((i=-1,(r=-E)>(n=1)?n:r<i?i:r))*ka,Math.abs(E)<.9999999?(t[0]=Math.atan2(S,b)*ka,t[2]=Math.atan2(x,y)*ka):(t[0]=0,t[2]=Math.atan2(-g,T)*ka),t}([],o)}return t.position&&(i.position=t.position),Array.isArray(t.scale)&&(i.scale=[t.scale[0]||1,t.scale[1]||1,t.scale[2]||1]),i}var s,a,u,l,c,h,f,p,d,m;return{}}}var ou=((eu={})[E.S]=[E.S,E.BPlus,E.APlus],eu[E.A]=[E.A,E.BPlus,E.APlus],eu[E.B]=[E.B,E.BPlus],eu);function su(t,e){if(!t||!e)return!0;var r=ou[e];return!!r&&r.includes(t)}var au=0,uu=function(){function t(t,e){var r,i;this.refCompositions=new Map,this.refCompositionProps=new Map,this.mask=0;var n=t.jsonScene,o=t.renderLevel,a=t.textureOptions,u=t.pluginSystem,l=t.totalTime,c=n.compositions,h=n.imgUsage,f=n.compositionId;if(!a)throw new Error("scene.textures expected");var p=a.map((function(t){return t&&(t instanceof Vr?t:Vr.create(e,t))}));t.textureOptions=p,null==p||p.forEach((function(t){return null==t?void 0:t.initialize()}));try{for(var d=s(c),m=d.next();!m.done;m=d.next()){var v=m.value;v.id===f?this.composition=v:this.refCompositions.set(v.id,v)}}catch(t){r={error:t}}finally{try{m&&!m.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}if(!this.composition)throw new Error("Invalid composition id: "+f);this.jsonScene=n,this.renderLevel=o,this.pluginSystem=u,this.totalTime=null!=l?l:0,this.imgUsage=null!=h?h:{},this.textures=p,au=0,this.textureOptions=a,this.sourceContent=this.getContent(this.composition)}return t.prototype.getContent=function(t){var e=t.id,r=t.duration,i=t.name,n=t.endBehavior,o=t.camera,s=t.globalVolume,a=t.startTime,u=void 0===a?0:a,l=this.assembleItems(t);return{id:e,duration:r,name:i,endBehavior:isNaN(n)?1:n,items:l,camera:o,startTime:u,globalVolume:s}},t.prototype.assembleItems=function(t){var e=this,r=[];return t.items.forEach((function(t){var n,o={},s=t.visible,a=t.renderLevel,u=t.type;if(!1!==s){var l=i({},t.content);if(l&&(o.content=i({},l),su(a,e.renderLevel))){var c=o.content;if(o.type=u,c.renderer){c.renderer=e.changeTex(c.renderer),e.processMask(c.renderer);var h=c.splits&&!c.textureSheetAnimation&&c.splits[0];Number.isInteger(c.renderer.shape)?c.renderer.shape=Do(null===(n=e.jsonScene)||void 0===n?void 0:n.shapes[c.renderer.shape],h):c.renderer.shape&&He(c.renderer.shape)&&(c.renderer.shape=Do(c.renderer.shape,h))}else o.content.renderer={order:0};c.trails&&(c.trails=e.changeTex(c.trails)),c.filter&&(c.filter=i({},c.filter));var f=t.name,p=t.delay,d=void 0===p?0:p,m=t.id,v=t.parentId,y=t.duration,g=t.endBehavior,x=t.pluginName,T=t.pn,E=t.transform,S=t.refCount,b=e.jsonScene.plugins,A=void 0===b?[]:b;if(o.name=f,o.delay=d,o.id=m,v&&(o.parentId=v),o.refCount=S,o.duration=y,o.listIndex=au++,o.endBehavior=g,x?o.pluginName=x:void 0!==T&&Number.isInteger(T)&&(o.pluginName=A[T]),E&&(o.transform=E),o.type===w.composition){e.mask++;var _=t.content.options.refId;if(!e.refCompositions.get(_))throw new Error("Invalid Ref Composition id: "+_);var C=e.getContent(e.refCompositions.get(_));e.refCompositionProps.has(_)||e.refCompositionProps.set(_,C),C.items.forEach((function(t){e.processMask(t.content)})),o.items=C.items}r.push(o)}}})),r},t.prototype.changeTex=function(t){var e=t.texture,r=i({},t);return void 0!==e&&(r.texture=this.addTextureUsage(e)||e),r},t.prototype.addTextureUsage=function(t){var e,r;if(Number.isInteger(t)){var i=null===(e=this.textures)||void 0===e?void 0:e[t],n=null==i?void 0:i.id,o=null!==(r=this.imgUsage)&&void 0!==r?r:{};if(n&&o)return o.hasOwnProperty(n)||(o[n]=0),o[n]++,i}},t.prototype.processMask=function(t){if(t.maskMode!==A.NONE&&!t.mask){var e=t.maskMode;e===A.MASK?t.mask=++this.mask:e!==A.OBSCURED&&e!==A.REVERSE_OBSCURED||(t.mask=this.mask)}},t.prototype.dispose=function(){this.textureOptions=[],this.textures=[],this.composition=void 0,this.jsonScene=void 0,this.totalTime=0,this.pluginSystem=void 0,this.sourceContent=void 0,this.refCompositions.clear(),this.refCompositionProps.clear()},t}();function lu(t){return He(t)&&"jsonScene"in t}var cu=1,hu=function(){function e(t,e){void 0===t&&(t={}),void 0===e&&(e=new Rr),this.options=t,this.downloader=e,this.assets={},this.id=cu++,this.timers=[],this.updateOptions(t)}return e.prototype.updateOptions=function(t){void 0===t&&(t={}),this.options=t,t.pluginData||(t.pluginData={});var e=t.timeout,r=void 0===e?10:e;this.timeout=r},e.prototype.updateSceneData=function(t){var e=this.options.variables;return!e||Object.keys(e).length<=0||t.forEach((function(t){t.items.forEach((function(t){if(t.type===w.text){var r=e[t.name];r&&(t.content.options.text=r)}}))})),t},e.prototype.loadScene=function(t,e,r){var s,u,l;return n(this,void 0,void 0,(function(){var c,h,f,p,d,m,v,y,g,x,T,E,S=this;return o(this,(function(b){return h=ke(t)?t:this.id,f=performance.now(),p=[],d=null==e?void 0:e.engine.gpuCapability,m=null!==(u=null===(s=null==d?void 0:d.detail)||void 0===s?void 0:s.asyncShaderCompile)&&void 0!==u&&u,v=null!==(l=null==d?void 0:d.detail.compressedTexture)&&void 0!==l?l:0,g=!1,x=new Promise((function(t,e){y=window.setTimeout((function(){g=!0,S.removeTimer(y);var t=performance.now()-f;e("Load time out: totalTime: ".concat(t.toFixed(4),"ms ").concat(p.join(" "),", url: ").concat(h))}),1e3*S.timeout),S.timers.push(y)})),T=function(t,e){return n(S,void 0,void 0,(function(){var r,i,n;return o(this,(function(o){switch(o.label){case 0:if(g)return[3,4];r=performance.now(),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,e()];case 2:return i=o.sent(),p.push("[".concat(t,": ").concat((performance.now()-r).toFixed(2),"]")),[2,i];case 3:throw n=o.sent(),new Error("load error in ".concat(t,", ").concat(n));case 4:throw new Error("load canceled.")}}))}))},E=function(){return n(S,void 0,void 0,(function(){var n,s,u,l,d,g,x,E,S,b,A,_,C,R,O,w,M,L,I,P=this;return o(this,(function(o){switch(o.label){case 0:return He(t)?(c=t,this.baseUrl=location.href,[3,3]):[3,1];case 1:return t=new URL(t,location.href).href,this.baseUrl=t,[4,T("loadJSON",(function(){return P.loadJSON(t)}))];case 2:c=o.sent(),o.label=3;case 3:if(!lu(c))return[3,6];if(n=i({},c),!this.options||!this.options.variables||0===Object.keys(this.options.variables).length)return[3,5];for(s=c.jsonScene.images,u=n.images,d=0;d<s.length;d++)u[d]instanceof HTMLCanvasElement&&(u[d]=s[d]);return l=n,[4,T("processImages",(function(){return P.processImages(u,n.usedImages,v)}))];case 4:for(l.images=o.sent(),d=0;d<n.images.length;d++)n.textureOptions[d].image=n.images[d];n.jsonScene.compositions=this.updateSceneData(n.jsonScene.compositions),o.label=5;case 5:return[3,12];case 6:return[4,T("processJSON",(function(){return P.processJSON(c)}))];case 7:return g=o.sent(),x=g.usedImages,E=g.jsonScene,S=g.pluginSystem,b=E.bins,A=void 0===b?[]:b,_=E.images,C=E.compositions,R=E.fonts,[4,Promise.all([T("processBins",(function(){return P.processBins(A)})),T("processImages",(function(){return P.processImages(_,x,v)})),T("".concat(m?"async":"sync"," compile"),(function(){return P.precompile(C,S,e,r)}))])];case 8:return O=a.apply(void 0,[o.sent(),2]),w=O[0],M=O[1],[4,T("processFontURL",(function(){return P.processFontURL(R)}))];case 9:return o.sent(),[4,T("processTextures",(function(){return P.processTextures(M,w,E)}))];case 10:return L=o.sent(),E.compositions=this.updateSceneData(E.compositions),n={url:t,renderLevel:this.options.renderLevel,storage:{},pluginSystem:S,jsonScene:E,usedImages:x,images:M,textureOptions:L,bins:w},[4,T("processPlugins",(function(){return S.loadResources(n,P.options)}))];case 11:o.sent(),o.label=12;case 12:return I=performance.now()-f,Be.info("Load asset: totalTime: ".concat(I.toFixed(4),"ms ").concat(p.join(" "),", url: ").concat(h)),window.clearTimeout(y),this.removeTimer(y),n.totalTime=I,n.startTime=f,[2,n]}}))}))},[2,Promise.race([x,E()])]}))}))},e.prototype.precompile=function(t,e,r,i){return n(this,void 0,void 0,(function(){var n;return o(this,(function(o){switch(o.label){case 0:return r&&r.getShaderLibrary()?(n=null==r?void 0:r.getShaderLibrary(),[4,null==e?void 0:e.precompile(t,r,i)]):[2];case 1:return o.sent(),[4,new Promise((function(t){n.compileAllShaders((function(){t(null)}))}))];case 2:return o.sent(),[2]}}))}))},e.prototype.processJSON=function(t){return n(this,void 0,void 0,(function(){var e,r,i,n,s,a,u,l,c;return o(this,(function(o){switch(o.label){case 0:return e=Qa(t),t.compositions.forEach((function(t,r){t.globalVolume&&(e.compositions[r].globalVolume=t.globalVolume)})),r=e.plugins,i=void 0===r?[]:r,n=e.compositions,s=e.imgUsage,a=e.images,[4,(u=new ir(i)).processRawJSON(e,this.options)];case 1:return o.sent(),l=this.options.renderLevel,c={},s?function(t,e,r,i,n){for(var o=0;o<e.length;o++){var s=r[e[o].id];if(s)for(var a=0;a<s.length;a++){var u=s[a];su(i[u].renderLevel,n)&&(t[u]=!0)}}}(c,n,s,a,l):null==a||a.forEach((function(t,e){c[e]=!0})),[2,{usedImages:c,jsonScene:e,pluginSystem:u}]}}))}))},e.prototype.processBins=function(t){return n(this,void 0,void 0,(function(){var e,r,i,n=this;return o(this,(function(o){return e=this.options.renderLevel,r=this.baseUrl,i=t.map((function(i){if(i instanceof ArrayBuffer)return i;if(su(i.renderLevel,e))return n.loadBins(new URL(i.url,r).href);throw new Error("Invalid bins source: ".concat(JSON.stringify(t)))})),[2,Promise.all(i)]}))}))},e.prototype.processFontURL=function(t){return n(this,void 0,void 0,(function(){var r,i=this;return o(this,(function(s){return t?(r=t.map((function(t){return n(i,void 0,void 0,(function(){var r,i,n;return o(this,(function(o){switch(o.label){case 0:if(!t.fontURL||e.fonts.has(t.fontFamily))return[3,4];r=new URL(t.fontURL,this.baseUrl).href,i=new FontFace(null!==(n=t.fontFamily)&&void 0!==n?n:"","url("+r+")"),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,i.load()];case 2:return o.sent(),document.fonts.add(i),e.fonts.add(t.fontFamily),[3,4];case 3:return o.sent(),Be.warn("Invalid fonts source: ".concat(JSON.stringify(r))),[3,4];case 4:return[2]}}))}))})),[2,Promise.all(r)]):[2]}))}))},e.prototype.processImages=function(e,r,i){return n(this,void 0,void 0,(function(){var s,a,u,l,c,h=this;return o(this,(function(f){return s=this.options,a=s.useCompressedTexture,u=s.variables,l=this.baseUrl,c=e.map((function(e,s){return n(h,void 0,void 0,(function(){var n,c,h,f,p,d,m,v,y,g,x,T,E,S,b,A,_,C,R;return o(this,(function(o){switch(o.label){case 0:if(!r[s])return[3,19];if(n=e.url,c=e.webp,h=new URL(n,l).href,f=c&&new URL(c,l).href,!("template"in e))return[3,16];if(p=e.template,d=void 0,!("v"in p)||2!==p.v||!p.background)return[3,9];if(!((m=Cs(p,u))instanceof Array))return[3,6];v=p.background.name,o.label=1;case 1:return o.trys.push([1,3,,5]),_={},[4,Mr(m[0])];case 2:return _.image=o.sent(),_.url=m[0],d=_,[3,5];case 3:return o.sent(),C={},[4,Mr(m[1])];case 4:return C.image=o.sent(),C.url=m[1],d=C,[3,5];case 5:return u&&(u[v]=d.url),[3,8];case 6:return"string"!=typeof m?[3,8]:(R={},[4,Mr(m)]);case 7:R.image=o.sent(),R.url=m,d=R,o.label=8;case 8:return[3,11];case 9:return[4,wr(h,f)];case 10:d=o.sent(),o.label=11;case 11:y=void 0,o.label=12;case 12:return o.trys.push([12,14,,15]),[4,Ms(d.image,p,u,this.options,-1===e.oriY)];case 13:return y=o.sent(),[3,15];case 14:throw o.sent(),new Error("image template fail: ".concat(h));case 15:return[2,y];case 16:if("type"in e&&"video"===e.type)return g=e.loop,[2,Ir(e.url,{loop:g})];if("compressed"in e&&a&&i){if(x=e.compressed,T=void 0,i===un.ASTC?T=x.astc:i===un.PVRTC&&(T=x.pvrtc),T)return E=new URL(T,l).href,this.assets[s]={url:E,type:t.TextureSourceType.compressed},[2,this.loadBins(E)]}else{if("sourceType"in e)return[2,e];if(e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof Vr)return[2,e]}o.label=17;case 17:return[4,wr(h,f)];case 18:return S=o.sent(),b=S.url,A=S.image,this.assets[s]={url:b,type:t.TextureSourceType.image},[2,A];case 19:return[2,void 0]}}))}))})),[2,Promise.all(c)]}))}))},e.prototype.processTextures=function(e,r,s){var a;return n(this,void 0,void 0,(function(){var n,u,l=this;return o(this,(function(o){return n=null!==(a=s.textures)&&void 0!==a?a:e.map((function(t,e){return{source:e}})),u=n.map((function(n,o){if(n instanceof Vr)return n;if("mipmaps"in n)try{return Pr(n,r,s.bins)}catch(t){throw new Error("load texture ".concat(o," fails, error message: ").concat(t))}var a=n.source,u=e[a];if(u){var c=function(e,r){if(e instanceof Vr)return e.source;if(e instanceof HTMLImageElement||function(t){var e;return"object"==typeof t&&null!==t&&"CANVAS"===(null===(e=t.tagName)||void 0===e?void 0:e.toUpperCase())}(e))return{image:e,sourceType:t.TextureSourceType.image,sourceFrom:r,keepImageSource:!0,minFilter:v.LINEAR,magFilter:v.LINEAR};if(e instanceof HTMLVideoElement)return{sourceType:t.TextureSourceType.video,video:e,minFilter:v.LINEAR,magFilter:v.LINEAR};if(e instanceof ArrayBuffer)return i(i({},Br(e)),{sourceFrom:r});if("width"in e&&"height"in e&&"data"in e)return{sourceType:t.TextureSourceType.data,data:e,wrapS:v.CLAMP_TO_EDGE,wrapT:v.CLAMP_TO_EDGE,minFilter:v.NEAREST,magFilter:v.NEAREST};throw new Error("Invalid texture options")}(u,l.assets[o]);return c.sourceType===t.TextureSourceType.compressed?c:i(i({},c),n)}throw new Error("Invalid texture source: ".concat(a))})),[2,Promise.all(u)]}))}))},e.prototype.loadJSON=function(t){return n(this,void 0,void 0,(function(){var e=this;return o(this,(function(r){return[2,new Promise((function(r,i){e.downloader.downloadJSON(t,r,(function(e,r){i("Couldn't load JSON ".concat(JSON.stringify(t),": status ").concat(e,", ").concat(r))}))}))]}))}))},e.prototype.loadBins=function(t){return n(this,void 0,void 0,(function(){var e=this;return o(this,(function(r){return[2,new Promise((function(r,i){e.downloader.downloadBinary(t,r,(function(e,r){i("Couldn't load bins ".concat(JSON.stringify(t),": status ").concat(e,", ").concat(r))}))}))]}))}))},e.prototype.removeTimer=function(t){var e=this.timers.indexOf(t);-1!==e&&this.timers.splice(e,1)},e.prototype.dispose=function(){var t;for(var e in this.timers.length&&this.timers.map((function(t){return window.clearTimeout(t)})),this.assets){var r=this.assets[e];null===(t=null==r?void 0:r.dispose)||void 0===t||t.call(r)}this.assets={},this.timers=[]},e.fonts=new Set,e}();var fu,pu,du=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.items=[],t.itemTree=[],t.itemCacheMap=new Map,t.itemsToRemove=[],t.tempQueue=[],t}return r(n,e),Object.defineProperty(n.prototype,"type",{get:function(){return w.composition},enumerable:!1,configurable:!0}),n.prototype.onConstructed=function(t){var e=t.items,r=void 0===e?[]:e,i=t.startTime,n=void 0===i?0:i,o=t.content,s=t.refId;this.refId=s,this.itemProps=r,this.contentProps=o;var a=this.endBehavior;5!==a&&1!==a&&3!==a||(this.freezeOnEnd=!0),this.startTime=n,this.startTimeInms=Math.round(1e3*this.startTime)},n.prototype.createContent=function(){if(!this.items.length&&this.composition)for(var e=0;e<this.itemProps.length;e++){var r=void 0,o=this.itemProps[e];if(t.Item.isComposition(o)){var s=o.content.options.refId,a=this.composition.refCompositionProps.get(s);if(!a)throw new Error("引用的Id: ".concat(s," 的预合成不存在"));a.content=o.content,(r=new n(i(i({},a),{refId:s,delay:o.delay,id:o.id,name:o.name,duration:o.duration,endBehavior:o.endBehavior,parentId:o.parentId,transform:o.transform}),this.composition)).contentProps=o.content,r.transform.parentTransform=this.transform,this.composition.refContent.push(r),5===r.endBehavior&&(this.composition.autoRefTex=!1)}else(r=Je(this.itemProps[e],this.composition)).transform.parentTransform=Qe.isCamera(r)?new Ke:this.transform;Qe.isExtraCamera(r)&&(this.extraCamera=r),this.items.push(r),this.tempQueue.push(r)}!this.content&&this.contentProps&&(this._content=this.doCreateContent())},n.prototype.doCreateContent=function(){var t=new In(this.contentProps,this);return t.renderData=t.getRenderData(0,!0),t},n.prototype.onLifetimeBegin=function(){var t;null===(t=this.items)||void 0===t||t.forEach((function(t){t.start(),t.createContent()})),this.buildItemTree()},n.prototype.doStop=function(){this.items&&this.items.forEach((function(t){return t.stop()}))},n.prototype.onItemUpdate=function(t,e){var r,i,n=this;if(this.content&&(this.content.updateTime(this.time),this.content.getRenderData(this.content.time)),this.items){null===(r=this.composition)||void 0===r||r.updatePluginLoaders(t);var o=[];this.itemsToRemove.length&&(this.itemsToRemove.forEach((function(t){var e,r,i=n.itemCacheMap.get(t.id);if(i){var o=i.children;if(i.parentId){var s=n.itemCacheMap.get(i.parentId);s?(s.children.splice(s.children.indexOf(i),1),o.forEach((function(t){return n.setItemParent(t.item,s.item)}))):(o.forEach((function(t){return n.setItemParent(t.item,void 0)})),(e=n.itemTree).push.apply(e,u([],a(o),!1)))}else(r=n.itemTree).splice.apply(r,u([n.itemTree.indexOf(i),1],a(o),!1)),o.forEach((function(t){return n.setItemParent(t.item,void 0)}));n.itemCacheMap.delete(t.id),n.items.splice(n.items.indexOf(t),1)}})),this.itemsToRemove.length=0);for(var s=0;s<this.itemTree.length;s++){if((c=this.itemTree[s])&&c.item){var l=c.item;Qe.isComposition(l)&&l.ended&&5===l.endBehavior?l.restart():l.onUpdate(t),o.push.apply(o,u([],a(c.children),!1))}}for(;o.length;){var c;if((c=o.shift())&&c.item)(l=c.item).onUpdate(t),o.push.apply(o,u([],a(c.children),!1)),l.composition||z(this.itemsToRemove,l)}null===(i=this.extraCamera)||void 0===i||i.onUpdate(t)}},n.prototype.onItemRemoved=function(t){this.items&&(this.items.forEach((function(t){return t.dispose()})),this.items.length=0,this.itemTree.length=0,this.itemCacheMap.clear())},n.prototype.reset=function(){e.prototype.reset.call(this),this.itemTree=[],this.itemCacheMap.clear(),this.tempQueue.length=0,this.itemsToRemove.length=0},n.prototype.handleVisibleChanged=function(t){this.items.forEach((function(e){return e.setVisible(t)}))},n.prototype.getUpdateTime=function(t){var e=this.startTimeInms,r=this.timeInms;if(t<0&&r+t<e)return e-r;if(this.freezeOnEnd){var i=this.durInms-r;if(i<t)return i}return t},n.prototype.removeItem=function(t){var e,r=this;if(this.items.indexOf(t)>-1){if(z(this.itemsToRemove,t),Qe.isTree(t)||Qe.isNull(t)){var i=6===t.endBehavior,n=Qe.isNull(t)&&!!this.itemCacheMap.get(t.id);((null===(e=this.itemCacheMap.get(t.id))||void 0===e?void 0:e.children)||[]).forEach((function(t){n||r.setItemParent(t.item,void 0),i&&r.removeItem(t.item)}))}return!0}return this.items.forEach((function(e){if(Qe.isComposition(e)&&e.items.indexOf(t)>-1)return e.removeItem(t),!0})),!1},n.prototype.setItemParent=function(t,e){var r=this.itemCacheMap.get(t.id);if(r)if(e){var i=this.itemCacheMap.get(e.id);if(r.parentId){var n=this.itemCacheMap.get(r.parentId);n.children.splice(n.children.indexOf(r),1)}t.parent=e,r.parentId=e.id,i.children.push(r),t.transform.parentTransform=e.transform}else r.parentId=void 0,t.parent=void 0,t.transform.parentTransform=Qe.isExtraCamera(t)?new Ke:this.transform;else console.error("item has been remove, please set item's parent in valid lifetime")},n.prototype.getItemCurrentParent=function(t){var e=t.id,r=this.itemCacheMap.get(e);if(r){var i=r.parentId;if(i){var n=this.itemCacheMap.get(i);return i&&n?n.item:void 0}}},n.prototype.getItemByName=function(t){var e,r,i=[];try{for(var n=s(this.items),o=n.next();!o.done;o=n.next()){var l=o.value;l.name===t?i.push(l):Qe.isComposition(l)&&i.push.apply(i,u([],a(l.getItemByName(t)),!1))}}catch(t){e={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}return i},n.prototype.hitTest=function(e,r,i,n,o,s){for(var a=[],u=(null==s?void 0:s.stop)||Ue,l=(null==s?void 0:s.skip)||Ue,c=(null==s?void 0:s.maxCount)||this.items.length,h=0;h<this.items.length&&n.length<c;h++){var f=this.items[h];if(f.lifetime>=0&&f.lifetime<=1&&!Qe.isComposition(f)&&!l(f)){var p=f.getHitTestParams(o);if(p){var d=!1,m=new Mt;if(p.type===t.HitTestType.triangle)for(var v=p.triangles,y=p.backfaceCulling,g=0;g<v.length;g++){var x=v[g];if(e.intersectTriangle(x,m,y)){d=!0,a.push(m);break}}else if(p.type===t.HitTestType.box){var T=p.center,E=p.size,S=T.clone().addScaledVector(E,.5),b=T.clone().addScaledVector(E,-.5);e.intersectBox({min:S,max:b},m)&&(d=!0,a.push(m))}else if(p.type===t.HitTestType.sphere){T=p.center;var A=p.radius;e.intersectSphere({center:T,radius:A},m)&&(d=!0,a.push(m))}else if(p.type===t.HitTestType.custom){var _=p.collect(e,new wt(r,i));_&&_.length>0&&(_.forEach((function(t){a.push(t)})),d=!0)}if(d){var C={compContent:this,id:f.id,name:f.name,position:a[a.length-1],parentId:f.parentId,hitPositions:a,behavior:p.behavior};if(n.push(C),u(C))return n}}}}return n},n.prototype.isEnded=function(t){return t>=this.durInms},n.prototype.buildItemTree=function(){if(!this.itemTree.length&&this.composition){this.itemTree=[];for(var t=this.itemCacheMap,e=this.tempQueue,r=function(){var r=e.shift();if(void 0===r.parentId){var n={id:r.id,item:r,children:[]};i.itemTree.push(n),t.set(r.id,n)}else{var o=i.getParentIdWithoutSuffix(r.parentId),s=t.get(o);if(s){n={id:r.id,parentId:o,item:r,children:[]};r.parent=s.item,r.transform.parentTransform=s.item.getNodeTransform(r.parentId),s.children.push(n),t.set(r.id,n)}else{if(-1===i.items.findIndex((function(t){return t.id===o})))throw Error("元素引用了不存在的元素,请检查数据");e.push(r)}}},i=this;e.length;)r()}},n.prototype.getParentIdWithoutSuffix=function(t){var e=t.lastIndexOf("^");return e>-1?t.substring(0,e):t},n.prototype.restart=function(){this.reset(),this.createContent(),this.start()},n}(Qe),mu=1,vu=function(){function e(t,e){var r;this.speed=1,this.loaderData={},this.refContent=[],this.refCompositionProps=new Map,this.assigned=!1,this.destroyed=!1,this.paused=!1,this.lastVideoUpdateTime=0,this.postLoaders=[];var n=t.reusable,o=void 0!==n&&n,s=t.speed,a=void 0===s?1:s,u=t.baseRenderOrder,l=void 0===u?0:u,c=t.renderer,h=t.onPlayerPause,f=t.onMessageItem,p=t.onEnd,d=t.event,m=t.width,v=t.height;this.compositionSourceManager=new uu(e,c.engine),e.jsonScene.imgUsage=void 0,o&&(this.keepResource=!0,e.textures=void 0,e.consumed=!0);var y=this.compositionSourceManager,g=y.sourceContent,x=y.pluginSystem,T=y.imgUsage,E=y.totalTime,S=y.renderLevel,b=y.refCompositionProps;rt(g),this.refCompositionProps=b;var A=new du(g,this),_=!o&&T;this.transform=new Ke({name:this.name}),A.transform=this.transform,this.globalVolume=g.globalVolume,this.width=m,this.height=v,this.renderOrder=l,this.id=mu++,this.renderer=c,this.texInfo=null!=_?_:{},this.event=d,this.statistic={loadTime:null!=E?E:0,loadStart:null!==(r=e.startTime)&&void 0!==r?r:0,firstFrameTime:0},this.reusable=o,this.speed=a,this.renderLevel=S,this.autoRefTex=!this.keepResource&&_&&5!==A.endBehavior,this.content=A,this.name=A.name,this.pluginSystem=x,this.pluginSystem.initializeComposition(this,e),this.camera=new js(this.name,i(i({},null==g?void 0:g.camera),{aspect:m/v})),this.url=e.url,this.assigned=!0,this.onPlayerPause=h,this.onMessageItem=f,this.onEnd=p,this.createRenderFrame(),this.reset()}return Object.defineProperty(e.prototype,"handleEnd",{set:function(t){console.warn("The handleEnd property is deprecated. Use onEnd instead."),this.onEnd=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textures",{get:function(){return this.compositionSourceManager.textures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"items",{get:function(){return this.content.items},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"startTime",{get:function(){var t;return null!==(t=this.content.startTime)&&void 0!==t?t:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"time",{get:function(){return this.content.timeInms/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.getDuration=function(){return this.content.duration},e.prototype.restart=function(){this.content.reset(),this.prepareRender(),this.reset(),this.transform.setValid(!0),this.content.start(),this.forwardTime(this.startTime),this.content.onUpdate(0),this.loaderData.spriteGroup.onUpdate(0)},e.prototype.setIndex=function(t){this.renderOrder=t},e.prototype.getIndex=function(){return this.renderOrder},e.prototype.setSpeed=function(t){this.speed=t},e.prototype.getSpeed=function(){return this.speed},e.prototype.play=function(){this.content.ended&&this.reusable&&this.restart(),this.content.started?this.gotoAndPlay(this.time-this.startTime):this.gotoAndPlay(0)},e.prototype.pause=function(){this.paused=!0},e.prototype.resume=function(){this.paused=!1},e.prototype.gotoAndPlay=function(t){this.resume(),this.content.started||this.content.start(),this.forwardTime(t+this.startTime)},e.prototype.gotoAndStop=function(t){this.gotoAndPlay(t),this.pause()},e.prototype.createRenderFrame=function(){this.renderFrame=new Qi({camera:this.camera,renderer:this.renderer,keepColorBuffer:this.keepColorBuffer,globalVolume:this.globalVolume}),this.renderFrame.cachedTextures=this.textures},e.prototype.setTime=function(t){var e=this.paused;e&&this.resume(),this.content.started||this.content.start(),this.forwardTime(t+this.startTime,!0),e&&this.pause()},e.prototype.forwardTime=function(t,e){void 0===e&&(e=!1);for(var r=1e3*t-this.content.timeInms,i=r<0,n=Math.abs(r),o=i?-15:15;n>15;n-=15)this.update(o,e);this.update(i?-n:n,e)},e.prototype.reset=function(){var t=this;this.rendererOptions=null,this.pluginSystem.plugins.forEach((function(e){return e.onCompositionWillReset(t,t.renderFrame)})),this.content.createContent(),this.content.onEnd=function(){window.setTimeout((function(){var e;null===(e=t.onEnd)||void 0===e||e.call(t,t)}),0)},this.pluginSystem.resetComposition(this,this.renderFrame)},e.prototype.prepareRender=function(){var t=this,e=this.renderFrame;this.postLoaders.length=0,this.pluginSystem.plugins.forEach((function(r){r.prepareRenderFrame(t,e)&&t.postLoaders.push(r)})),this.postLoaders.forEach((function(r){return r.postProcessFrame(t,e)}))},e.prototype.shouldRestart=function(){var t=this.content,e=t.ended,r=t.endBehavior;return e&&5===r},e.prototype.shouldDispose=function(){if(this.reusable)return!1;var t=this.content,e=t.ended,r=t.endBehavior;return e&&(!r||3===r)},e.prototype.update=function(t,e){if(void 0===e&&(e=!1),this.assigned&&!this.paused){this.shouldRestart()&&this.restart();var r=this.content.getUpdateTime(t*this.speed);this.updateVideo(),this.content.onUpdate(r),this.loaderData.spriteGroup.onUpdate(r),this.updateCamera(),this.shouldDispose()?this.dispose():e||this.prepareRender()}},e.prototype.updateVideo=function(){var t,e=performance.now();e-this.lastVideoUpdateTime>33&&((null!==(t=this.textures)&&void 0!==t?t:[]).forEach((function(t){return null==t?void 0:t.uploadCurrentVideoFrame()})),this.lastVideoUpdateTime=e)},e.prototype.updateCamera=function(){this.camera.updateMatrix()},e.prototype.updatePluginLoaders=function(t){var e=this;this.pluginSystem.plugins.forEach((function(r){return r.onCompositionUpdate(e,t)}))},e.prototype.getItemByName=function(t,e){if(this.content&&this.content.items)return this.content.getItemByName(t)[0]},e.prototype.getItemByID=function(t){return this.content&&this.content.items&&this.content.itemCacheMap.has(t)?this.content.itemCacheMap.get(t).item:null},e.prototype.getItemCurrentParent=function(t){return this.content.getItemCurrentParent(t)},e.prototype.itemLifetimeEvent=function(t,e){var r=this,i=e?function(e){return e.onCompositionItemLifeBegin(r,t)}:function(e){return e.onCompositionItemLifeEnd(r,t)};this.pluginSystem.plugins.forEach(i)},e.prototype.getHitTestRay=function(t,e){var r=this.renderFrame.editorTransform,i=r.x,n=r.y;return ue((t-r.z)/i,(e-r.w)/n,this.camera)},e.prototype.getEngine=function(){var t;return null===(t=this.renderer)||void 0===t?void 0:t.engine},e.prototype.hitTest=function(t,e,r,i){if(this.isDestroyed)return[];var n=[],o=this.getHitTestRay(t,e);return this.content.hitTest(o,t,e,n,r,i),this.refContent.forEach((function(s){s.hitTest(o,t,e,n,r,i)})),n},e.prototype.addInteractiveItem=function(t,e){var r;if(e===R.MESSAGE)return null===(r=this.onMessageItem)||void 0===r||r.call(this,{name:t.name,phrase:2,id:t.id,compositionId:this.id}),t.id},e.prototype.removeInteractiveItem=function(t,e){var r;e===R.MESSAGE&&(null===(r=this.onMessageItem)||void 0===r||r.call(this,{name:t.name,phrase:1,id:t.id,compositionId:this.id}))},e.prototype.destroyTextures=function(e){for(var r,i=0;i<e.length;i++){var n=e[i];if(n)if(n.sourceType!==t.TextureSourceType.data||this.texInfo[n.id]){if(this.autoRefTex)--this.texInfo[n.id]||n.dispose()}else n!==(null===(r=this.rendererOptions)||void 0===r?void 0:r.emptyTexture)&&n!==this.renderFrame.transparentTexture&&n.dispose()}},e.prototype.destroyItem=function(t){var e=this;t.type==w.composition?4!==t.endBehavior&&t.items.forEach((function(t){return e.pluginSystem.plugins.forEach((function(r){return r.onCompositionItemRemoved(e,t)}))})):(this.content.removeItem(t),this.refContent.forEach((function(e){return e.removeItem(t)})),this.pluginSystem.plugins.forEach((function(r){return r.onCompositionItemRemoved(e,t)})))},e.prototype.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()},e.prototype.dispose=function(){var t,e,r=this;if(!this.destroyed){this.destroyed=!0;var i={},n=this.textures;n&&(this.keepResource?n.forEach((function(t){(null==t?void 0:t.dispose)&&(i[t.id]=t.dispose,t.dispose=Ue)})):n.forEach((function(t){return t&&t.dispose()}))),this.content.dispose(),this.renderFrame.dispose(),null===(t=this.rendererOptions)||void 0===t||t.emptyTexture.dispose(),null===(e=this.pluginSystem)||void 0===e||e.destroyComposition(this),this.update=function(){Be.error("Update disposed composition: ".concat(r.name,"."))},this.onPlayerPause=Ue,this.dispose=Ue,n&&this.keepResource&&n.forEach((function(t){return t.dispose=i[t.id]})),this.compositionSourceManager.dispose(),this.refCompositionProps.clear()}},e.prototype.setEditorTransform=function(t,e,r){this.renderFrame.editorTransform.set(t,t,e,r)},e.prototype.translateByPixel=function(t,e){this.renderer?this.content.translateByPixel(t,e):console.warn("Can not translate position when container not assigned")},e.prototype.translate=function(t,e,r){this.content.translate(t,e,r)},e.prototype.setPosition=function(t,e,r){this.content.setPosition(t,e,r)},e.prototype.rotate=function(t,e,r){this.content.rotate(t,e,r)},e.prototype.setRotation=function(t,e,r){this.content.setRotation(t,e,r)},e.prototype.scale=function(t,e,r){this.content.scale(t,e,r)},e.prototype.setScale=function(t,e,r){this.content.setScale(t,e,r)},e.prototype.offloadTexture=function(){this.textureOffloaded||(this.textures.forEach((function(t){return t&&t.offloadData()})),this.textureOffloaded=!0)},e.prototype.getRendererOptions=function(){return this.rendererOptions||(this.rendererOptions={emptyTexture:this.renderFrame.emptyTexture,cachePrefix:"-"}),this.rendererOptions},e.prototype.reloadTexture=function(){return n(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this.textureOffloaded?[4,Promise.all(this.textures.map((function(t){return null==t?void 0:t.reloadData()})))]:[3,2];case 1:t.sent(),this.textureOffloaded=!1,t.label=2;case 2:return[2]}}))}))},e}(),yu=function(){function t(){this.destroyed=!1,this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[]}return t.prototype.addTexture=function(t){this.destroyed||z(this.textures,t)},t.prototype.removeTexture=function(t){this.destroyed||B(this.textures,t)},t.prototype.addMaterial=function(t){this.destroyed||z(this.materials,t)},t.prototype.removeMaterial=function(t){this.destroyed||B(this.materials,t)},t.prototype.addGeometry=function(t){this.destroyed||z(this.geometries,t)},t.prototype.removeGeometry=function(t){this.destroyed||B(this.geometries,t)},t.prototype.addMesh=function(t){this.destroyed||z(this.meshes,t)},t.prototype.removeMesh=function(t){this.destroyed||B(this.meshes,t)},t.prototype.addRenderPass=function(t){this.destroyed||z(this.renderPasses,t)},t.prototype.removeRenderPass=function(t){this.destroyed||B(this.renderPasses,t)},Object.defineProperty(t.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),t.prototype.getShaderLibrary=function(){return this.renderer.getShaderLibrary()},t.prototype.dispose=function(){if(!this.destroyed){this.destroyed=!0;var t=[];this.renderPasses.length>0&&t.push("Pass ".concat(this.renderPasses.length)),this.meshes.length>0&&t.push("Mesh ".concat(this.meshes.length)),this.geometries.length>0&&t.push("Geom ".concat(this.geometries.length)),this.textures.length>0&&t.push("Tex ".concat(this.textures.length)),t.length>0&&Be.warn("Release GPU memory: ".concat(t.join(", "))),this.renderPasses.forEach((function(t){t.dispose()})),this.meshes.forEach((function(t){t.dispose()})),this.geometries.forEach((function(t){t.dispose()})),this.materials.forEach((function(t){t.dispose()})),this.textures.forEach((function(t){t.dispose()})),this.textures=[],this.materials=[],this.geometries=[],this.meshes=[],this.renderPasses=[],this.renderer=null}},t}(),gu=function(){function t(t){void 0===t&&(t=60),this.paused=!0,this.lastTime=0,this.setFPS(t),this.tickers=[]}return t.prototype.getFPS=function(){return this.targetFPS},t.prototype.setFPS=function(t){this.targetFPS=Rt(t,1,120),this.interval=Math.floor(1e3/t)-2},t.prototype.getPaused=function(){return this.paused},t.prototype.start=function(){var t=this;if(this.paused=!1,!this.intervalId){this.lastTime=performance.now();var e=requestAnimationFrame||function(t){return window.setTimeout(t,16.7)},r=function(){t.intervalId=e(r),t.paused||t.tick()};r()}},t.prototype.stop=function(){(cancelAnimationFrame||window.clearTimeout)(this.intervalId),this.intervalId=0,this.lastTime=0,this.paused=!0,this.tickers=[]},t.prototype.pause=function(){this.paused=!0},t.prototype.resume=function(){this.paused=!1},t.prototype.tick=function(){if(!this.paused){var t=performance.now(),e=t-this.lastTime;if(e>=this.interval){this.lastTime=t,this.resetTickers&&(this.tickers=this.tickers.filter((function(t){return t})),this.resetTickers=!1);for(var r=0,i=this.tickers.length;r<i;r++){(0,this.tickers[r])(e)}}}},t.prototype.add=function(t){if("function"!=typeof t)throw new Error("Ticker: The tick object must implement the tick method.");this.tickers.push(t)},t}();rr("camera",ur,lr,!0),rr("sprite",wn,Vn,!0),rr("particle",as,ss,!0),rr("cal",ls,cs,!0),rr("interact",vn,dn,!0),rr("filter",wn,zn,!0),rr("text",Fs,Ps,!0),N(na);var xu=((fu={})[v.RGBA]=34842,fu[v.RGB]=34843,fu[v.ALPHA]=33325,fu[v.RED]=33325,fu[v.LUMINANCE_ALPHA]=33327,fu[v.LUMINANCE]=33325,fu),Tu=((pu={})[v.RGBA]=34836,pu[v.RGB]=34837,pu[v.ALPHA]=33326,pu[v.RED]=33326,pu[v.LUMINANCE_ALPHA]=33328,pu[v.LUMINANCE]=33326,pu),Eu=function(e){function s(t,r){var i=e.call(this)||this;i.initialized=!1;var n=i.assembleOptions(r),o=n.sourceType,s=n.sourceFrom,a=n.name,u=void 0===a?"":a;return i.source=n,i.sourceType=o,i.sourceFrom=s,i.name=u,i.engine=t,i}return r(s,e),s.prototype.bind=function(t){this.pipelineContext.bindTexture(this.target,this.textureBuffer,t)},s.prototype.initialize=function(){if(!this.initialized){var t=this.engine;t.addTexture(this);var e=t.getGLPipelineContext();this.pipelineContext=e;var r=e.gl,i=this.source,n=i.target,o=void 0===n?r.TEXTURE_2D:n,s=i.name;this.textureBuffer=r.createTexture(),this.textureBuffer&&Ru(this.textureBuffer,s),this.target=o,this.update(this.source),this.release(),this.initialized=!0}},s.prototype.clone=function(){var t=new s(this.engine,this.source);return t.sourceFrom=this.sourceFrom,t.sourceType=this.sourceType,t.width=this.width,t.height=this.height,t},s.prototype.release=function(){switch(this.source.sourceType){case t.TextureSourceType.image:delete this.source.image,delete this.source.cube;break;case t.TextureSourceType.data:delete this.source.data;break;case t.TextureSourceType.compressed:case t.TextureSourceType.mipmaps:delete this.source.mipmaps}},s.prototype.update=function(e){var r,i,n,o,s=this;if(!this.pipelineContext||!this.textureBuffer)return this.width=0,void(this.height=0);var u=this.target,l=this.source,c=this.pipelineContext.gl,h=this.engine.gpuCapability.detail,f=l.sourceType,p=l.data,d=l.cube,m=l.image,y=l.video,x=l.mipmaps,T=l.mipmaps,E=e.data,S=e.cube,b=e.generateMipmap,A=e.mipmaps,_=l,C=_.format,R=_.type,O=_.internalFormat,w=0,M=0;if(this.bind(f===t.TextureSourceType.video),R===v.HALF_FLOAT?((R=h.halfFloatTexture)||Be.error("Half float texture is not support."),g(c)&&O===C&&(C===v.LUMINANCE&&(C=v.RED),O=xu[C]),h.halfFloatLinear||(l.minFilter=l.magFilter=c.NEAREST,Be.warn("Half float linear not support, change to NEAREST."))):R===c.FLOAT&&((R=h.floatTexture)||Be.error("Float texture is not support."),g(c)&&O===C&&(C===v.LUMINANCE&&(C=v.RED),O=Tu[C]),h.floatLinear||(l.minFilter=c.NEAREST,l.magFilter=c.NEAREST,Be.warn("Float linear not support, change to NEAREST."))),void 0===l.premultiplyAlpha&&(l.premultiplyAlpha=!1),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,l.premultiplyAlpha),void 0===l.flipY&&(l.flipY=!1),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,l.flipY),f===t.TextureSourceType.framebuffer)E&&(w=null!==(n=E.width)&&void 0!==n?n:0,M=null!==(o=E.height)&&void 0!==o?o:0,w&&M&&(this.width!==w||this.height!==M)&&c.texImage2D(u,0,O,w,M,0,C,R,null));else if(f===t.TextureSourceType.data)u===c.TEXTURE_CUBE_MAP?S.forEach((function(t,e){var r=a(s.texImage2DData(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,O,C,R,t),2),i=r[0],n=r[1];w=Math.max(i,w),M=Math.max(n,M)})):(r=a(this.texImage2DData(c,u,0,O,C,R,p),2),w=r[0],M=r[1]);else if(f===t.TextureSourceType.image||f===t.TextureSourceType.video){if(u===c.TEXTURE_CUBE_MAP)d.forEach((function(t,e){var r=a(s.texImage2D(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,O,C,R,t),2),i=r[0],n=r[1];w=Math.max(i,w),M=Math.max(n,M)}));else if(u===c.TEXTURE_2D){var L=null!=m?m:y;i=a(this.texImage2D(c,u,0,O,C,R,L),2),w=i[0],M=i[1]}b&&(Su(w)&&Su(M)||g(c))&&c.generateMipmap(u)}else if(f===t.TextureSourceType.mipmaps){var I;u===c.TEXTURE_2D?x.forEach((function(t,e){var r;I="data"in t?s.texImage2DData(c,u,e,O,C,R,t):s.texImage2D(c,u,e,O,C,R,t),0===e&&(r=a(I,2),w=r[0],M=r[1])})):u===c.TEXTURE_CUBE_MAP&&T.forEach((function(t,e){t.forEach((function(t,r){var i;I="data"in t?s.texImage2DData(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,O,C,R,t):s.texImage2D(c,c.TEXTURE_CUBE_MAP_POSITIVE_X+r,e,O,C,R,t),0===e&&(i=a(I,2),w=i[0],M=i[1])}))}))}else f===t.TextureSourceType.compressed&&A&&(w=A[0].width,M=A[0].height,A.forEach((function(t,e){c.compressedTexImage2D(u,e,O,t.width,t.height,0,t.data)})));this.width=w,this.height=M,this.setTextureFilters(c,u,l)},s.prototype.setTextureFilters=function(t,e,r){var i=r.anisotropic,n=void 0===i?4:i,o=r.wrapS,s=void 0===o?t.CLAMP_TO_EDGE:o,a=r.wrapT,u=void 0===a?t.CLAMP_TO_EDGE:a,l=this.engine.gpuCapability;this.target===t.TEXTURE_2D&&l.setTextureAnisotropic(t,this.target,n);var c=g(t)||Su(this.width)&&Su(this.height),h=r.minFilter?r.minFilter:t.NEAREST,f=r.magFilter?r.magFilter:t.NEAREST;t.texParameteri(e,t.TEXTURE_MIN_FILTER,h),t.texParameteri(e,t.TEXTURE_MAG_FILTER,f),t.texParameteri(e,t.TEXTURE_WRAP_S,c?s:t.CLAMP_TO_EDGE),t.texParameteri(e,t.TEXTURE_WRAP_T,c?u:t.CLAMP_TO_EDGE)},s.prototype.texImage2D=function(e,r,i,n,o,s,a){var u,l=this,c=this.source,h=c.sourceType,f=c.minFilter,p=c.magFilter;c.flipY;var d=c.wrapS,m=c.wrapT,v=null!==(u=this.engine.gpuCapability.detail.maxTextureSize)&&void 0!==u?u:2048,y=a;if(h!==t.TextureSourceType.video){var g=f!==e.NEAREST||p!==e.NEAREST||d!==e.CLAMP_TO_EDGE||m!==e.CLAMP_TO_EDGE;(g=g||a.width>v||a.height>v)&&setTimeout((function(){y=l.resizeImage(a)}))}e.texImage2D(r,i,n,o,s,y);var x=[y.width,y.height];if(h===t.TextureSourceType.video){var T=a;return[T.videoWidth,T.videoHeight]}return x},s.prototype.texImage2DData=function(t,e,r,i,n,o,s){var a=s.data,u=s.width,l=s.height,c=n===t.UNSIGNED_BYTE?new Uint8Array(a.buffer,a.byteOffset,a.byteLength/a.BYTES_PER_ELEMENT):a;return t.texImage2D(e,r,i,u,l,0,n,o,c),[u,l]},s.prototype.resizeImage=function(t,e,r){var i,n=null!==(i=this.engine.gpuCapability.detail.maxTextureSize)&&void 0!==i?i:2048;if(g(this.pipelineContext.gl)&&t.width<n&&t.height<n)return t;var o=function(t,e,r,i){var n=t.width,o=t.height,s=Math.min(e,r||ae(n)),a=Math.min(e,i||ae(o));if(a!==o||s!==n){var u=_s.getCanvas(),l=u.getContext("2d");return u.width=s,u.height=a,null==l||l.drawImage(t,0,0,n,o,0,0,s,a),Be.warn("Image resize from ".concat(n,"x").concat(o," to ").concat(s,"x").concat(a)),u}}(t,n,e,r);return o||t},s.prototype.reloadData=function(){return n(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return this.offloaded?[4,Gr().reload(this)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},s.prototype.offloadData=function(){if(this.initialized&&Gr().canOffloadTexture(this.source.sourceFrom)){var t=this.target,e=this.pipelineContext.gl;if(e&&this.textureBuffer){var r=new Uint8Array([255]);if(this.bind(),t===e.TEXTURE_2D)e.texImage2D(t,0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,r);else if(t===e.TEXTURE_CUBE_MAP)for(var i=[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<i.length;n++)e.texImage2D(i[n],0,e.LUMINANCE,1,1,0,e.LUMINANCE,e.UNSIGNED_BYTE,r);e.generateMipmap(t),this.width=1,this.height=1}this.offloaded=!0}},s.prototype.uploadCurrentVideoFrame=function(){return n(this,void 0,void 0,(function(){var e;return o(this,(function(r){switch(r.label){case 0:return this.source.sourceType===t.TextureSourceType.video&&this.source.video&&this.initialized?(e=this.source.video).paused?[4,e.play()]:[3,2]:[3,3];case 1:r.sent(),r.label=2;case 2:return this.update({video:this.source.video}),[2,!0];case 3:return[2,!1]}}))}))},s.prototype.updateSource=function(t){this.source=this.assembleOptions(i(i({},this.source),t)),this.sourceType=this.source.sourceType,this.sourceFrom=this.source.sourceFrom,this.update(this.source)},s.prototype.restore=function(){},s.prototype.dispose=function(){this.pipelineContext&&this.textureBuffer&&this.pipelineContext.gl.deleteTexture(this.textureBuffer),this.source.sourceType===t.TextureSourceType.video&&this.source.video&&this.initialized&&(this.source.video.pause(),this.source.video.src="",this.source.video.load()),this.width=0,this.height=0,this.textureBuffer=null,this.destroyed=!0,this.update=function(){Be.error("This texture has been destroyed.")},this.initialize=je,void 0!==this.engine&&this.engine.removeTexture(this)},s}(Vr);function Su(t){return 0==(t&t-1)&&0!==t}var bu,Au=function(){function t(t,e){this.engine=t,this.ready=!1,this.disposed=!1,this.gl=t.getGLPipelineContext().gl,this.vaoExt=t.gpuCapability.vaoExt,this.vao=this.createVertexArray(e)}return t.prototype.bind=function(){this.bindVertexArray(this.vao)},t.prototype.unbind=function(){this.bindVertexArray(null)},t.prototype.createVertexArray=function(t){var e=null;return g(this.gl)&&(e=this.gl.createVertexArray()),!e&&this.vaoExt&&(e=this.vaoExt.createVertexArrayOES()),e&&Ru(e,t),e},t.prototype.bindVertexArray=function(t){var e;g(this.gl)?this.gl.bindVertexArray(t):null===(e=this.vaoExt)||void 0===e||e.bindVertexArrayOES(t)},t.prototype.dispose=function(){var t;g(this.gl)?this.gl.deleteVertexArray(this.vao):null===(t=this.vaoExt)||void 0===t||t.deleteVertexArrayOES(this.vao)},t}(),_u=1,Cu=function(){function e(e){this.engine=e,this.textures=[],this.renderBuffers=[],this.frameBuffers=[],this.destroyed=!1;var r={width:1,height:1,data:new Uint8Array([255])},i=e.getGLPipelineContext(),n=i.gl;this.gl=n,this.pipelineContext=i,this.emptyTexture2D=new Eu(e,{data:r,sourceType:t.TextureSourceType.data,format:n.LUMINANCE,internalFormat:n.LUMINANCE,type:n.UNSIGNED_BYTE}),this.emptyTexture2D.initialize(),this.emptyTextureCube=new Eu(e,{target:n.TEXTURE_CUBE_MAP,cube:[r,r,r,r,r,r],sourceType:t.TextureSourceType.data,format:n.LUMINANCE,internalFormat:n.LUMINANCE,type:n.UNSIGNED_BYTE}),this.emptyTextureCube.initialize(),this.name="GLGPURenderer"+_u,_u++}return Object.defineProperty(e.prototype,"height",{get:function(){var t;return null===(t=this.gl)||void 0===t?void 0:t.drawingBufferHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){var t;return null===(t=this.gl)||void 0===t?void 0:t.drawingBufferWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvas",{get:function(){return this.gl.canvas},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),e.prototype.copy2=function(t,e){var r=this.gl;if(r){this.sourceFbo||(this.sourceFbo=r.createFramebuffer()),this.targetFbo||(this.targetFbo=r.createFramebuffer());var i=this.pipelineContext,n=r.COLOR_ATTACHMENT0;i.bindFramebuffer(r.FRAMEBUFFER,this.sourceFbo),r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_2D,t.textureBuffer,0),i.bindFramebuffer(r.FRAMEBUFFER,this.targetFbo),r.framebufferTexture2D(r.FRAMEBUFFER,n,r.TEXTURE_2D,e.textureBuffer,0),i.bindFramebuffer(r.READ_FRAMEBUFFER,this.sourceFbo),i.bindFramebuffer(r.DRAW_FRAMEBUFFER,this.targetFbo);var o=t.getWidth()===t.getHeight()&&e.getWidth()==e.getHeight()?r.NEAREST:r.LINEAR;r.blitFramebuffer(0,0,t.getWidth(),t.getHeight(),0,0,e.getWidth(),e.getHeight(),r.COLOR_BUFFER_BIT,o),i.bindFramebuffer(r.FRAMEBUFFER,null),i.bindFramebuffer(r.READ_FRAMEBUFFER,null),i.bindFramebuffer(r.DRAW_FRAMEBUFFER,null)}},e.prototype.resetColorAttachments=function(t,e){t.bind(),t.resetColorTextures(e)},e.prototype.createGLRenderBuffer=function(t){var e=this.gl.createRenderbuffer();return e&&z(this.renderBuffers,t),e},e.prototype.resize=function(t,e){var r=this.gl;(r&&r.drawingBufferWidth!==t||r.drawingBufferHeight!==e)&&(r.canvas.width=t,r.canvas.height=e,r.viewport(0,0,t,e),this.frameBuffers.forEach((function(r){var i=r.viewport;r.isCustomViewport||r.resize(i[0],i[1],t*r.viewportScale,e*r.viewportScale)})))},e.prototype.drawGeometry=function(t,e){if(this.gl){var r=t,i=e,n=i.shader.program;if(n){var o=n.setupAttributes(r),s=this.gl,a=r.indicesBuffer,u=r.drawStart,l=r.mode,c=r.drawCount;if(a){var h=a.type,f=a.elementCount;(c=isNaN(c)?f:c)>0&&s.drawElements(l,c,h,null!=u?u:0)}else c>0&&s.drawArrays(l,u,c);null==o||o.unbind()}else console.warn("Material "+i.name+" 的shader着色器程序未初始化。")}else console.warn("GLGPURenderer没有绑定gl对象, 无法绘制geometry")},e.prototype.createGLFrameBuffer=function(t,e){var r=this.gl.createFramebuffer();return r&&(z(this.frameBuffers,t),Ru(r,e,e)),r},e.prototype.createVAO=function(t){return new Au(this.engine,t)},e.prototype.deleteGLTexture=function(t){t.textureBuffer&&!this.destroyed&&(this.gl.deleteTexture(t.textureBuffer),B(this.textures,t),delete t.textureBuffer)},e.prototype.deleteGPUBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteBuffer(t.glBuffer),delete t.glBuffer)},e.prototype.deleteGLFrameBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteFramebuffer(t.fbo),B(this.frameBuffers,t),delete t.fbo)},e.prototype.deleteGLRenderBuffer=function(t){t&&!this.destroyed&&(this.gl.deleteRenderbuffer(t.buffer),B(this.renderBuffers,t),delete t.buffer)},e.prototype.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.prototype.lost=function(t){Be.error("gl lost, destroy glRenderer by default",t.target),this.deleteResource()},e.prototype.dispose=function(t){this.deleteResource();var e=this.gl;if(e&&t){var r=e.getExtension("WEBGL_lose_context");null==r||r.loseContext()}this.emptyTexture2D=this.emptyTextureCube=this.pipelineContext=this.gpu=this.gl=null,this.destroyed=!0},e}();function Ru(t,e,r){void 0!==e&&(t.__SPECTOR_Metadata={name:e},t.__SPECTOR_Object_TAG?(t.__SPECTOR_Object_TAG.displayText=e,r&&(t.__SPECTOR_Object_TAG.id=r)):t.__SPECTOR_Object_TAG={displayText:e,id:""})}var Ou,wu=function(){function t(t,e){this.pipelineContext=t,this.byteLength=0,this.destroyed=!1;var r=e.target,i=void 0===r?v.ARRAY_BUFFER:r,n=e.type,o=void 0===n?v.FLOAT:n,s=e.name,a=e.usage,u=void 0===a?v.STATIC_DRAW:a,l=e.data,c=e.elementCount,h=function(t){var e,r;return null!==(r=null===(e=Mu[t])||void 0===e?void 0:e.BYTES_PER_ELEMENT)&&void 0!==r?r:0}(o);this.target=i,this.type=o,this.usage=u,this.glBuffer=this.createGLBuffer(s),this.bytesPerElement=h,l?this.bufferData(l):c&&this.bufferData(h*c)}return Object.defineProperty(t.prototype,"elementCount",{get:function(){return this.byteLength/this.bytesPerElement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),t.prototype.createGLBuffer=function(t){var e=this.pipelineContext.gl.createBuffer();return e&&Ru(e,t),e},t.prototype.bind=function(){this.pipelineContext.gl.bindBuffer(this.target,this.glBuffer)},t.prototype.bufferData=function(t){var e="number"==typeof t?t:t.byteLength;if(this.pipelineContext){this.byteLength=e;var r=this.pipelineContext.gl,i=this.target;r.bindBuffer(i,this.glBuffer),0===e?r.bufferData(i,1,this.usage):(r.bufferData(i,e,this.usage),"number"!=typeof t&&r.bufferSubData(i,0,t))}else this.byteLength=0},t.prototype.bufferSubData=function(t,e){if(this.pipelineContext){var r=this.pipelineContext.gl,i=this.target,n=t*this.bytesPerElement,o=n+e.byteLength;r.bindBuffer(i,this.glBuffer),o>this.byteLength&&(this.byteLength=o,r.bufferData(i,o,this.usage)),r.bufferSubData(i,n,e)}else this.byteLength=0},t.prototype.dispose=function(){this.pipelineContext.gl.deleteBuffer(this.glBuffer),this.glBuffer=null,this.destroyed=!0},t.prototype.readSubData=function(t,e){return!!g(this.pipelineContext.gl)&&(this.pipelineContext.gl.getBufferSubData(this.target,t*this.bytesPerElement,e),!0)},t}(),Mu=((bu={})[v.INT]=Int32Array,bu[v.FLOAT]=Float32Array,bu[v.SHORT]=Int16Array,bu[v.BYTE]=Int8Array,bu[v.UNSIGNED_BYTE]=Uint8Array,bu[v.UNSIGNED_INT]=Uint32Array,bu[v.UNSIGNED_SHORT]=Uint16Array,bu);var Lu=((Ou={})[Uint8Array.BYTES_PER_ELEMENT]=v.UNSIGNED_BYTE,Ou[Uint16Array.BYTES_PER_ELEMENT]=v.UNSIGNED_SHORT,Ou[Uint32Array.BYTES_PER_ELEMENT]=v.UNSIGNED_INT,Ou),Iu=1,Pu=function(t){function e(e,r){var i=this,n=r.drawStart,o=void 0===n?0:n,s=r.drawCount,a=r.mode,u=r.indices,l=r.name,c=void 0===l?"effectsGeometry:".concat(Iu++):l,h=r.bufferUsage,f=void 0===h?v.STATIC_DRAW:h;(i=t.call(this,c)||this).buffers={},i.vaos={},i.initialized=!1,i.indicesReleasable=!1,i.attributesName=[],i.destroyed=!1,i.engine=e;var p={},d=[],m={},y={},g={},x=f;return i.drawStart=o,i.drawCount=isNaN(+s)?NaN:s,i.mode=isNaN(a)?v.TRIANGLES:a,Object.keys(r.attributes).forEach((function(t){var e=r.attributes[t],i=e.size,n=e.stride,o=e.offset,s=e.normalize,a=e,u=a.type,l=void 0===u?v.FLOAT:u,c=a.releasable,h=e.data;if(!l||"dataSource"in e||h||(h=ci(l)),h){var f=h instanceof Float32Array?v.FLOAT:v.INT;p[t]={data:h,usage:x,target:v.ARRAY_BUFFER,name:t},m[t]={size:i,stride:n,offset:o,type:null!=l?l:f,normalize:!!s,dataSource:t},g[t]=null!=c&&c,y[t]={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0}}else{var T=e.dataSource;T&&(m[t]={size:i,stride:n,offset:o,type:l,dataSource:T,normalize:!!s})}d.push(t)})),y.index={dirty:!0,discard:!0,start:Number.POSITIVE_INFINITY,end:0},i.indices=null==u?void 0:u.data,i.indicesReleasable=!0===(null==u?void 0:u.releasable),i.bufferProps=p,i.attributes=m,i.attributesName=d,i.attributesReleasable=g,i.dirtyFlags=y,i.options=r,i}return r(e,t),Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInitialized",{get:function(){return this.initialized},enumerable:!1,configurable:!0}),e.prototype.getOptions=function(){return i({},this.options)},e.prototype.initialize=function(){var t=this;if(!this.initialized){var e=this.engine;rt(e),e.addGeometry(this);var r=this.engine.getGLPipelineContext();Object.keys(this.bufferProps).forEach((function(e){t.buffers[e]=new wu(r,t.bufferProps[e])})),this.indices&&(this.indicesBuffer=this.createIndicesBuffer(r,this.indices)),this.initialized=!0,this.flush(),this.options=void 0}},e.prototype.getAttributeBuffer=function(t){if(this.initialized){var e=this.attributes[t].dataSource;return this.buffers[e]}},e.prototype.setAttributeData=function(t,e){if(null!=this.bufferProps){var r=this.getAttributeBufferOption(t),i=this.attributes[t].dataSource;if(r){var n=r.usage,o=r.target;this.bufferProps[i]={data:e,usage:n,target:o,elementCount:e.length},this.dirtyFlags[i].discard=!0,this.dirtyFlags[i].dirty=!0}}},e.prototype.getAttributeData=function(t){if(null!=this.bufferProps){var e=this.getAttributeBufferOption(t);return e?e.data:void 0}},e.prototype.setAttributeSubData=function(t,e,r){if(null!=this.bufferProps){var i=this.getAttributeBufferOption(t);if(i&&null!=i.data){var n=e,o=e+r.length;if(i.data.length<o){var s=new r.constructor(o);s.set(i.data),i.data=s,this.dirtyFlags[t].discard=!0}else if(!this.dirtyFlags[t].discard){var a=this.dirtyFlags[t];a.start=Math.min(a.start,n),a.end=Math.max(a.end,o-1)}i.data.set(r,n),this.dirtyFlags[t].dirty=!0}}},e.prototype.getIndexData=function(){return this.indices},e.prototype.setIndexData=function(t){(t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Uint32Array)&&(this.indices=t,this.dirtyFlags.index.discard=!0,this.dirtyFlags.index.dirty=!0)},e.prototype.setIndexSubData=function(t,e){var r;if(this.indices){var i=t,n=t+e.length;if(this.indices.length<n){var o=new e.constructor(end);o.set(this.indices),this.indices=o,this.dirtyFlags.index.discard=!0}else if(!this.dirtyFlags.index.discard){var s=this.dirtyFlags.index;s.start=Math.min(s.start,i),s.end=Math.max(s.end,n-1)}null===(r=this.indices)||void 0===r||r.set(e,i),this.dirtyFlags.index.dirty=!0}},e.prototype.getAttributeStride=function(t){var e=this.attributes[t],r=e.stride,i=e.size,n=e.type;return r||i*ui[n]},e.prototype.getAttributeNames=function(){return this.attributesName},e.prototype.setDrawStart=function(t){this.drawStart=t},e.prototype.getDrawStart=function(){return this.drawStart},e.prototype.setDrawCount=function(t){this.drawCount=t},e.prototype.getDrawCount=function(){return this.drawCount},e.prototype.getAttributeBufferOption=function(t){var e=this.attributes[t];return e?this.bufferProps[e.dataSource]:void 0},e.prototype.createIndicesBuffer=function(t,e){var r=Lu[e.BYTES_PER_ELEMENT],i={data:e,target:v.ELEMENT_ARRAY_BUFFER,type:r,name:"".concat(this.name,"##index")};return new wu(t,i)},e.prototype.flush=function(){var t=this;if(this.initialized){var e=this.attributes,r=this.bufferProps,i=this.indices;Object.keys(this.dirtyFlags).forEach((function(n){var o,s,a=t.dirtyFlags[n];if("index"==n)o=t.indicesBuffer,s=i;else{var u=e[n].dataSource;o=t.buffers[u],s=r[u].data}if((a.dirty||a.discard)&&o&&s){if(a.discard)o.bufferData(s);else{var l=a.start*s.BYTES_PER_ELEMENT+s.byteOffset,c=a.end-a.start+1,h=new s.constructor(s.buffer,l,c);o.bufferSubData(a.start,h)}a.start=Number.POSITIVE_INFINITY,a.end=0,a.dirty=a.discard=!1}})),Object.keys(this.attributesReleasable).forEach((function(i){var n=t.attributesReleasable[i],o=e[i].dataSource;r[o]&&n&&(r[o].data=void 0)})),this.indicesReleasable}},e.prototype.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)||void 0===t||t.dispose(),Object.keys(this.vaos).forEach((function(t){var r;null===(r=e.vaos[t])||void 0===r||r.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},e}(li),Fu=function(){function t(){this.reset()}return t.prototype.setBlendColor=function(t){var e=a(t,4),r=e[0],i=e[1],n=e[2],o=e[3];this.blendColor[0]===r&&this.blendColor[1]===i&&this.blendColor[2]===n&&this.blendColor[3]===o||(this.blendColor[0]=r,this.blendColor[1]=i,this.blendColor[2]=n,this.blendColor[3]=o)},t.prototype.setBlending=function(t){this.blending!==t&&(this.blending=t)},t.prototype.setBlendFunctionParameters=function(t){var e=a(t,4),r=e[0],i=e[1],n=e[2],o=e[3];this.blendFunctionParameters[0]===r&&this.blendFunctionParameters[1]===i&&this.blendFunctionParameters[2]===n&&this.blendFunctionParameters[3]===o||(this.blendFunctionParameters[0]=r,this.blendFunctionParameters[1]=i,this.blendFunctionParameters[2]=n,this.blendFunctionParameters[3]=o)},t.prototype.setBlendEquationParameters=function(t){var e=a(t,2),r=e[0],i=e[1];this.blendEquationParameters[0]===r&&this.blendEquationParameters[1]===i||(this.blendEquationParameters[0]=r,this.blendEquationParameters[1]=i)},t.prototype.setDepthTest=function(t){this.depthTest!==t&&(this.depthTest=t)},t.prototype.setDepthMask=function(t){this.depthMask!==t&&(this.depthMask=t)},t.prototype.setDepthRange=function(t){this.depthRange[0]===t[0]&&this.depthRange[1]===t[1]||(this.depthRange[0]=t[0],this.depthRange[1]=t[1])},t.prototype.setDepthFunc=function(t){this.depthFunc!==t&&(this.depthFunc=t)},t.prototype.setPolygonOffsetFill=function(t){this.polygonOffsetFill!==t&&(this.polygonOffsetFill=t)},t.prototype.setPolygonOffset=function(t){this.polygonOffset[0]===t[0]&&this.polygonOffset[1]===t[1]||(this.polygonOffset[0]=t[0],this.polygonOffset[1]=t[1])},t.prototype.setSampleAlphaToCoverage=function(t){this.sampleAlphaToCoverage!==t&&(this.sampleAlphaToCoverage=t)},t.prototype.setColorMask=function(t){var e=a(t,4),r=e[0],i=e[1],n=e[2],o=e[3];this.colorMask[0]===r&&this.colorMask[1]===i&&this.colorMask[2]===n&&this.colorMask[3]===o||(this.colorMask[0]=r,this.colorMask[1]=i,this.colorMask[2]=n,this.colorMask[3]=o)},t.prototype.setStencilTest=function(t){this.stencilTest!==t&&(this.stencilTest=t)},t.prototype.setStencilMask=function(t){this.stencilMask[0]===t[0]&&this.stencilMask[1]===t[1]||(this.stencilMask[0]=t[0],this.stencilMask[1]=t[1])},t.prototype.setStencilRef=function(t){this.stencilRef[0]===t[0]&&this.stencilRef[1]===t[1]||(this.stencilRef[0]=t[0],this.stencilRef[1]=t[1])},t.prototype.setStencilFunc=function(t){this.stencilFunc[0]===t[0]&&this.stencilFunc[1]===t[1]||(this.stencilFunc[0]=t[0],this.stencilFunc[1]=t[1])},t.prototype.setStencilOpFail=function(t){this.stencilOpFail[0]===t[0]&&this.stencilOpFail[1]===t[1]||(this.stencilOpFail[0]=t[0],this.stencilOpFail[1]=t[1])},t.prototype.setStencilOpZFail=function(t){this.stencilOpZFail[0]===t[0]&&this.stencilOpZFail[1]===t[1]||(this.stencilOpZFail[0]=t[0],this.stencilOpZFail[1]=t[1])},t.prototype.setStencilOpZPass=function(t){this.stencilOpZPass[0]===t[0]&&this.stencilOpZPass[1]===t[1]||(this.stencilOpZPass[0]=t[0],this.stencilOpZPass[1]=t[1])},t.prototype.setCulling=function(t){this.culling!==t&&(this.culling=t)},t.prototype.setFrontFace=function(t){this.frontFace!==t&&(this.frontFace=t)},t.prototype.setCullFace=function(t){this.cullFace!==t&&(this.cullFace=t)},t.prototype.reset=function(){this.blending=!1,this.blendColor=[0,0,0,0],this.blendFunctionParameters=[v.ONE,v.ONE_MINUS_SRC_ALPHA,v.ONE,v.ONE_MINUS_SRC_ALPHA],this.blendEquationParameters=[v.FUNC_ADD,v.FUNC_ADD],this.depthTest=!1,this.depthMask=!1,this.depthRange=[0,1],this.depthFunc=v.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=[v.ALWAYS,v.ALWAYS],this.stencilOpFail=[v.KEEP,v.KEEP],this.stencilOpZFail=[v.KEEP,v.KEEP],this.stencilOpZPass=[v.KEEP,v.KEEP],this.culling=!1,this.frontFace=v.CW,this.cullFace=v.FRONT},t.prototype.apply=function(t){if(t.toggle(v.SAMPLE_ALPHA_TO_COVERAGE,this.sampleAlphaToCoverage),t.toggle(v.BLEND,this.blending),t.toggle(v.DEPTH_TEST,this.depthTest),t.toggle(v.STENCIL_TEST,this.stencilTest),t.toggle(v.CULL_FACE,this.culling),t.toggle(v.POLYGON_OFFSET_FILL,this.polygonOffsetFill),this.stencilTest&&(t.stencilMaskSeparate(v.BACK,this.stencilMask[1]),t.stencilMaskSeparate(v.FRONT,this.stencilMask[0]),t.stencilFuncSeparate(v.BACK,this.stencilFunc[0],this.stencilRef[0],this.stencilMask[0]),t.stencilFuncSeparate(v.FRONT,this.stencilFunc[1],this.stencilRef[1],this.stencilMask[1]),t.stencilOpSeparate(v.BACK,this.stencilOpFail[0],this.stencilOpZFail[0],this.stencilOpZPass[0]),t.stencilOpSeparate(v.FRONT,this.stencilOpFail[1],this.stencilOpZFail[1],this.stencilOpZPass[1])),this.blending){var e=this,r=e.blendColor,i=e.blendEquationParameters,n=e.blendFunctionParameters;t.blendColor(r[0],r[1],r[2],r[3]),t.blendEquationSeparate(i[0],i[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}(),Nu=zt,Vu=Ft,Du=function(e){function i(t,r){var i=e.call(this,r)||this;return i.floats={},i.ints={},i.vector2s={},i.vector3s={},i.vector4s={},i.quaternions={},i.matrices={},i.matrice3s={},i.textures={},i.floatArrays={},i.vector4Arrays={},i.matrixArrays={},i.samplers=[],i.uniforms=[],i.uniformDirtyFlag=!0,i.glMaterialState=new Fu,i.engine=t,i}return r(i,e),Object.defineProperty(i.prototype,"blending",{get:function(){return this.glMaterialState.blending},set:function(t){void 0!==t&&this.glMaterialState.setBlending(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendColor",{get:function(){return this.glMaterialState.blendColor},set:function(t){t&&this.glMaterialState.setBlendColor(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendFunction",{get:function(){return this.glMaterialState.blendFunctionParameters},set:function(t){t&&this.glMaterialState.setBlendFunctionParameters(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"blendEquation",{get:function(){return this.glMaterialState.blendEquationParameters},set:function(t){t&&this.glMaterialState.setBlendEquationParameters(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthTest",{get:function(){return this.glMaterialState.depthTest},set:function(t){void 0!==t&&this.glMaterialState.setDepthTest(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthMask",{get:function(){return this.glMaterialState.depthMask},set:function(t){void 0!==t&&this.glMaterialState.setDepthMask(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthRange",{get:function(){return this.glMaterialState.depthRange},set:function(t){t&&this.glMaterialState.setDepthRange(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthFunc",{get:function(){return this.glMaterialState.depthFunc},set:function(t){void 0!==t&&this.glMaterialState.setDepthFunc(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"polygonOffsetFill",{get:function(){return this.glMaterialState.polygonOffsetFill},set:function(t){void 0!==t&&this.glMaterialState.setPolygonOffsetFill(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"polygonOffset",{get:function(){return this.glMaterialState.polygonOffset},set:function(t){t&&this.glMaterialState.setPolygonOffset(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"sampleAlphaToCoverage",{get:function(){return this.glMaterialState.sampleAlphaToCoverage},set:function(t){void 0!==t&&this.glMaterialState.setSampleAlphaToCoverage(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"colorMask",{get:function(){return this.glMaterialState.colorMask},set:function(t){t&&this.glMaterialState.setColorMask(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilTest",{get:function(){return this.glMaterialState.stencilTest},set:function(t){void 0!==t&&this.glMaterialState.setStencilTest(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilMask",{get:function(){return this.glMaterialState.stencilMask},set:function(t){t&&this.glMaterialState.setStencilMask(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilRef",{get:function(){return this.glMaterialState.stencilRef},set:function(t){t&&this.glMaterialState.setStencilRef(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilFunc",{get:function(){return this.glMaterialState.stencilFunc},set:function(t){t&&this.glMaterialState.setStencilFunc(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilOpFail",{get:function(){return this.glMaterialState.stencilOpFail},set:function(t){t&&this.glMaterialState.setStencilOpFail(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilOpZFail",{get:function(){return this.glMaterialState.stencilOpZFail},set:function(t){t&&this.glMaterialState.setStencilOpZFail(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"stencilOpZPass",{get:function(){return this.glMaterialState.stencilOpZPass},set:function(t){t&&this.glMaterialState.setStencilOpZPass(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"culling",{get:function(){return this.glMaterialState.culling},set:function(t){void 0!==t&&this.glMaterialState.setCulling(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"frontFace",{get:function(){return this.glMaterialState.frontFace},set:function(t){void 0!==t&&this.glMaterialState.setFrontFace(t)},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cullFace",{get:function(){return this.glMaterialState.cullFace},set:function(t){void 0!==t&&this.glMaterialState.setCullFace(t)},enumerable:!1,configurable:!0}),i.prototype.enableKeyword=function(t){throw new Error("Method not implemented.")},i.prototype.disableKeyword=function(t){throw new Error("Method not implemented.")},i.prototype.isKeywordEnabled=function(t){throw new Error("Method not implemented.")},i.prototype.createMaterialStates=function(t){this.sampleAlphaToCoverage=!!t.sampleAlphaToCoverage,this.depthTest=t.depthTest,this.depthMask=t.depthMask,this.depthRange=t.depthRange,this.depthFunc=t.depthFunc,this.colorMask=t.colorMask,this.polygonOffset=t.polygonOffset,this.polygonOffsetFill=t.polygonOffsetFill,this.blending=t.blending,this.blendFunction=t.blendFunction,this.stencilTest=t.stencilTest},Object.defineProperty(i.prototype,"isDestroyed",{get:function(){return this.destroyed},enumerable:!1,configurable:!0}),i.prototype.initialize=function(){var t=this;if(!this.initialized){var e=this.engine;if(e.addMaterial(this),!this.shader){var r=e.getGLPipelineContext();this.shader=r.shaderLibrary.createShader(this.shaderSource)}this.shader.initialize(e),Object.keys(this.textures).forEach((function(e){var r=t.textures[e];Xe(r.initialize)?r.initialize():Be.error("".concat(JSON.stringify(r)," is not valid Texture to initialize"))})),this.initialized=!0}},i.prototype.setupStates=function(t){this.glMaterialState.apply(t)},i.prototype.use=function(t,e){var r,i,n,o,a,u=t.engine.getGLPipelineContext();if(this.shader.program.bind(),this.setupStates(u),e){try{for(var l=s(e.uniforms),c=l.next();!c.done;c=l.next())a=c.value,this.checkUniform(a)}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(r)throw r.error}}try{for(var h=s(e.samplers),f=h.next();!f.done;f=h.next())a=f.value,this.samplers.includes(a)||(this.samplers.push(a),this.uniformDirtyFlag=!0)}catch(t){n={error:t}}finally{try{f&&!f.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}if(this.uniformDirtyFlag&&(this.shader.fillShaderInformation(this.uniforms,this.samplers),this.uniformDirtyFlag=!1),e){for(a in e.floats)this.shader.setFloat(a,e.floats[a]);for(a in e.ints)this.shader.setInt(a,e.ints[a]);for(a in e.matrices)this.shader.setMatrix(a,e.matrices[a])}for(a in this.textures)this.textures[a].textureBuffer||this.textures[a].initialize();for(a in this.floats)this.shader.setFloat(a,this.floats[a]);for(a in this.ints)this.shader.setInt(a,this.ints[a]);for(a in this.floatArrays)this.shader.setFloats(a,this.floatArrays[a]);for(a in this.textures)this.shader.setTexture(a,this.textures[a]);for(a in this.vector2s)this.shader.setVector2(a,this.vector2s[a]);for(a in this.vector3s)this.shader.setVector3(a,this.vector3s[a]);for(a in this.vector4s)this.shader.setVector4(a,this.vector4s[a]);for(a in this.quaternions)this.shader.setQuaternion(a,this.quaternions[a]);for(a in this.matrices)this.shader.setMatrix(a,this.matrices[a]);for(a in this.matrice3s)this.shader.setMatrix3(a,this.matrice3s[a]);for(a in this.vector4Arrays)this.shader.setVector4Array(a,this.vector4Arrays[a]);for(a in this.matrixArrays)this.shader.setMatrixArray(a,this.matrixArrays[a])},i.prototype.getFloat=function(t){return this.floats[t]},i.prototype.setFloat=function(t,e){this.checkUniform(t),this.floats[t]=e},i.prototype.getInt=function(t){return this.ints[t]},i.prototype.setInt=function(t,e){this.checkUniform(t),this.ints[t]=e},i.prototype.getFloats=function(t){return this.floatArrays[t]},i.prototype.setFloats=function(t,e){this.checkUniform(t),this.floatArrays[t]=e},i.prototype.getVector2=function(t){return this.vector2s[t]},i.prototype.setVector2=function(t,e){this.checkUniform(t),this.vector2s[t]=e},i.prototype.getVector3=function(t){return this.vector3s[t]},i.prototype.setVector3=function(t,e){this.checkUniform(t),this.vector3s[t]=e},i.prototype.getVector4=function(t){return this.vector4s[t]},i.prototype.setVector4=function(t,e){this.checkUniform(t),this.vector4s[t]=e},i.prototype.getQuaternion=function(t){return this.quaternions[t]},i.prototype.setQuaternion=function(t,e){this.checkUniform(t),this.quaternions[t]=e},i.prototype.getMatrix=function(t){return this.matrices[t]},i.prototype.setMatrix=function(t,e){this.checkUniform(t),this.matrices[t]=e},i.prototype.setMatrix3=function(t,e){this.checkUniform(t),this.matrice3s[t]=e},i.prototype.getVector4Array=function(t){return this.vector4Arrays[t]},i.prototype.setVector4Array=function(t,e){var r,i;this.checkUniform(t),this.vector4Arrays[t]=[];try{for(var n=s(e),o=n.next();!o.done;o=n.next()){var a=o.value;this.vector4Arrays[t].push(a.x,a.y,a.z,a.w)}}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}},i.prototype.getMatrixArray=function(t){return this.matrixArrays[t]},i.prototype.setMatrixArray=function(t,e){var r,i;this.checkUniform(t),this.matrixArrays[t]=[];try{for(var n=s(e),o=n.next();!o.done;o=n.next())for(var a=o.value,u=0;u<16;u++)this.matrixArrays[t].push(a.elements[u])}catch(t){r={error:t}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}},i.prototype.setMatrixNumberArray=function(t,e){this.checkUniform(t),this.matrixArrays[t]=e},i.prototype.getTexture=function(t){return this.textures[t]},i.prototype.setTexture=function(t,e){this.samplers.includes(t)||(this.samplers.push(t),this.uniformDirtyFlag=!0),this.textures[t]=e},i.prototype.hasUniform=function(t){return this.uniforms.includes(t)||this.samplers.includes(t)},i.prototype.clone=function(t){var e=t||this.props,r=this.engine;rt(r);var n=new i(r,e);return n.glMaterialState=Object.assign(new Fu,n.glMaterialState),n.floats=this.floats,n.ints=this.ints,n.vector2s=this.vector2s,n.vector3s=this.vector3s,n.vector4s=this.vector4s,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.uniformDirtyFlag=!0,n},i.prototype.cloneUniforms=function(t){var e,r=t;for(e in r.floats)this.setFloat(e,r.floats[e]);for(e in r.ints)this.setInt(e,r.ints[e]);for(e in r.floatArrays)this.setFloats(e,r.floatArrays[e]);for(e in r.textures)this.setTexture(e,r.textures[e]);for(e in r.vector2s)this.setVector2(e,r.vector2s[e]);for(e in r.vector3s)this.setVector3(e,r.vector3s[e]);for(e in r.vector4s)this.setVector4(e,r.vector4s[e]);for(e in r.quaternions)this.setQuaternion(e,r.quaternions[e]);for(e in r.matrices)this.setMatrix(e,r.matrices[e]);for(e in r.vector4Arrays){for(var i=[],n=0;n<r.vector4Arrays[e].length;n+=4)i.push(new Nu(r.vector4Arrays[e][n],r.vector4Arrays[e][n+1],r.vector4Arrays[e][n+2],r.vector4Arrays[e][n+3]));this.setVector4Array(e,i)}for(e in r.matrixArrays){var o=[];for(n=0;n<r.matrixArrays[e].length;n+=16){for(var s=Vu.fromIdentity(),a=0;a<16;a++)s.elements[a]=r.matrixArrays[e][n+a];o.push(s)}this.setMatrixArray(e,o)}},i.prototype.checkUniform=function(t){this.uniforms.includes(t)||(this.uniforms.push(t),this.uniformDirtyFlag=!0)},i.prototype.dispose=function(e){var r,i=this;this.destroyed||(null===(r=this.shader)||void 0===r||r.dispose(),(null==e?void 0:e.textures)!==t.DestroyOptions.keep&&Object.keys(this.textures).forEach((function(t){i.textures[t].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=je,this.destroyed=!0,void 0!==this.engine&&(this.engine.removeMaterial(this),this.engine=void 0))},i}(qr),zu=function(){function e(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)}}return e.prototype.resetColorAttachments=function(t,e){this.renderer&&t.resetColorAttachments(e)},e.prototype.copyTexture=function(e,r){this.renderer&&(e.initialize(),r.initialize(),r.updateSource({sourceType:t.TextureSourceType.framebuffer,data:{width:r.getWidth()||e.getWidth(),height:r.getHeight()||e.getHeight()}}),2===this.renderer.engine.gpuCapability.level?this.copy2(e,r):this.copy1(e,r))},e.prototype.copy2=function(t,e){var r,i=this.renderer.getFrameBuffer();null===(r=this.renderer)||void 0===r||r.glRenderer.copy2(t,e),this.renderer.setFrameBuffer(i)},e.prototype.copy1=function(t,e){var r=this.copyRenderPass;if(r){var i=this.renderer;if(i){var n=r.frameBuffer;n.viewport[2]=e.getWidth()||t.getWidth(),n.viewport[3]=e.getHeight()||t.getHeight(),i.glRenderer.resetColorAttachments(n,[e]),r.meshes[0].material.setTexture("uTex",t),i.renderRenderPass(r)}}},e.prototype.createCopyRenderPass=function(){var e="mri-copy-mesh",r={texture:{format:v.RGBA}},i=this.renderer.engine,n=new Pu(i,{name:e,mode:v.TRIANGLE_STRIP,attributes:{aPos:{type:v.FLOAT,size:2,data:new Float32Array([-1,1,-1,-1,1,1,1,-1])}},drawCount:4}),o=i.gpuCapability.level,s=new Du(i,{name:e,shader:{cacheId:"$mri-internal-copy",name:e,vertex:br([],"\n precision highp float;\n attribute vec2 aPos;\n varying vec2 vTex;\n void main(){\n gl_Position = vec4(aPos,0.,1.0);\n vTex = (aPos + vec2(1.))/2.;\n }\n ",t.ShaderType.vertex,o),fragment:br([],"\n precision highp float;\n varying vec2 vTex;\n uniform sampler2D uTex;\n void main(){gl_FragColor = texture2D(uTex,vTex);}\n ",t.ShaderType.fragment,o),glslVersion:2===o?t.GLSLVersion.GLSL3:t.GLSLVersion.GLSL1}});s.blending=!1,s.depthTest=!1,s.culling=!1;var a=new gi(i,{name:e,geometry:n,material:s,priority:0});return new Bu(this.renderer,{name:"mri-copy-rp",clearAction:{colorAction:t.TextureLoadAction.whatever},attachments:[r],meshes:[a]})},e.prototype.dispose=function(){var t;this.renderer&&(null===(t=this.copyRenderPass)||void 0===t||t.dispose(),this.renderer=void 0)},e}(),Bu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.configure=function(t){this.currentFrameBuffer=t.getFrameBuffer(),t.setFrameBuffer(this.frameBuffer)},e.prototype.execute=function(t){this.clearAction&&t.clear(this.clearAction),t.renderMeshes(this.meshes),this.storeAction&&t.clear(this.storeAction),t.setFrameBuffer(this.currentFrameBuffer)},e}(bi),Uu=function(){function t(t,e,r){var i=this;void 0===e&&(e="webgl"),void 0===r&&(r={}),this.canvas=t,this.glType=e,this.restoreHandlers=[],this.lostHandlers=[],rt(t),this.gl=p(t,e,r),this.contextLostListener=function(t){var e,r,n;try{for(var o=s(i.lostHandlers),a=o.next();!a.done;a=o.next()){a.value.lost(t)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}null===(n=i.canvas)||void 0===n||n.removeEventListener("webglcontextlost",i.contextLostListener)},this.contextRestoredListener=function(t){var e,r,n;try{for(var o=s(i.restoreHandlers),a=o.next();!a.done;a=o.next()){a.value.restore()}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}null===(n=i.canvas)||void 0===n||n.addEventListener("webglcontextlost",i.contextLostListener)},t.addEventListener("webglcontextlost",this.contextLostListener),t.addEventListener("webglcontextrestored",this.contextRestoredListener)}return t.prototype.dispose=function(){this.canvas&&(this.canvas.removeEventListener("webglcontextlost",this.contextLostListener),this.canvas.removeEventListener("webglcontextrestored",this.contextRestoredListener)),this.gl=null,this.canvas=null},t.prototype.addLostHandler=function(t){this.lostHandlers.push(t)},t.prototype.removeLostHandler=function(t){var e=this.lostHandlers.indexOf(t);e>-1&&this.lostHandlers.splice(e,1)},t.prototype.addRestoreHandler=function(t){this.restoreHandlers.push(t)},t.prototype.removeRestoreHandler=function(t){var e=this.restoreHandlers.indexOf(t);e>-1&&this.restoreHandlers.splice(e,1)},t}(),ku=function(t){function e(e,r){var i=t.call(this,e)||this;return i.initialized=!1,void 0!==r&&i.initialize(r),i}return r(e,t),e.prototype.initialize=function(t){this.initialized||(this.initialized=!0,this.renderer=t,this.buffer=t.createGLRenderBuffer(this))},e.prototype.setSize=function(t,e){if(this.initialized){if(t!==this.size[0]||e!==this.size[1]){var r=this.renderer,i=r.gl;r.pipelineContext.bindRenderBuffer(i.RENDERBUFFER,this.buffer),t&&e?i.renderbufferStorage(i.RENDERBUFFER,this.format,this.size[0]=t,this.size[1]=e):Be.error("Invalid render buffer size: ".concat(t,"x").concat(e))}}else Be.error("Can't set size for uninitialized render buffer")},e.prototype.dispose=function(){this.renderer&&(this.renderer.deleteGLRenderBuffer(this),this.renderer=null,this.buffer=null),this.destroyed=!0,this.initialize=je},e}(en),Gu=1,Xu=function(e){function i(r,i){var n,o=e.call(this)||this;o.attachmentTextures=[],o.renderer=i,o.engine=i.engine;var s=r.depthStencilAttachment,a=r.viewport,u=r.isCustomViewport,l=r.viewportScale,c=void 0===l?1:l,h=r.storeAction,f=r.name,p=void 0===f?"GLFrameBuffer".concat(Gu++):f;return o.depthStencilStorageType=null!==(n=null==s?void 0:s.storageType)&&void 0!==n?n:t.RenderPassAttachmentStorageType.none,o.viewport=a,o.isCustomViewport=!!u,o.viewportScale=c,o.name=p,o.storeAction=h,o.updateProps(r),o}return r(i,e),Object.defineProperty(i.prototype,"stencilStorage",{get:function(){if(this.depthStencilStorageType!==t.RenderPassAttachmentStorageType.depth_16_opaque)return this.depthStencilRenderBuffer},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"depthStorage",{get:function(){if(this.depthStencilStorageType!==t.RenderPassAttachmentStorageType.stencil_8_opaque)return this.depthStencilRenderBuffer},enumerable:!1,configurable:!0}),i.prototype.getDepthTexture=function(){return this.depthTexture},i.prototype.getStencilTexture=function(){return this.stencilTexture},i.prototype.getColorTextures=function(){return this.colorTextures},i.prototype.updateAttachmentTextures=function(){var t=this;this.attachmentTextures.length=0,this.colorTextures.forEach((function(e){e.initialize(),z(t.attachmentTextures,e.textureBuffer)})),this.stencilTexture&&z(this.attachmentTextures,this.stencilTexture.textureBuffer),this.depthTexture&&z(this.attachmentTextures,this.depthTexture.textureBuffer)},i.prototype.updateProps=function(e){var r,i,n=this.renderer,o=this.engine.gpuCapability,s=null!==(r=e.depthStencilAttachment)&&void 0!==r?r:{storageType:t.RenderPassAttachmentStorageType.none},a=e.attachments.length>0;this.externalStorage=!1;var u=!0;if(e.attachments.length>1&&!o.detail.drawBuffers)throw Error("multiple color attachments not support");var l=null===(i=e.depthStencilAttachment)||void 0===i?void 0:i.texture,c=o.detail.readableDepthStencilTextures;if(this.colorTextures=e.attachments.slice(),!a&&s.storageType!==t.RenderPassAttachmentStorageType.none)throw Error("use depth stencil attachment without color attachments");a&&(this.fbo=n.glRenderer.createGLFrameBuffer(this,this.name));var h=s.storageType;if(h===t.RenderPassAttachmentStorageType.depth_stencil_opaque){if(s.storage){if(!(s.storage instanceof ku))throw Error("invalid depth stencil attachment storage");this.depthStencilRenderBuffer=s.storage,this.externalStorage=!0}else this.depthStencilRenderBuffer=new ku({format:v.DEPTH_STENCIL,attachment:v.DEPTH_STENCIL_ATTACHMENT,storageType:h},n.glRenderer);u=!1}else if(h===t.RenderPassAttachmentStorageType.depth_16_opaque)if(s.storage){if(!(s.storage instanceof ku))throw Error("invalid depth attachment storage");this.depthStencilRenderBuffer=s.storage,this.externalStorage=!0}else this.depthStencilRenderBuffer=new ku({attachment:v.DEPTH_ATTACHMENT,format:v.DEPTH_COMPONENT16,storageType:h},n.glRenderer);else if(h===t.RenderPassAttachmentStorageType.stencil_8_opaque)if(s.storage){if(!(s.storage instanceof ku))throw Error("invalid stencil attachment storage");this.depthStencilRenderBuffer=s.storage,this.externalStorage=!0}else this.depthStencilRenderBuffer=new ku({attachment:v.STENCIL_ATTACHMENT,format:v.STENCIL_INDEX8,storageType:h},n.glRenderer);else if(h===t.RenderPassAttachmentStorageType.depth_16_texture){if(!c)throw Error("depth texture is not support in framebuffer");this.depthTexture=null!=l?l:new Eu(this.engine,{sourceType:t.TextureSourceType.framebuffer,format:v.DEPTH_COMPONENT,internalFormat:o.internalFormatDepth16,type:v.UNSIGNED_SHORT,name:"".concat(this.name,"##depthTex")}),this.depthTexture.initialize()}else if(h===t.RenderPassAttachmentStorageType.depth_24_stencil_8_texture){if(!c)throw Error("depth stencil texture is not support in framebuffer");this.depthTexture=this.stencilTexture=null!=l?l:new Eu(this.engine,{sourceType:t.TextureSourceType.framebuffer,format:v.DEPTH_STENCIL,internalFormat:o.internalFormatDepth24_stencil8,type:o.UNSIGNED_INT_24_8,name:"".concat(this.name,"##dpthStclTex")}),this.depthTexture.initialize(),u=!0}this.storeInvalidAttachments=this.getStoreAttachments(this.storeAction,u),this.updateAttachmentTextures()},i.prototype.getStoreAttachments=function(e,r){var i=this.renderer.glRenderer.gl,n=this.colorTextures.length;if(e&&g(i)&&n>0){var o=[];if(e.depthAction===t.TextureStoreAction.clear&&this.depthStorage&&z(o,r?i.DEPTH_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),e.stencilAction===t.TextureStoreAction.clear&&this.stencilStorage&&z(o,r?i.STENCIL_ATTACHMENT:i.DEPTH_STENCIL_ATTACHMENT),e.colorAction===t.TextureStoreAction.clear)for(var s=0;s<n;s++)z(o,i["COLOR_ATTACHMENT".concat(s)]);return o}},i.prototype.unbind=function(){var t=this.storeInvalidAttachments;if(null==t?void 0:t.length){var e=this.renderer.glRenderer.gl;e.invalidateFramebuffer(e.FRAMEBUFFER,t)}this.renderer.pipelineContext.bindSystemFramebuffer()},i.prototype.bind=function(){var t=this,e=this.renderer.glRenderer.gl,r=this.renderer.pipelineContext;if(this.fbo){var i=e.FRAMEBUFFER,n=a(this.viewport,4),o=n[0],s=n[1],u=n[2],l=n[3];r.bindFramebuffer(i,this.fbo),r.viewport(o,s,u,l);var c=this.renderer.glRenderer.emptyTexture2D.textureBuffer;Object.keys(r.textureUnitDict).forEach((function(e){var i=r.textureUnitDict[e];i!==c&&i&&t.attachmentTextures.includes(i)&&(r.activeTexture(+e),t.renderer.glRenderer.emptyTexture2D.bind())}));for(var h=0;h<4;h++)r.activeTexture(e.TEXTURE0+h),this.renderer.glRenderer.emptyTexture2D.bind();if(!this.ready){var f=this,p=f.depthStencilRenderBuffer,d=f.depthTexture,m=f.stencilTexture;if(r.activeTexture(e.TEXTURE0),p)p.setSize(u,l),e.framebufferRenderbuffer(i,p.attachment,e.RENDERBUFFER,p.buffer);else if(d){d.source.data={width:u,height:l},d.update({data:{width:u,height:l,data:new Uint16Array(0)}});var v=d&&m?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;e.framebufferTexture2D(i,v,e.TEXTURE_2D,d.textureBuffer,0)}this.resetColorTextures(this.colorTextures);var y=e.checkFramebufferStatus(i);if(y!==e.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer failed, status: ".concat(y,", error: ").concat(e.getError()));this.ready=!0}}},i.prototype.resetColorTextures=function(t){var e,r,i=t,n=this.renderer.glRenderer.gl,o=this.engine.gpuCapability,a=this.viewport,u=[];if(i){try{for(var l=s(i),c=l.next();!c.done;c=l.next()){c.value.initialize()}}catch(t){e={error:t}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}this.colorTextures=i.slice()}this.renderer.pipelineContext.activeTexture(n.TEXTURE0),this.colorTextures.forEach((function(t,e){var r={width:a[2],height:a[3],data:new Uint8Array(0)};t.update({data:r}),o.framebufferTexture2D(n,n.FRAMEBUFFER,e,n.TEXTURE_2D,t.textureBuffer),u.push(!0)})),o.drawBuffers(n,u),this.updateAttachmentTextures()},i.prototype.resize=function(t,e,r,i){var n=a(this.viewport,4),o=n[0],s=n[1],u=n[2],l=n[3];o===t&&s===e&&u===r&&l===i||(this.viewport=[t,e,r,i],this.ready=!1,this.bind())},i.prototype.dispose=function(e){var r,i,n=this.renderer;if(n){n.glRenderer.deleteGLFrameBuffer(this),delete this.fbo;var o=(null==e?void 0:e.depthStencilAttachment)?e.depthStencilAttachment:t.RenderPassDestroyAttachmentType.force;(o===t.RenderPassDestroyAttachmentType.force||o===t.RenderPassDestroyAttachmentType.keepExternal&&!this.externalStorage)&&(null===(r=this.depthStencilRenderBuffer)||void 0===r||r.dispose(),null===(i=this.depthTexture)||void 0===i||i.dispose()),this.renderer=this.stencilRenderBuffer=this.depthStencilRenderBuffer=null}},i}(cn);var Hu,Yu,ju=function(t){for(var e=5381,r=t.length;r;)e=33*e^t.charCodeAt(--r);return e>>>0},Wu=((Hu={})[v.FLOAT]=1,Hu[v.INT]=1,Hu[v.UNSIGNED_INT]=1,Hu[v.SHORT]=1,Hu[v.BOOL]=1,Hu[v.UNSIGNED_SHORT]=1,Hu[v.FLOAT_VEC2]=2,Hu[v.FLOAT_VEC3]=3,Hu[v.FLOAT_VEC4]=4,Hu[v.FLOAT_MAT2]=4,Hu[v.FLOAT_MAT3]=9,Hu[v.FLOAT_MAT4]=16,Hu[v.FLOAT_MAT2x3]=6,Hu[v.FLOAT_MAT2x4]=8,Hu[v.FLOAT_MAT4x3]=12,Hu[v.FLOAT_MAT4x2]=8,Hu[v.FLOAT_MAT3x4]=12,Hu[v.FLOAT_MAT3x2]=6,Hu[v.INT_VEC2]=2,Hu[v.INT_VEC3]=3,Hu[v.INT_VEC4]=4,Hu[v.UNSIGNED_INT_VEC2]=2,Hu[v.UNSIGNED_INT_VEC3]=3,Hu[v.UNSIGNED_INT_VEC4]=4,Hu[v.BOOL_VEC2]=2,Hu[v.BOOL_VEC3]=3,Hu[v.BOOL_VEC4]=4,Hu),Zu=Ju(Float32Array),qu=Ju(Int32Array),Ku=Ju(Uint8Array);function Qu(t){return function(e,r,i,n){var o={start:r[1],dirty:!0};if(r[2]>1){var s=e;if(s.length){for(var a=n[1]||s.length,u=r[4]/t.BYTES_PER_ELEMENT,l=o.buffer=new t(a*u),c=n[0]||0,h=0;h<a;h++)l[h*u]=s[h+c];o.start+=c*u}}else o.buffer=new t([e]);return o}}function Ju(t){return function(e,r,i,n){for(var o=r[8],s=r[2],a=r[5],u=1===s?o:r[4],l=a?u/a:1,c=u/t.BYTES_PER_ELEMENT/l,h=o/t.BYTES_PER_ELEMENT/c,f=Wu[r[0]],p=f/l,d=(n[0]||0)*f,m=n[1]?l*n[1]:h,v=new t(c*m),y={start:r[1]+u*(n[0]||0),dirty:!0,buffer:v},g=0,x=0,T=d;g<m;g++){for(var E=0;E<p;E++)v[x+E]=e[T+E];x+=c,T+=p}return y}}function $u(t,e){for(var r=[],i=[],n=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS),o=function(n){var o=t.getActiveUniformBlockName(e,n),s={index:t.getUniformBlockIndex(e,o),usedByVertexShader:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER),usedByFragmentShader:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER),size:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_DATA_SIZE),uniformIndices:t.getActiveUniformBlockParameter(e,n,t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES),used:!1,uniforms:{},name:o,id:""};s.used=s.usedByVertexShader||s.usedByFragmentShader,r[n]=s;for(var a=s.uniformIndices,u=[],l=0;l<a.length;l++){var c=t.getActiveUniform(e,a[l]).name.replace("[0]","");s.uniforms[c]=[0,0,0,0,0,0,0,l,0],u[l]=c,i.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(r,i){t.getActiveUniforms(e,a,r).forEach((function(t,e){var r=u[e];s.uniforms[r][i]=+t}))}));for(l=0;l<u.length;l++){var h=s.uniforms[u[l]],f=s.uniforms[u[l+1]],p=f?f[1]:s.size;h[8]=p-h[1]}s.id=function(t){var e=t.name,r=t.size,i=t.uniforms,n=t.uniformIndices;return Object.keys(i).map((function(t){return"".concat(t,"[").concat(i[t].join(":"),"]")})).join("+"),ju("".concat(e,"+"),"".concat(r,"+"),"".concat(n.length,"+"))}(s)+""},s=0;s<n;++s)o(s);return{blockSpecs:r,blockUniformNames:i}}(Yu={})[v.FLOAT]=Qu(Float32Array),Yu[v.INT]=Qu(Int32Array),Yu[v.UNSIGNED_INT]=Qu(Uint32Array),Yu[v.SHORT]=Qu(Int16Array),Yu[v.BOOL]=Qu(Uint8Array),Yu[v.UNSIGNED_SHORT]=Qu(Uint16Array),Yu[v.FLOAT_VEC2]=Zu,Yu[v.FLOAT_VEC3]=Zu,Yu[v.FLOAT_VEC4]=Zu,Yu[v.FLOAT_MAT2]=Zu,Yu[v.FLOAT_MAT3]=Zu,Yu[v.FLOAT_MAT4]=Zu,Yu[v.FLOAT_MAT2x3]=Zu,Yu[v.FLOAT_MAT2x4]=Zu,Yu[v.FLOAT_MAT4x3]=Zu,Yu[v.FLOAT_MAT4x2]=Zu,Yu[v.FLOAT_MAT3x4]=Zu,Yu[v.FLOAT_MAT3x2]=Zu,Yu[v.INT_VEC2]=qu,Yu[v.INT_VEC3]=qu,Yu[v.INT_VEC4]=qu,Yu[v.UNSIGNED_INT_VEC2]=qu,Yu[v.UNSIGNED_INT_VEC3]=qu,Yu[v.UNSIGNED_INT_VEC4]=qu,Yu[v.BOOL_VEC2]=Ku,Yu[v.BOOL_VEC3]=Ku,Yu[v.BOOL_VEC4]=Ku;var tl=function(){function t(t,e,r,i){var n=this;this.engine=t,this.program=e,this.shared=r,this.id=i,this.uniformBlockMap={},this.pipelineContext=t.getGLPipelineContext();var o=this.pipelineContext.gl;if(this.pipelineContext.useProgram(e),this.attribInfoMap=this.createAttribMap(),g(o)){var s=$u(o,e),a=s.blockSpecs;s.blockUniformNames,a.forEach((function(t){return n.uniformBlockMap[t.name]=t}))}this.pipelineContext.useProgram(null)}return t.prototype.bind=function(){this.pipelineContext.useProgram(this.program)},t.prototype.setupAttributes=function(t){var e,r,i=this,n=this.id,o=this.pipelineContext.gl;return t.vaos[n]?r=t.vaos[n]:((r=new Au(this.engine,"".concat(t.name,"-").concat(n)))||console.error("创建vao对象失败"),t.vaos[n]=r),r&&(r.bind(),r.ready)||(Object.keys(this.attribInfoMap).forEach((function(e){var r=i.attribInfoMap[e],n=t.attributes[e];if(n){var s=t.buffers[n.dataSource];if(!s)throw Error("no buffer named ".concat(n.dataSource||e));s.bind(),o.enableVertexAttribArray(r.loc),o.vertexAttribPointer(r.loc,n.size,n.type,n.normalize,n.stride||0,n.offset||0)}})),null===(e=t.indicesBuffer)||void 0===e||e.bind(),r&&(r.ready=!0)),r},t.prototype.createAttribMap=function(){for(var t=this.pipelineContext.gl,e=this.program,r={},i=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES),n=0;n<i;n++){var o=t.getActiveAttrib(e,n),s=o.name,a=o.type,u=o.size,l=t.getAttribLocation(e,s);r[s]={type:a,name:s,size:u,loc:l}}return r},t.prototype.dispose=function(){this.pipelineContext&&(this.pipelineContext.gl.deleteProgram(this.program),this.pipelineContext=null)},t}(),el=function(t){function e(e){var r=t.call(this,e)||this;return r.initialized=!1,r.uniformLocations={},r.samplerChannels={},r}return r(e,t),e.prototype.initialize=function(t){this.initialized||t.getGLPipelineContext().shaderLibrary.compileShader(this)},e.prototype.setFloat=function(t,e){this.pipelineContext.setFloat(this.uniformLocations[t],e)},e.prototype.setInt=function(t,e){this.pipelineContext.setInt(this.uniformLocations[t],e)},e.prototype.setFloats=function(t,e){this.pipelineContext.setFloats(this.uniformLocations[t],e)},e.prototype.setTexture=function(t,e){this.pipelineContext.setTexture(this.uniformLocations[t],this.samplerChannels[t],e)},e.prototype.setVector2=function(t,e){this.pipelineContext.setVector2(this.uniformLocations[t],e)},e.prototype.setVector3=function(t,e){this.pipelineContext.setVector3(this.uniformLocations[t],e)},e.prototype.setVector4=function(t,e){this.pipelineContext.setVector4(this.uniformLocations[t],e)},e.prototype.setQuaternion=function(t,e){this.pipelineContext.setQuaternion(this.uniformLocations[t],e)},e.prototype.setMatrix=function(t,e){this.pipelineContext.setMatrix(this.uniformLocations[t],e)},e.prototype.setMatrix3=function(t,e){this.pipelineContext.setMatrix3(this.uniformLocations[t],e)},e.prototype.setVector4Array=function(t,e){this.pipelineContext.setVector4Array(this.uniformLocations[t],e)},e.prototype.setMatrixArray=function(t,e){this.pipelineContext.setMatrixArray(this.uniformLocations[t],e)},e.prototype.fillShaderInformation=function(t,e){var r=e.slice();t=t.concat(r);for(var i,n=this.pipelineContext.getUniforms(this.program.program,t),o=0;o<t.length;o++)this.uniformLocations[t[o]]=n[o];for(i=0;i<r.length;i++){null==this.uniformLocations[r[i]]&&(r.splice(i,1),i--)}for(i=0;i<r.length;i++){var s=r[i];this.samplerChannels[s]=i}},e.prototype.dispose=function(){var t;this.compileResult&&this.compileResult.shared||null===(t=this.program)||void 0===t||t.dispose()},e}(Qr),rl=0,il=function(){function e(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}return e.prototype.compileAllShaders=function(t){var e,r,i=this;if(this.shaderAllDone)t&&t([]);else{var n=[];try{for(var o=s(Object.keys(this.cachedShaders)),a=o.next();!a.done;a=o.next()){var u=a.value;this.cachedShaders[u].initialized||n.push(u)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}t?n.length?Promise.all(n.map((function(t){return new Promise((function(e){return i.compileShader(i.cachedShaders[t],e)}))}))).then(t).catch((function(){return 0})):t([]):n.map((function(t){return i.compileShader(i.cachedShaders[t])})),this.shaderAllDone=!0}},e.prototype.addShader=function(e){var r=this.computeShaderCacheId(e);if(this.cachedShaders[r])return r;this.shaderAllDone=!1;var i=e.glslVersion===t.GLSLVersion.GLSL3?"#version 300 es\n":"",n=e.vertex?i+e.vertex:"",o=e.fragment?i+e.fragment:"",s=!1;return(e.shared||e.cacheId)&&(s=!0),this.cachedShaders[r]=new el({vertex:n,fragment:o,name:e.name||r,shared:s}),this.cachedShaders[r].id=r,r},e.prototype.createShader=function(t){var e=this.addShader(t);return this.cachedShaders[e]},e.prototype.compileShader=function(e,r){var i=this,n=e.source,o=!1;(n.shared||n.cacheId)&&(o=!0);var s={vertex:n.vertex,fragment:n.fragment,name:n.name,shared:o},a=this.pipelineContext.gl,u={shared:s.shared,status:t.ShaderCompileResultStatus.compiling},l=this.createProgram(a,s.vertex,s.fragment,u),c=this.glAsyncCompileExt,h=performance.now(),f=function(r){u.status=t.ShaderCompileResultStatus.success,u.compileTime=performance.now()-h,e.program=r,e.initialized=!0,e.pipelineContext=i.pipelineContext,void 0!==i.programMap[e.id]&&console.warn("find duplicated shader id",e.id),i.programMap[e.id]=r},p=function(){var n=(!r||!c||c&&1==a.getProgramParameter(u.program,c.COMPLETION_STATUS_KHR))&&l();if(n){if(u.status!==t.ShaderCompileResultStatus.fail){Ru(n,s.name);var h=new tl(i.engine,n,o,e.id);if(a.validateProgram(n),a.getProgramParameter(n,a.VALIDATE_STATUS))f(h);else{var d=a.getProgramInfoLog(n);(null==d?void 0:d.includes("the same texture"))?f(h):(u.status=t.ShaderCompileResultStatus.fail,u.error=d,console.error("compileProgramError: "+d,"\nvertex:\n",s.vertex,"\nfragment:\n",s.fragment),a.deleteProgram(n))}}r&&r(u)}else r&&requestAnimationFrame(p)};e.compileResult=u,p()},e.prototype.computeShaderCacheId=function(t){var e,r=t.vertex?t.vertex:"",i=t.fragment?t.fragment:"";return e=t.shared||t.cacheId?t.cacheId||"shared_".concat(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var r=0,i=0;i<arguments.length;i++)for(var n=t[i],o=0;o<n.length;o++)r=Math.imul(31,r)+n.charCodeAt(o)|0;return r}(r,i)):"instanced_"+rl++,e},e.prototype.createProgram=function(e,r,i,n){var o=e.createProgram(),s=this.createGLShader(e,e.VERTEX_SHADER,r),a=this.createGLShader(e,e.FRAGMENT_SHADER,i);return o&&s&&a?(e.attachShader(o,s),e.attachShader(o,a),e.linkProgram(o),n.program=o,n.status=t.ShaderCompileResultStatus.compiling,function(){if(delete n.program,!e.getProgramParameter(o,e.LINK_STATUS)){var u=nl(e,s,"vertex",r),l=nl(e,a,"fragment",i);return n.status=t.ShaderCompileResultStatus.fail,u&&(n.error=u.error,n.status=u.status),l&&(n.error=l.error,n.status=l.status),o}return o}):(n.status=t.ShaderCompileResultStatus.fail,function(){return null})},e.prototype.createGLShader=function(t,e,r){var i=e===t.VERTEX_SHADER?this.glVertShaderMap:this.glFragShaderMap,n=ju(null!=r?r:""),o=i.get(n);if(o)return o;var s=t.createShader(e);return s&&(t.shaderSource(s,r),t.compileShader(s),i.set(n,s)),s},e.prototype.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.prototype.restore=function(){},e.prototype.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}},e}();function nl(e,r,i,n){if(!e.getShaderParameter(r,e.COMPILE_STATUS)){var o=e.getShaderInfoLog(r);return console.error("compile "+i+" error: "+o,(null!=n?n:"").split("\n").map((function(t,e){return"".concat(e+1," ").concat(t)})).join("\n")),{error:o,status:t.ShaderCompileResultStatus.fail}}}var ol=function(){function t(t,e){this.engine=t,this.gl=e,this.gl=e,this.shaderLibrary=new il(t,this),this.maxTextureCount=this.gl.TEXTURE0+this.gl.getParameter(this.gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS)-1,this.reset()}return t.prototype.dispose=function(){this.shaderLibrary.dispose(),this.reset()},t.prototype.reset=function(){this.glCapabilityCache={},this.activeTextureIndex=v.TEXTURE0,this.textureUnitDict={},this.currentFramebuffer={},this.pixelStorei={},this.currentRenderBuffer={}},t.prototype.toggle=function(t,e){e?this.enable(t):this.disable(t)},t.prototype.enable=function(t){!0!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!0,this.gl.enable(t))},t.prototype.disable=function(t){!1!==this.glCapabilityCache[t]&&(this.glCapabilityCache[t]=!1,this.gl.disable(t))},t.prototype.bindFramebuffer=function(t,e){this.currentFramebuffer[t]!==e&&(this.currentFramebuffer[t]=e,this.gl.bindFramebuffer(t,e))},t.prototype.bindRenderBuffer=function(t,e){this.currentRenderBuffer[t]!==e&&(this.currentRenderBuffer[t]=e,this.gl.bindRenderbuffer(t,e))},t.prototype.bindSystemFramebuffer=function(){this.bindFramebuffer(this.gl.FRAMEBUFFER,null)},t.prototype.useProgram=function(t){this.set1("useProgram",t)},t.prototype.clear=function(t){this.gl.clear(t)},t.prototype.clearDepth=function(t){this.set1("clearDepth",t)},t.prototype.depthFunc=function(t){this.set1("depthFunc",t)},t.prototype.depthMask=function(t){this.set1("depthMask",t)},t.prototype.polygonOffset=function(t,e){this.set2("polygonOffset",t,e)},t.prototype.depthRange=function(t,e){this.set2("depthRange",t,e)},t.prototype.clearStencil=function(t){this.set1("clearStencil",t)},t.prototype.stencilMask=function(t){this.stencilMaskSeparate(this.gl.FRONT,t),this.stencilMaskSeparate(this.gl.BACK,t)},t.prototype.stencilFunc=function(t,e,r){this.stencilFuncSeparate(this.gl.FRONT,t,e,r),this.stencilFuncSeparate(this.gl.BACK,t,e,r)},t.prototype.stencilFuncSeparate=function(t,e,r,i){this.set4("stencilFuncSeparate",t,e,r,i)},t.prototype.stencilMaskSeparate=function(t,e){this.set2("stencilMaskSeparate",t,e)},t.prototype.stencilOp=function(t,e,r){this.stencilOpSeparate(this.gl.FRONT,t,e,r),this.stencilOpSeparate(this.gl.BACK,t,e,r)},t.prototype.stencilOpSeparate=function(t,e,r,i){this.set4("stencilOpSeparate",t,e,r,i)},t.prototype.cullFace=function(t){this.set1("cullFace",t)},t.prototype.frontFace=function(t){this.set1("frontFace",t)},t.prototype.clearColor=function(t,e,r,i){this.set4("clearColor",t,e,r,i)},t.prototype.colorMask=function(t,e,r,i){this.set4("colorMask",t,e,r,i)},t.prototype.blendColor=function(t,e,r,i){this.set4("blendColor",t,e,r,i)},t.prototype.blendFunc=function(t,e){this.blendFuncSeparate(t,e,t,e)},t.prototype.blendFuncSeparate=function(t,e,r,i){this.set4("blendFuncSeparate",t,e,r,i)},t.prototype.blendEquation=function(t){this.set1("blendEquation",t)},t.prototype.blendEquationSeparate=function(t,e){this.set2("blendEquationSeparate",t,e)},t.prototype.setPixelStorei=function(t,e){this.pixelStorei[t]!==e&&(this.pixelStorei[t]=e,this.gl.pixelStorei(t,e))},t.prototype.viewport=function(t,e,r,i){this.set4("viewport",t,e,r,i)},t.prototype.activeTexture=function(t){t=Math.min(t,this.maxTextureCount),this.activeTextureIndex!==t&&(this.activeTextureIndex=t,this.gl.activeTexture(t))},t.prototype.bindTexture=function(t,e,r){(this.currentTextureBinding!==e||r)&&(this.gl.bindTexture(t,e),this.currentTextureBinding=e),this.textureUnitDict[this.activeTextureIndex]=e},t.prototype.set1=function(t,e){this.glCapabilityCache[t]!==e&&(this.glCapabilityCache[t]=e,this.gl[t](e))},t.prototype.set2=function(t,e,r){var i=this.glCapabilityCache[t];i||(i=this.glCapabilityCache[t]={x:NaN,y:NaN}),i.x===e&&i.y===r||this.gl[t](i.x=e,i.y=r)},t.prototype.set3=function(t,e,r,i){var n=this.glCapabilityCache[t];n||(n=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN}),n.x===e&&n.y===r&&n.z===i||this.gl[t](n.x=e,n.y=r,n.z=i)},t.prototype.set4=function(t,e,r,i,n){var o=this.glCapabilityCache[t];o||(o=this.glCapabilityCache[t]={x:NaN,y:NaN,z:NaN,w:NaN}),o.x===e&&o.y===r&&o.z===i&&o.w===n||this.gl[t](o.x=e,o.y=r,o.z=i,o.w=n)},t.prototype.get=function(t){return this.glCapabilityCache[t]},t.prototype.setFloat=function(t,e){t&&this.gl.uniform1f(t,e)},t.prototype.setInt=function(t,e){t&&this.gl.uniform1i(t,e)},t.prototype.setFloats=function(t,e){t&&this.gl.uniform1fv(t,e)},t.prototype.setVector2=function(t,e){this.setFloat2(t,e.x,e.y)},t.prototype.setVector3=function(t,e){this.setFloat3(t,e.x,e.y,e.z)},t.prototype.setVector4=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},t.prototype.setQuaternion=function(t,e){this.setFloat4(t,e.x,e.y,e.z,e.w)},t.prototype.setVector4Array=function(t,e){t&&e.length%4==0&&this.gl.uniform4fv(t,e)},t.prototype.setMatrix=function(t,e){t&&this.gl.uniformMatrix4fv(t,!1,e.elements)},t.prototype.setMatrix3=function(t,e){t&&this.gl.uniformMatrix3fv(t,!1,e.elements)},t.prototype.setMatrixArray=function(t,e){t&&e.length%16==0&&this.gl.uniformMatrix4fv(t,!1,e)},t.prototype.setTexture=function(t,e,r){if(t){this.gl.activeTexture(this.gl.TEXTURE0+e);var i=r.target;this.gl.bindTexture(i,r.textureBuffer),this.gl.uniform1i(t,e)}},t.prototype.getUniforms=function(t,e){for(var r=[],i=0;i<e.length;i++)r.push(this.gl.getUniformLocation(t,e[i]));return r},t.prototype.setFloat4=function(t,e,r,i,n){t&&this.gl.uniform4f(t,e,r,i,n)},t.prototype.setFloat3=function(t,e,r,i){t&&this.gl.uniform3f(t,e,r,i)},t.prototype.setFloat2=function(t,e,r){t&&this.gl.uniform2f(t,e,r)},t}(),sl=function(t){function e(e){var r=t.call(this)||this;return r.gpuCapability=new nn(e),r}return r(e,t),e.prototype.dispose=function(){this.isDestroyed||t.prototype.dispose.call(this)},e.prototype.getGLRenderer=function(){return this.renderer},e.prototype.getGLRendererInternal=function(){return this.getGLRenderer().glRenderer},e.prototype.getGLPipelineContext=function(){return this.getGLRenderer().pipelineContext},e}(yu),al=function(e){function n(r,n,o){var s=e.call(this)||this;s.canvas=r,s.temporaryRTs={};var a=i({preserveDrawingBuffer:void 0,alpha:!0,stencil:!0,antialias:!0,depth:!0,premultipliedAlpha:!0},o);s.context=new Uu(r,n,a);var u=s.context.gl;return rt(u),s.engine=new sl(u),s.engine.renderer=s,s.pipelineContext=new ol(s.engine,u),s.glRenderer=new Cu(s.engine),s.extension=new zu(s),s.renderingData={currentFrame:{}},s.frameBuffer=new Xu({storeAction:{},viewport:[0,0,s.width,s.height],attachments:[new Eu(s.engine,{sourceType:t.TextureSourceType.framebuffer,data:{width:s.width,height:s.height}})],depthStencilAttachment:{storageType:t.RenderPassAttachmentStorageType.none}},s),s}return r(n,e),Object.defineProperty(n.prototype,"isDestroyed",{get:function(){var t=this.glRenderer;return!t||t.isDestroyed},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){var t,e;return null!==(e=null===(t=this.glRenderer)||void 0===t?void 0:t.height)&&void 0!==e?e:0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){var t,e;return null!==(e=null===(t=this.glRenderer)||void 0===t?void 0:t.width)&&void 0!==e?e:0},enumerable:!1,configurable:!0}),n.prototype.renderRenderFrame=function(t){var e,r,i,n,o,a,u=t;u.resource&&u.resource.color_b.initialize(),u.emptyTexture.initialize(),u.transparentTexture.initialize();var l=u._renderPasses;if(this.isDestroyed)return console.error("renderer is destroyed",this);u.renderer.getShaderLibrary().compileAllShaders(),this.setFrameBuffer(null),this.clear(u.clearAction),this.renderingData.currentFrame=u,this.renderingData.currentCamera=u.camera,J(l);try{for(var c=s(l),h=c.next();!h.done;h=c.next()){var f=(m=h.value).delegate;null===(o=f.willBeginRenderPass)||void 0===o||o.call(f,m,this.renderingData),this.renderRenderPass(m),null===(a=f.didEndRenderPass)||void 0===a||a.call(f,m,this.renderingData)}}catch(t){e={error:t}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(e)throw e.error}}try{for(var p=s(l),d=p.next();!d.done;d=p.next()){var m;(m=d.value).frameCleanup(this)}}catch(t){i={error:t}}finally{try{d&&!d.done&&(n=p.return)&&n.call(p)}finally{if(i)throw i.error}}},n.prototype.renderRenderPass=function(t){this.renderingData.currentPass=t,t.initialize(this),t.configure(this),t.execute(this)},n.prototype.renderMeshes=function(t){var e,r,i,n,o=this.renderingData.currentPass.delegate;try{for(var a=s(t),u=a.next();!u.done;u=a.next()){var l=u.value;l.isDestroyed||l.getVisible()&&(l.material?(l.material.initialize(),l.geometry.initialize(),null===(i=o.willRenderMesh)||void 0===i||i.call(o,l,this.renderingData),l.render(this),null===(n=o.didRenderMesh)||void 0===n||n.call(o,l,this.renderingData)):console.warn("Mesh "+l.name+" 没有绑定材质。"))}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}},n.prototype.setGlobalFloat=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.floats[t]=e},n.prototype.setGlobalInt=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.ints[t]=e},n.prototype.setGlobalMatrix=function(t,e){this.checkGlobalUniform(t),this.renderingData.currentFrame.globalUniforms.matrices[t]=e},n.prototype.drawGeometry=function(t,e){this.glRenderer.drawGeometry(t,e)},n.prototype.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()))},n.prototype.getFrameBuffer=function(){return this.frameBuffer},n.prototype.getTemporaryRT=function(e,r,i,n,o,s){if(this.temporaryRTs[e])return this.temporaryRTs[e];var a,u,l=t.RenderPassAttachmentStorageType.none;o===t.FilterMode.Linear?a=v.LINEAR:o===t.FilterMode.Nearest&&(a=v.NEAREST),s===t.RenderTextureFormat.RGBA32?u=v.UNSIGNED_BYTE:s===t.RenderTextureFormat.RGBAHalf&&(u=v.HALF_FLOAT),0===n?l=t.RenderPassAttachmentStorageType.none:16===n?l=t.RenderPassAttachmentStorageType.depth_16_opaque:24===n&&(l=t.RenderPassAttachmentStorageType.depth_24_stencil_8_texture);var c=new Eu(this.engine,{sourceType:t.TextureSourceType.framebuffer,minFilter:a,magFilter:a,internalFormat:v.RGBA,format:v.RGBA,type:u}),h=new Xu({name:e,storeAction:{},viewport:[0,0,r,i],viewportScale:1,isCustomViewport:!0,attachments:[c],depthStencilAttachment:{storageType:l}},this);return this.temporaryRTs[e]=h,h},n.prototype.setViewport=function(t,e,r,i){this.pipelineContext.viewport(t,e,r,i)},n.prototype.clear=function(e){var r=this.pipelineContext,i=0;if(e.colorAction===t.TextureLoadAction.clear){var n=e.clearColor;n&&r.clearColor(n[0],n[1],n[2],n[3]),r.colorMask(!0,!0,!0,!0),i=v.COLOR_BUFFER_BIT}if(e.stencilAction===t.TextureLoadAction.clear&&(r.stencilMask(255),r.clearStencil(e.clearStencil||0),i|=v.STENCIL_BUFFER_BIT),e.depthAction===t.TextureLoadAction.clear){var o=e.clearDepth;r.depthMask(!0),r.clearDepth(Number.isFinite(o)?o:1),i|=v.DEPTH_BUFFER_BIT}i&&r.clear(i)},n.prototype.addLostHandler=function(t){this.context.addLostHandler(t)},n.prototype.addRestoreHandler=function(t){this.context.addRestoreHandler(t)},n.prototype.getShaderLibrary=function(){return this.pipelineContext.shaderLibrary},n.prototype.getWidth=function(){return this.width},n.prototype.getHeight=function(){return this.height},n.prototype.dispose=function(t){var e;this.context.dispose(),this.extension.dispose(),this.pipelineContext.dispose(),null===(e=this.glRenderer)||void 0===e||e.dispose(t),this.canvas=null,this.engine.dispose()},n.prototype.lost=function(t){t.preventDefault(),this.pipelineContext.dispose(),this.extension.dispose(),this.glRenderer.lost(t)},n.prototype.restore=function(){var t=this.context.gl;if(!t)throw new Error("Can not restore automatically because losing gl context");this.engine=new sl(t),this.engine.renderer=this,this.pipelineContext=new ol(this.engine,t),this.glRenderer=new Cu(this.engine),this.extension=new zu(this)},n.prototype.resize=function(t,e){var r=this.glRenderer;r&&(this.width===t&&this.height===e||r.resize(t,e))},n.prototype.checkGlobalUniform=function(t){var e=this.renderingData.currentFrame.globalUniforms;e.uniforms.includes(t)||e.uniforms.push(t)},n}(hn),ul="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",ll="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",cl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",hl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",fl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg",pl="https://galacean.antgroup.com/effects/#/user/gasrv4ka5sacrwpg";var dl=new Map,ml=!1,vl=1,yl=function(){function e(t){var e,r,a=this;this.compositions=[],this.displayScale=1,this.resumePending=!1,this.disposed=!1,this.assetManagers=[],this.speed=1,this.baseCompositionIndex=0,this.lost=function(t){var e,r;null===(e=a.ticker)||void 0===e||e.pause(),a.compositions.forEach((function(e){return e.lost(t)})),a.renderer.lost(t),null===(r=a.handleWebGLContextLost)||void 0===r||r.call(a,t),xl(a,!1)},this.restore=function(){return n(a,void 0,void 0,(function(){var t,e,r,i=this;return o(this,(function(s){switch(s.label){case 0:return this.renderer.restore(),t=this,[4,Promise.all(this.compositions.map((function(t){return n(i,void 0,void 0,(function(){var e,r,i,n,s,a,u,l,c,h,f,p;return o(this,(function(o){switch(o.label){case 0:return e=t.time,r=t.url,i=t.speed,n=t.keepResource,s=t.reusable,a=t.renderOrder,u=t.transform,l=t.videoState,[4,this.loadScene(r)];case 1:(c=o.sent()).speed=i,c.reusable=s,c.keepResource=n,c.renderOrder=a,c.transform=u,h=0,o.label=2;case 2:return h<l.length?l[h]?((f=c.textures[h].source.video).currentTime=null!==(p=l[h])&&void 0!==p?p:0,[4,f.play()]):[3,4]:[3,5];case 3:o.sent(),o.label=4;case 4:return h++,[3,2];case 5:return c.content.start(),c.gotoAndPlay(e),[2,c]}}))}))})))];case 1:return t.compositions=s.sent(),null===(e=this.handleWebGLContextRestored)||void 0===e||e.call(this),null===(r=this.ticker)||void 0===r||r.resume(),[2]}}))}))},this.handleResume=function(){var t;null===(t=a.handlePlayableUpdate)||void 0===t||t.call(a,{player:a,playing:!0})},this.handleClick=function(t){var e=t.x,r=t.y;a.compositions.forEach((function(t){var n,o=t.hitTest(e,r);if(o.length)for(var s=0;s<o.length;s++){var u=o[s].behavior||O.NOTIFY;u===O.NOTIFY?null===(n=a.handleItemClicked)||void 0===n||n.call(a,i(i({},o[s]),{composition:t.name,player:a})):u===O.RESUME_PLAYER&&a.resume()}}))};var u=t.container,l=t.canvas,c=t.gl,h=t.fps,f=t.name,p=t.pixelRatio,d=t.manualRender,v=t.interactive,y=t.reportGPUTime,g=t.onMessageItem,x=t.onPausedByItem,T=t.onItemClicked,E=t.onPlayableUpdate,S=t.onRenderError,b=t.onWebGLContextLost,A=t.onWebGLContextRestored,_=t.renderFramework,C=t.env,R=void 0===C?"":C,w=t.notifyTouch;if(m.length)throw new Error("Errors before player create: ".concat(m.map((function(t,e){return"\n ".concat(e+1,": ").concat(t)}))));var M=null!==(r=null!==(e=t.renderOptions)&&void 0!==e?e:t)&&void 0!==r?r:{},L=M.willCaptureImage,I=M.premultiplyAlpha;if(!ml&&"debug-disable"!==_){var P,F=Z()||(P=/iPhone OS (\d+)_(\d+)/.exec(navigator.userAgent))&&("13"===P[1]||"16"===P[1]&&"5"===P[2])?"webgl":"webgl2";if(_&&(F="webgl"===_?"webgl":"webgl2"),this.handleWebGLContextLost=b,this.handleWebGLContextRestored=A,this.reportGPUTime=y,this.handleItemClicked=T,this.handleMessageItem=g,this.handlePlayableUpdate=E,this.handleRenderError=S,this.handlePlayerPause=function(t){a.pause(),null==x||x({name:t.name,player:a})},this.pixelRatio=Number.isFinite(p)?p:W(),this.offscreenMode=!0,this.env=R,l)this.canvas=l;else if(c){this.canvas=c.canvas;var N=c instanceof WebGLRenderingContext?"webgl":"webgl2";F!==N&&(Be.error("The gl context(".concat(N,") is inconsistent with renderFramework or default version(").concat(F,")")),F=N)}else Tl(u),this.canvas=document.createElement("canvas"),u.appendChild(this.canvas);this.renderer=hn.create(this.canvas,F,{preserveDrawingBuffer:L,premultipliedAlpha:I}),this.renderer.env=R,this.renderer.addLostHandler({lost:this.lost}),this.renderer.addRestoreHandler({restore:this.restore}),this.gpuCapability=this.renderer.engine.gpuCapability,dl.forEach((function(t){t.gpuCapability.type!==a.gpuCapability.type&&Be.warn("Create player with different webgl version: old=".concat(t.gpuCapability.type,", new=").concat(a.gpuCapability.type))})),d||(this.ticker=new gu(h),this.ticker.add(this.tick.bind(this))),this.event=new yr(this.canvas,!!w),this.event.bindListeners(),this.event.addEventListener(fr,this.handleClick),this.interactive=null!=v&&v,this.name=f||"".concat(vl++),c||this.resize(),Tn(this.gpuCapability.detail),this.container=this.canvas.parentElement,dl.set(this.canvas,this),function(){var t,e,r=[];try{for(var i=s(dl.values()),n=i.next();!n.done;n=i.next()){var o=n.value;o.paused||r.push(o)}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}r.length>1&&Be.error("Current running player count: ".concat(r.length,", see ").concat(pl),r)}(),xl(this,!0)}}return e.prototype.setSpeed=function(t){isNaN(t)||(this.speed=t)},e.prototype.getSpeed=function(){return this.speed},e.prototype.getCompositionByName=function(t){return this.compositions.find((function(e){return e.name===t}))},e.prototype.getCompositions=function(){return this.compositions},Object.defineProperty(e.prototype,"hasPlayable",{get:function(){return this.compositions.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"paused",{get:function(){var t;return null===(t=this.ticker)||void 0===t?void 0:t.getPaused()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"interactive",{get:function(){return this.event.enabled},set:function(t){this.event.enabled=t},enumerable:!1,configurable:!0}),e.prototype.loadScene=function(t,e){var r;return n(this,void 0,void 0,(function(){var i,s,a=this;return o(this,(function(u){switch(u.label){case 0:return s=this.baseCompositionIndex,Ge(t)?(this.baseCompositionIndex+=t.length,[4,Promise.all(t.map((function(t,r){return n(a,void 0,void 0,(function(){var i;return o(this,(function(n){switch(n.label){case 0:return[4,this.createComposition(t,e)];case 1:return(i=n.sent()).setIndex(s+r),[2,i]}}))}))})))]):[3,2];case 1:return i=u.sent(),[3,4];case 2:return this.baseCompositionIndex+=1,[4,this.createComposition(t,e)];case 3:(i=u.sent()).setIndex(s),u.label=4;case 4:return null===(r=this.ticker)||void 0===r||r.start(),[2,i]}}))}))},e.prototype.createComposition=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var r,n,s,a,u,l,c,h,f=this;return o(this,(function(o){switch(o.label){case 0:return r=this.renderer,n=performance.now(),s=i({autoplay:!0},e),gl(t)?(a=t.scene,s=i(i({},s),t.options||{})):a=t,u=new hu(s),this.assetManagers.push(u),[4,u.loadScene(a,this.renderer,{env:this.env})];case 1:if(l=o.sent(),this.disposed)throw new Error("Disposed player can not used to create Composition");return c=new vu(i(i({},s),{renderer:r,width:r.getWidth(),height:r.getHeight(),event:this.event,onPlayerPause:this.handlePlayerPause,onMessageItem:this.handleMessageItem}),l),this.ticker&&c.renderLevel===E.B&&this.ticker.setFPS(Math.min(this.ticker.getFPS(),30)),[4,new Promise((function(t){f.renderer.getShaderLibrary().compileAllShaders((function(){t(null)}))}))];case 2:return o.sent(),s.autoplay?(this.autoPlaying=!0,c.play()):c.pause(),h=performance.now()-n+c.statistic.loadTime,c.statistic.firstFrameTime=h,Be.info("first frame: [".concat(c.name,"]").concat(h.toFixed(4),"ms")),this.compositions.push(c),[2,c]}}))}))},e.prototype.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)||void 0===t||t.start()},e.prototype.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)},e.prototype.gotoAndStop=function(t){var e,r;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?void 0:e.getPaused())||this.doTick(0,!0),null===(r=this.handlePlayableUpdate)||void 0===r||r.call(this,{player:this,playing:!1})},e.prototype.playSequence=function(t){for(var e,r=function(e){var r=t[e],i=r.onEnd;r.onEnd=function(){null==i||i.call(r,r),t[e+1].play()}},i=0;i<t.length-1;i++)r(i);t[0].play(),null===(e=this.ticker)||void 0===e||e.start()},e.prototype.pause=function(t){var e,r;this.paused||(null===(e=this.ticker)||void 0===e||e.pause(),null===(r=this.handlePlayableUpdate)||void 0===r||r.call(this,{player:this,playing:!1}),t&&t.offloadTexture&&this.offloadTexture())},e.prototype.resume=function(){var t;return n(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return this.resumePending?[2]:this.paused?(this.resumePending=!0,[4,Promise.all(this.compositions.map((function(t){return t.reloadTexture()})))]):[3,2];case 1:e.sent(),this.resumePending=!1,this.handleResume(),e.label=2;case 2:return null===(t=this.ticker)||void 0===t||t.resume(),[2]}}))}))},e.prototype.tick=function(t){this.doTick(t,this.forceRenderNextFrame),this.forceRenderNextFrame=!1},e.prototype.doTick=function(e,r){var i,n,o,s=this;e=Math.min(e,33)*this.speed;var a=this.compositions,u=!1;a.sort((function(t,e){return t.getIndex()-e.getIndex()})),this.compositions=[];for(var l=0;l<a.length;l++){var c=a[l];c.textureOffloaded?(u=!0,Be.error("Composition ".concat(c.name," texture offloaded, skip render.")),this.compositions.push(c)):(!c.isDestroyed&&c.renderer&&c.update(e),c.isDestroyed||this.compositions.push(c))}if(this.baseCompositionIndex=this.compositions.length,u)return null===(i=this.handleRenderError)||void 0===i||i.call(this,new Error("play when texture offloaded")),null===(n=this.ticker)||void 0===n?void 0:n.pause();if(!this.paused||r){var h=this.gpuCapability.level,f=this.renderer.context.gl,p=2===h&&this.reportGPUTime?d(f):void 0;if(null==p||p.begin(),this.compositions.length||this.compositions.length<a.length||r){this.renderer.setFrameBuffer(null),this.renderer.clear({stencilAction:t.TextureLoadAction.clear,clearStencil:0,depthAction:t.TextureLoadAction.clear,clearDepth:1,colorAction:t.TextureLoadAction.clear,clearColor:[0,0,0,0]});for(l=0;l<a.length;l++)!a[l].renderFrame.isDestroyed&&this.renderer.renderRenderFrame(a[l].renderFrame)}null==p||p.end(),null==p||p.getTime().then((function(t){var e;return null===(e=s.reportGPUTime)||void 0===e?void 0:e.call(s,null!=t?t:0)})).catch,this.autoPlaying&&(null===(o=this.handlePlayableUpdate)||void 0===o||o.call(this,{player:this,playing:!0}))}},e.prototype.resizeToAspect=function(t,e){void 0===e&&(e=1),t!==this.displayAspect&&(this.displayAspect=t),e!==this.displayScale&&(this.displayScale=e),this.resize()},e.prototype.resize=function(){var t,e,r,i,n,o=this.canvas.parentElement;if(o){var s=this.getTargetSize(o);e=s[0],r=s[1],i=s[2],n=s[3]}else e=i=this.canvas.width,r=n=this.canvas.height;var a=e/r;if(e&&r){var u=document.documentElement.clientWidth;i>2*u&&Be.error("DPI overflowed, width ".concat(i," is more than 2x document width ").concat(u,", see ").concat(ll));var l=this.env?this.gpuCapability.detail.maxTextureSize:2048;(i>l||n>l)&&(Be.error("Container size overflowed ".concat(i,"x").concat(n,", see ").concat(ul)),a>1?(i=Math.round(l),n=Math.round(l/a)):(n=Math.round(l),i=Math.round(l*a))),this.renderer.resize(i,n),this.canvas.style.width=e+"px",this.canvas.style.height=r+"px",Be.info("Resize player ".concat(this.name," [").concat(i,",").concat(n,",").concat(e,",").concat(r,"].")),null===(t=this.compositions)||void 0===t||t.forEach((function(t){t.camera.aspect=a}))}},e.prototype.clearCanvas=function(e){e?this.renderer.clear({stencilAction:t.TextureLoadAction.clear,clearStencil:0,depthAction:t.TextureLoadAction.clear,clearDepth:1,colorAction:t.TextureLoadAction.clear,clearColor:[0,0,0,0]}):this.forceRenderNextFrame=!0},e.prototype.destroyItem=function(t,e){},e.prototype.destroyCurrentCompositions=function(){this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.baseCompositionIndex=0},e.prototype.dispose=function(t){var e;if(Be.info("call player destroy: ".concat(this.name)),!this.disposed){dl.delete(this.canvas),this.pause(),null===(e=this.ticker)||void 0===e||e.stop(),this.assetManagers.forEach((function(t){return t.dispose()})),this.compositions.forEach((function(t){return t.dispose()})),this.compositions.length=0,this.renderer.context.removeLostHandler({lost:this.lost}),this.renderer.context.removeRestoreHandler({restore:this.restore}),this.event.dispose(),this.renderer.dispose(!t),xl(this,!1),this.canvas instanceof HTMLCanvasElement&&!t&&this.renderer.context&&(_s.dispose(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.canvas.remove());var r,i=(r=this.name,"Never use destroyed player: ".concat(r," again, see ").concat(fl)),n=function(){return function(t){throw new Error(t)}(i)},o=function(){return t=i,Promise.reject(t);var t};this.tick=n,this.resize=n,this.loadScene=o,this.play=o,this.gotoAndPlay=o,this.gotoAndStop=o,this.playSequence=n,this.destroyCurrentCompositions=n,this.resume=o,this.disposed=!0}},e.prototype.offloadTexture=function(){this.compositions.forEach((function(t){return t.offloadTexture()}))},e.prototype.getTargetSize=function(t){Tl(t);var e,r,i=this.displayAspect;i?t.clientWidth/t.clientHeight>i?e=(r=t.clientHeight*this.displayScale)*i:r=(e=t.clientWidth*this.displayScale)/i:(e=t.clientWidth,r=t.clientHeight);var n=this.pixelRatio,o=e,s=r;if(e=Math.round(e*n),(r=Math.round(r*n))<1||r<1){if(!this.offscreenMode)throw Error("Invalid container size ".concat(e,"x").concat(r,", see ").concat(cl));e=r=o=s=1}return[o,s,e,r]},e}();function gl(t){return He(t)&&"scene"in t&&"options"in t}function xl(t,e){Object.keys($e).forEach((function(r){var i=$e[r],n=e?i.onPlayerCreated:i.onPlayerDestroy;null==n||n(t)}))}function Tl(t){if(null==t)throw new Error("Container is not an HTMLElement, see ".concat(hl))}Vr.create=function(t,e){return new Eu(t,e)},Vr.createWithData=function(e,r,i){void 0===r&&(r=K("#fff")),void 0===i&&(i={});var n=i,o=n.type,s=void 0===o?v.UNSIGNED_BYTE:o,a=n.format,u=void 0===a?v.RGBA:a,l=n.internalFormat,c=n.wrapS,h=void 0===c?v.MIRRORED_REPEAT:c,f=n.wrapT,p=void 0===f?v.MIRRORED_REPEAT:f,d=n.minFilter,m=void 0===d?v.NEAREST:d,y=n.magFilter,g=void 0===y?v.NEAREST:y,x=n.flipY,T=void 0!==x&&x;return new Eu(e,{data:r,type:s,sourceType:t.TextureSourceType.data,format:u,internalFormat:l||u,wrapS:h,wrapT:p,minFilter:m,magFilter:g,flipY:T})},qr.create=function(t,e){return new Du(t,e)},li.create=function(t,e){return new Pu(t,e)},gi.create=function(t,e){return new gi(t,e)},en.create=function(t){return new ku(t)},cn.create=function(t,e){return new Xu(t,e)},hn.create=function(t,e,r){return new al(t,e,r)},yu.create=function(t){return new sl(t)};var El="1.2.4";Be.info("player version: "+El),t.AbstractPlugin=sr,t.AssetManager=hu,t.BYTES_TYPE_MAP=ui,t.BezierSegments=Ee,t.COMPRESSED_TEXTURE=un,t.COPY_FRAGMENT_SHADER=ei,t.COPY_MESH_SHADER_ID=$r,t.COPY_VERTEX_SHADER=ti,t.CalculateItem=In,t.CalculateLoader=ls,t.CalculateVFXItem=cs,t.Camera=js,t.CameraController=ar,t.CameraVFXItem=lr,t.CameraVFXItemLoader=ur,t.Composition=vu,t.CompositionSourceManager=uu,t.CurveValue=ge,t.DEFAULT_FONTS=Es,t.Downloader=Rr,t.EFFECTS_COPY_MESH_NAME=Jr,t.EVENT_TYPE_CLICK=fr,t.EVENT_TYPE_TOUCH_END=mr,t.EVENT_TYPE_TOUCH_MOVE=dr,t.EVENT_TYPE_TOUCH_START=pr,t.Engine=yu,t.EventSystem=yr,t.FILTER_NAME_NONE=h,t.FilterSpriteVFXItem=zn,t.Float16ArrayWrapper=Zt,t.FrameBuffer=cn,t.GLEngine=sl,t.GLGeometry=Pu,t.GLRenderer=al,t.GPUCapability=nn,t.Geometry=li,t.GlobalUniforms=tn,t.GradientValue=ye,t.HELP_LINK=f,t.InteractBehavior=vr,t.InteractItem=yn,t.InteractLoader=vn,t.InteractMesh=pn,t.InteractVFXItem=dn,t.KTXTexture=zr,t.LineSegments=xe,t.LinearValue=ve,t.Material=qr,t.MaterialDataBlock=Hr,t.Mesh=gi,t.PLAYER_OPTIONS_ENV_EDITOR=c,t.POST_PROCESS_SETTINGS="post_process_settings",t.ParticleLoader=as,t.ParticleMesh=Bn,t.ParticleSystem=Zo,t.ParticleVFXItem=ss,t.PassTextureCache=si,t.PathSegments=Te,t.Player=yl,t.PluginSystem=ir,t.QCanvasViewer=vs,t.QText=ms,t.RENDER_PASS_NAME_PREFIX=qi,t.RENDER_PREFER_LOOKUP_TEXTURE=hi,t.RUNTIME_ENV="runtime_env",t.RandomSetValue=pe,t.RandomValue=de,t.RandomVectorValue=me,t.RenderBuffer=en,t.RenderFrame=Qi,t.RenderPass=bi,t.RenderPassPriorityNormal=xi,t.RenderPassPriorityPostprocess=3e3,t.RenderPassPriorityPrepare=0,t.RenderTargetHandle=Ei,t.Renderer=hn,t.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_0="PRE_MAIN_COLOR_0",t.SEMANTIC_MAIN_PRE_COLOR_ATTACHMENT_SIZE_0="PRE_MAIN_COLOR_SIZE_0",t.SEMANTIC_PRE_COLOR_ATTACHMENT_0="PRE_COLOR_0",t.SEMANTIC_PRE_COLOR_ATTACHMENT_SIZE_0="PRE_COLOR_SIZE_0",t.SPRITE_VERTEX_STRIDE=l,t.SemanticMap=ai,t.Shader=Qr,t.SpriteItem=Nn,t.SpriteLoader=wn,t.SpriteMesh=xn,t.SpriteVFXItem=Vn,t.StaticValue=fe,t.TEMPLATE_USE_OFFSCREEN_CANVAS=fi,t.TextItem=Is,t.TextLoader=Fs,t.TextMesh=hs,t.TextVFXItem=Ps,t.Texture=Vr,t.TextureFactory=kr,t.Ticker=gu,t.TimelineComponent=Ne,t.Transform=Ke,t.VFXItem=Qe,t.ValueGetter=he,t.addByOrder=$,t.addItem=z,t.addItemWithOrder=U,t.alphaFrameFrag=Mi,t.alphaMaskFrag=Li,t.assertExist=rt,t.asserts=function(t,e){if(void 0===e&&(e="asserts failed"),!t)throw new Error(e)}
|
|
15
15
|
/*!
|
|
16
16
|
* Name: @galacean/effects-specification
|
|
17
17
|
* Description: Galacean Effects JSON Specification
|