!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";var t,e;t=void 0,e=function(t,e){function asyncGeneratorStep(t,e,i,r,n,s,a){try{var o=t[s](a),h=o.value}catch(t){return void i(t)}o.done?e(h):Promise.resolve(h).then(r,n)}function _asyncToGenerator(t){return function(){var e=this,i=arguments;return new Promise((function(r,n){var s=t.apply(e,i);function _next(t){asyncGeneratorStep(s,r,n,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(s,r,n,_next,_throw,"throw",t)}_next(void 0)}))}}function _callSuper(t,e,i){return e=_getPrototypeOf(e),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(e,i||[],_getPrototypeOf(t).constructor):e.apply(t,i))}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var i=0;i=0;--n){var s=this.tryEntries[n],a=s.completion;if("root"===s.tryLoc)return handle("end");if(s.tryLoc<=this.prev){var o=r.call(s,"catchLoc"),h=r.call(s,"finallyLoc");if(o&&h){if(this.prev=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev=0;--e){var i=this.tryEntries[e];if(i.finallyLoc===t)return this.complete(i.completion,i.afterLoc),resetTryEntry(i),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc===t){var r=i.completion;if("throw"===r.type){var n=r.arg;resetTryEntry(i)}return n}}throw Error("illegal catch attempt")},delegateYield:function(e,i,r){return this.delegate={iterator:values(e),resultName:i,nextLoc:r},"next"===this.method&&(this.arg=t),p}},e}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var e=function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}const i=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let r=1234567;const n=Math.PI/180,s=180/Math.PI;function clamp(t,e,i){return Math.max(e,Math.min(i,t))}function euclideanModulo(t,e){return(t%e+e)%e}function lerp(t,e,i){return(1-i)*t+i*e}const a={DEG2RAD:n,RAD2DEG:s,generateUUID:function generateUUID(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0;return(i[255&t]+i[t>>8&255]+i[t>>16&255]+i[t>>24&255]+"-"+i[255&e]+i[e>>8&255]+"-"+i[e>>16&15|64]+i[e>>24&255]+"-"+i[63&r|128]+i[r>>8&255]+"-"+i[r>>16&255]+i[r>>24&255]+i[255&n]+i[n>>8&255]+i[n>>16&255]+i[n>>24&255]).toLowerCase()},clamp:clamp,euclideanModulo:euclideanModulo,mapLinear:function mapLinear(t,e,i,r,n){return r+(t-e)*(n-r)/(i-e)},inverseLerp:function inverseLerp(t,e,i){return t!==e?(i-t)/(e-t):0},lerp:lerp,damp:function damp(t,e,i,r){return lerp(t,e,1-Math.exp(-i*r))},pingpong:function pingpong(t,e=1){return e-Math.abs(euclideanModulo(t,2*e)-e)},smoothstep:function smoothstep(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)},smootherstep:function smootherstep(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)},randInt:function randInt(t,e){return t+Math.floor(Math.random()*(e-t+1))},randFloat:function randFloat(t,e){return t+Math.random()*(e-t)},randFloatSpread:function randFloatSpread(t){return t*(.5-Math.random())},seededRandom:function seededRandom(t){void 0!==t&&(r=t);let e=r+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296},degToRad:function degToRad(t){return t*n},radToDeg:function radToDeg(t){return t*s},isPowerOfTwo:function isPowerOfTwo(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function ceilPowerOfTwo(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function floorPowerOfTwo(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function setQuaternionFromProperEuler(t,e,i,r,n){const s=Math.cos,a=Math.sin,o=s(i/2),h=a(i/2),u=s((e+r)/2),c=a((e+r)/2),l=s((e-r)/2),d=a((e-r)/2),p=s((r-e)/2),m=a((r-e)/2);switch(n){case"XYX":t.set(o*c,h*l,h*d,o*u);break;case"YZY":t.set(h*d,o*c,h*l,o*u);break;case"ZXZ":t.set(h*l,h*d,o*c,o*u);break;case"XZX":t.set(o*c,h*m,h*p,o*u);break;case"YXY":t.set(h*p,o*c,h*m,o*u);break;case"ZYZ":t.set(h*m,h*p,o*c,o*u);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}},normalize:function normalize$1(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("Invalid component type.")}},denormalize:function denormalize(t,e){switch(e.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("Invalid component type.")}}};class Quaternion{constructor(t=0,e=0,i=0,r=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=r}static slerpFlat(t,e,i,r,n,s,a){let o=i[r+0],h=i[r+1],u=i[r+2],c=i[r+3];const l=n[s+0],d=n[s+1],p=n[s+2],m=n[s+3];if(0===a)return t[e+0]=o,t[e+1]=h,t[e+2]=u,void(t[e+3]=c);if(1===a)return t[e+0]=l,t[e+1]=d,t[e+2]=p,void(t[e+3]=m);if(c!==m||o!==l||h!==d||u!==p){let t=1-a;const e=o*l+h*d+u*p+c*m,i=e>=0?1:-1,r=1-e*e;if(r>Number.EPSILON){const n=Math.sqrt(r),s=Math.atan2(n,e*i);t=Math.sin(t*s)/n,a=Math.sin(a*s)/n}const n=a*i;if(o=o*t+l*n,h=h*t+d*n,u=u*t+p*n,c=c*t+m*n,t===1-a){const t=1/Math.sqrt(o*o+h*h+u*u+c*c);o*=t,h*=t,u*=t,c*=t}}t[e]=o,t[e+1]=h,t[e+2]=u,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,r,n,s){const a=i[r],o=i[r+1],h=i[r+2],u=i[r+3],c=n[s],l=n[s+1],d=n[s+2],p=n[s+3];return t[e]=a*p+u*c+o*d-h*l,t[e+1]=o*p+u*l+h*c-a*d,t[e+2]=h*p+u*d+a*l-o*c,t[e+3]=u*p-a*c-o*l-h*d,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new Quaternion(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,r=t._y,n=t._z,s=t._order,a=Math.cos,o=Math.sin,h=a(i/2),u=a(r/2),c=a(n/2),l=o(i/2),d=o(r/2),p=o(n/2);switch(s){case"XYZ":this._x=l*u*c+h*d*p,this._y=h*d*c-l*u*p,this._z=h*u*p+l*d*c,this._w=h*u*c-l*d*p;break;case"YXZ":this._x=l*u*c+h*d*p,this._y=h*d*c-l*u*p,this._z=h*u*p-l*d*c,this._w=h*u*c+l*d*p;break;case"ZXY":this._x=l*u*c-h*d*p,this._y=h*d*c+l*u*p,this._z=h*u*p+l*d*c,this._w=h*u*c-l*d*p;break;case"ZYX":this._x=l*u*c-h*d*p,this._y=h*d*c+l*u*p,this._z=h*u*p-l*d*c,this._w=h*u*c+l*d*p;break;case"YZX":this._x=l*u*c+h*d*p,this._y=h*d*c+l*u*p,this._z=h*u*p-l*d*c,this._w=h*u*c-l*d*p;break;case"XZY":this._x=l*u*c-h*d*p,this._y=h*d*c-l*u*p,this._z=h*u*p+l*d*c,this._w=h*u*c+l*d*p;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],r=e[4],n=e[8],s=e[1],a=e[5],o=e[9],h=e[2],u=e[6],c=e[10],l=i+a+c;if(l>0){const t=.5/Math.sqrt(l+1);this._w=.25/t,this._x=(u-o)*t,this._y=(n-h)*t,this._z=(s-r)*t}else if(i>a&&i>c){const t=2*Math.sqrt(1+i-a-c);this._w=(u-o)/t,this._x=.25*t,this._y=(r+s)/t,this._z=(n+h)/t}else if(a>c){const t=2*Math.sqrt(1+a-i-c);this._w=(n-h)/t,this._x=(r+s)/t,this._y=.25*t,this._z=(o+u)/t}else{const t=2*Math.sqrt(1+c-i-a);this._w=(s-r)/t,this._x=(n+h)/t,this._y=(o+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return iMath.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(clamp(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const r=Math.min(1,e/i);return this.slerp(t,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let 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._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,r=t._y,n=t._z,s=t._w,a=e._x,o=e._y,h=e._z,u=e._w;return this._x=i*u+s*a+r*h-n*o,this._y=r*u+s*o+n*a-i*h,this._z=n*u+s*h+i*o-r*a,this._w=s*u-i*a-r*o-n*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,r=this._y,n=this._z,s=this._w;let a=s*t._w+i*t._x+r*t._y+n*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=s,this._x=i,this._y=r,this._z=n,this;const o=1-a*a;if(o<=Number.EPSILON){const t=1-e;return this._w=t*s+e*this._w,this._x=t*i+e*this._x,this._y=t*r+e*this._y,this._z=t*n+e*this._z,this.normalize(),this}const h=Math.sqrt(o),u=Math.atan2(h,a),c=Math.sin((1-e)*u)/h,l=Math.sin(e*u)/h;return this._w=s*c+this._w*l,this._x=i*c+this._x*l,this._y=r*c+this._y*l,this._z=n*c+this._z*l,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),n*Math.sin(e),n*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Vector3{constructor(t=0,e=0,i=0){this.isVector3=!0,Vector3.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return void 0===i&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new Vector3(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(h.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(h.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,r=this.z,n=t.elements,s=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*s,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*s,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*s,this}applyQuaternion(t){const e=this.x,i=this.y,r=this.z,n=t.x,s=t.y,a=t.z,o=t.w,h=2*(s*r-a*i),u=2*(a*e-n*r),c=2*(n*i-s*e);return this.x=e+o*h+s*c-a*u,this.y=i+o*u+a*h-n*c,this.z=r+o*c+n*u-s*h,this}transformDirection(t){const e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return 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}max(t){return 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}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(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}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,r=t.y,n=t.z,s=e.x,a=e.y,o=e.z;return this.x=r*o-n*a,this.y=n*s-i*o,this.z=i*a-r*s,this}projectOnVector(t){const e=t.lengthSq();if(0===e)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return o.copy(this).projectOnVector(t),this.sub(o)}reflect(t){return this.sub(o.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSphericalCoords(t,e,i){const r=Math.sin(e)*t;return this.x=r*Math.sin(i),this.y=Math.cos(e)*t,this.z=r*Math.cos(i),this}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,4*e)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,3*e)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=2*Math.random()-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}abs(){return this.x=Math.abs(this.x),this.y=Math.abs(this.y),this.z=Math.abs(this.z),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const o=new Vector3,h=new Quaternion,u=2e3;class Matrix4{constructor(t,e,i,r,n,s,a,o,h,u,c,l,d,p,m,f){this.isMatrix4=!0,Matrix4.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,e,i,r,n,s,a,o,h,u,c,l,d,p,m,f)}extractPosition(t){return console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."),this.copyPosition(t)}multiplyToArray(t,e,i){return console.error("THREE.Matrix4: .multiplyToArray() has been removed."),this}setRotationFromQuaternion(t){return this.makeRotationFromQuaternion(t)}set(t,e,i,r,n,s,a,o,h,u,c,l,d,p,m,f){const y=this.elements;return y[0]=t,y[4]=e,y[8]=i,y[12]=r,y[1]=n,y[5]=s,y[9]=a,y[13]=o,y[2]=h,y[6]=u,y[10]=c,y[14]=l,y[3]=d,y[7]=p,y[11]=m,y[15]=f,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new Matrix4).fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,r=1/c.setFromMatrixColumn(t,0).length(),n=1/c.setFromMatrixColumn(t,1).length(),s=1/c.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*s,e[9]=i[9]*s,e[10]=i[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,r=t.y,n=t.z,s=Math.cos(i),a=Math.sin(i),o=Math.cos(r),h=Math.sin(r),u=Math.cos(n),c=Math.sin(n);if("XYZ"===t.order){const t=s*u,i=s*c,r=a*u,n=a*c;e[0]=o*u,e[4]=-o*c,e[8]=h,e[1]=i+r*h,e[5]=t-n*h,e[9]=-a*o,e[2]=n-t*h,e[6]=r+i*h,e[10]=s*o}else if("YXZ"===t.order){const t=o*u,i=o*c,r=h*u,n=h*c;e[0]=t+n*a,e[4]=r*a-i,e[8]=s*h,e[1]=s*c,e[5]=s*u,e[9]=-a,e[2]=i*a-r,e[6]=n+t*a,e[10]=s*o}else if("ZXY"===t.order){const t=o*u,i=o*c,r=h*u,n=h*c;e[0]=t-n*a,e[4]=-s*c,e[8]=r+i*a,e[1]=i+r*a,e[5]=s*u,e[9]=n-t*a,e[2]=-s*h,e[6]=a,e[10]=s*o}else if("ZYX"===t.order){const t=s*u,i=s*c,r=a*u,n=a*c;e[0]=o*u,e[4]=r*h-i,e[8]=t*h+n,e[1]=o*c,e[5]=n*h+t,e[9]=i*h-r,e[2]=-h,e[6]=a*o,e[10]=s*o}else if("YZX"===t.order){const t=s*o,i=s*h,r=a*o,n=a*h;e[0]=o*u,e[4]=n-t*c,e[8]=r*c+i,e[1]=c,e[5]=s*u,e[9]=-a*u,e[2]=-h*u,e[6]=i*c+r,e[10]=t-n*c}else if("XZY"===t.order){const t=s*o,i=s*h,r=a*o,n=a*h;e[0]=o*u,e[4]=-c,e[8]=h*u,e[1]=t*c+n,e[5]=s*u,e[9]=i*c-r,e[2]=r*c-i,e[6]=a*u,e[10]=n*c+t}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(d,t,p)}lookAt(t,e,i){const r=this.elements;return y.subVectors(t,e),0===y.lengthSq()&&(y.z=1),y.normalize(),m.crossVectors(i,y),0===m.lengthSq()&&(1===Math.abs(i.z)?y.x+=1e-4:y.z+=1e-4,y.normalize(),m.crossVectors(i,y)),m.normalize(),f.crossVectors(y,m),r[0]=m.x,r[4]=f.x,r[8]=y.x,r[1]=m.y,r[5]=f.y,r[9]=y.y,r[2]=m.z,r[6]=f.z,r[10]=y.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,r=e.elements,n=this.elements,s=i[0],a=i[4],o=i[8],h=i[12],u=i[1],c=i[5],l=i[9],d=i[13],p=i[2],m=i[6],f=i[10],y=i[14],v=i[3],g=i[7],x=i[11],S=i[15],M=r[0],_=r[4],w=r[8],b=r[12],N=r[1],O=r[5],V=r[9],z=r[13],P=r[2],E=r[6],C=r[10],T=r[14],A=r[3],U=r[7],I=r[11],k=r[15];return n[0]=s*M+a*N+o*P+h*A,n[4]=s*_+a*O+o*E+h*U,n[8]=s*w+a*V+o*C+h*I,n[12]=s*b+a*z+o*T+h*k,n[1]=u*M+c*N+l*P+d*A,n[5]=u*_+c*O+l*E+d*U,n[9]=u*w+c*V+l*C+d*I,n[13]=u*b+c*z+l*T+d*k,n[2]=p*M+m*N+f*P+y*A,n[6]=p*_+m*O+f*E+y*U,n[10]=p*w+m*V+f*C+y*I,n[14]=p*b+m*z+f*T+y*k,n[3]=v*M+g*N+x*P+S*A,n[7]=v*_+g*O+x*E+S*U,n[11]=v*w+g*V+x*C+S*I,n[15]=v*b+g*z+x*T+S*k,this}multiplyScalar(t){const 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}determinant(){const t=this.elements,e=t[0],i=t[4],r=t[8],n=t[12],s=t[1],a=t[5],o=t[9],h=t[13],u=t[2],c=t[6],l=t[10],d=t[14];return t[3]*(+n*o*c-r*h*c-n*a*l+i*h*l+r*a*d-i*o*d)+t[7]*(+e*o*d-e*h*l+n*s*l-r*s*d+r*h*u-n*o*u)+t[11]*(+e*h*c-e*a*d-n*s*c+i*s*d+n*a*u-i*h*u)+t[15]*(-r*a*u-e*o*c+e*a*l+r*s*c-i*s*l+i*o*u)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const r=this.elements;return t.isVector3?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],s=t[4],a=t[5],o=t[6],h=t[7],u=t[8],c=t[9],l=t[10],d=t[11],p=t[12],m=t[13],f=t[14],y=t[15],v=c*f*h-m*l*h+m*o*d-a*f*d-c*o*y+a*l*y,g=p*l*h-u*f*h-p*o*d+s*f*d+u*o*y-s*l*y,x=u*m*h-p*c*h+p*a*d-s*m*d-u*a*y+s*c*y,S=p*c*o-u*m*o-p*a*l+s*m*l+u*a*f-s*c*f,M=e*v+i*g+r*x+n*S;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/M;return t[0]=v*_,t[1]=(m*l*n-c*f*n-m*r*d+i*f*d+c*r*y-i*l*y)*_,t[2]=(a*f*n-m*o*n+m*r*h-i*f*h-a*r*y+i*o*y)*_,t[3]=(c*o*n-a*l*n-c*r*h+i*l*h+a*r*d-i*o*d)*_,t[4]=g*_,t[5]=(u*f*n-p*l*n+p*r*d-e*f*d-u*r*y+e*l*y)*_,t[6]=(p*o*n-s*f*n-p*r*h+e*f*h+s*r*y-e*o*y)*_,t[7]=(s*l*n-u*o*n+u*r*h-e*l*h-s*r*d+e*o*d)*_,t[8]=x*_,t[9]=(p*c*n-u*m*n-p*i*d+e*m*d+u*i*y-e*c*y)*_,t[10]=(s*m*n-p*a*n+p*i*h-e*m*h-s*i*y+e*a*y)*_,t[11]=(u*a*n-s*c*n-u*i*h+e*c*h+s*i*d-e*a*d)*_,t[12]=S*_,t[13]=(u*m*r-p*c*r+p*i*l-e*m*l-u*i*f+e*c*f)*_,t[14]=(p*a*r-s*m*r-p*i*o+e*m*o+s*i*f-e*a*f)*_,t[15]=(s*c*r-u*a*r+u*i*o-e*c*o-s*i*l+e*a*l)*_,this}scale(t){const e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),r=Math.sin(e),n=1-i,s=t.x,a=t.y,o=t.z,h=n*s,u=n*a;return this.set(h*s+i,h*a-r*o,h*o+r*a,0,h*a+r*o,u*a+i,u*o-r*s,0,h*o-r*a,u*o+r*s,n*o*o+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,r,n,s){return this.set(1,i,n,0,t,1,s,0,e,r,1,0,0,0,0,1),this}compose(t,e,i){const r=this.elements,n=e._x,s=e._y,a=e._z,o=e._w,h=n+n,u=s+s,c=a+a,l=n*h,d=n*u,p=n*c,m=s*u,f=s*c,y=a*c,v=o*h,g=o*u,x=o*c,S=i.x,M=i.y,_=i.z;return r[0]=(1-(m+y))*S,r[1]=(d+x)*S,r[2]=(p-g)*S,r[3]=0,r[4]=(d-x)*M,r[5]=(1-(l+y))*M,r[6]=(f+v)*M,r[7]=0,r[8]=(p+g)*_,r[9]=(f-v)*_,r[10]=(1-(l+m))*_,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,i){const r=this.elements;let n=c.set(r[0],r[1],r[2]).length();const s=c.set(r[4],r[5],r[6]).length(),a=c.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),t.x=r[12],t.y=r[13],t.z=r[14],l.copy(this);const o=1/n,h=1/s,u=1/a;return l.elements[0]*=o,l.elements[1]*=o,l.elements[2]*=o,l.elements[4]*=h,l.elements[5]*=h,l.elements[6]*=h,l.elements[8]*=u,l.elements[9]*=u,l.elements[10]*=u,e.setFromRotationMatrix(l),i.x=n,i.y=s,i.z=a,this}makePerspective(t,e,i,r,n,s,a=2e3){const o=this.elements,h=2*n/(e-t),c=2*n/(i-r),l=(e+t)/(e-t),d=(i+r)/(i-r);let p,m;if(a===u)p=-(s+n)/(s-n),m=-2*s*n/(s-n);else{if(2001!==a)throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+a);p=-s/(s-n),m=-s*n/(s-n)}return o[0]=h,o[4]=0,o[8]=l,o[12]=0,o[1]=0,o[5]=c,o[9]=d,o[13]=0,o[2]=0,o[6]=0,o[10]=p,o[14]=m,o[3]=0,o[7]=0,o[11]=-1,o[15]=0,this}makeOrthographic(t,e,i,r,n,s,a=2e3){const o=this.elements,h=1/(e-t),c=1/(i-r),l=1/(s-n),d=(e+t)*h,p=(i+r)*c;let m,f;if(a===u)m=(s+n)*l,f=-2*l;else{if(2001!==a)throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);m=n*l,f=-1*l}return o[0]=2*h,o[4]=0,o[8]=0,o[12]=-d,o[1]=0,o[5]=2*c,o[9]=0,o[13]=-p,o[2]=0,o[6]=0,o[10]=f,o[14]=-m,o[3]=0,o[7]=0,o[11]=0,o[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<16;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const c=new Vector3,l=new Matrix4,d=new Vector3(0,0,0),p=new Vector3(1,1,1),m=new Vector3,f=new Vector3,y=new Vector3,v=new Matrix4,g=new Quaternion;class Euler{constructor(t=0,e=0,i=0,r=Euler.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=r}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,r=this._order){return this._x=t,this._y=e,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new Euler(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const r=t.elements,n=r[0],s=r[4],a=r[8],o=r[1],h=r[5],u=r[9],c=r[2],l=r[6],d=r[10];switch(e){case"XYZ":this._y=Math.asin(clamp(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-u,d),this._z=Math.atan2(-s,n)):(this._x=Math.atan2(l,h),this._z=0);break;case"YXZ":this._x=Math.asin(-clamp(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(a,d),this._z=Math.atan2(o,h)):(this._y=Math.atan2(-c,n),this._z=0);break;case"ZXY":this._x=Math.asin(clamp(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-s,h)):(this._y=0,this._z=Math.atan2(o,n));break;case"ZYX":this._y=Math.asin(-clamp(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(l,d),this._z=Math.atan2(o,n)):(this._x=0,this._z=Math.atan2(-s,h));break;case"YZX":this._z=Math.asin(clamp(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-u,h),this._y=Math.atan2(-c,n)):(this._x=0,this._y=Math.atan2(a,d));break;case"XZY":this._z=Math.asin(-clamp(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(l,h),this._y=Math.atan2(a,n)):(this._x=Math.atan2(-u,d),this._y=0);break;default:console.warn("../math.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,!0===i&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return v.makeRotationFromQuaternion(t),this.setFromRotationMatrix(v,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return g.setFromEuler(this),this.setFromQuaternion(g,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],void 0!==t[3]&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(t){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Euler.DEFAULT_ORDER="XYZ";class Vector2{constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new Vector2(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===e)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(clamp(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,s=this.y-t.y;return this.x=n*i-s*r+t.x,this.y=n*r+s*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}Vector2.isVector2=!0;class Vector4{constructor(t=0,e=0,i=0,r=1){Vector4.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=r}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,r){return this.x=t,this.y=e,this.z=i,this.w=r,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(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:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new Vector4(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(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}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(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}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,r=this.z,n=this.w,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r+s[12]*n,this.y=s[1]*e+s[5]*i+s[9]*r+s[13]*n,this.z=s[2]*e+s[6]*i+s[10]*r+s[14]*n,this.w=s[3]*e+s[7]*i+s[11]*r+s[15]*n,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,r,n;const s=.01,a=.1,o=t.elements,h=o[0],u=o[4],c=o[8],l=o[1],d=o[5],p=o[9],m=o[2],f=o[6],y=o[10];if(Math.abs(u-l)o&&t>v?tv?o0?Math.floor(e/i)*i:e,t){case S.Loop:n%=1;break;case S.PingPong:n=Math.abs(n%2-1)}return n}!function(t){t[t.Random=0]="Random",t[t.Loop=1]="Loop",t[t.PingPong=2]="PingPong",t[t.Burst=3]="Burst"}(S||(S={}));class Bezier{constructor(t,e,i,r){this.p=[t,e,i,r]}genValue(t){const e=t*t,i=t*t*t,r=1-t,n=r*r,s=n*r;return this.p[0]*s+this.p[1]*n*t*3+this.p[2]*r*e*3+this.p[3]*i}derivativeCoefficients(t){const e=[];for(let i=t,r=i.length-1;r>0;r--){const t=[];for(let e=0;e1;){for(r=[],s=0,a=i.length-1;s({r:t.x,g:t.y,b:t.z,a:t.w}),JSONToColor=t=>new Vector4(t.r,t.g,t.b,t.a),JSONToValue=(t,e)=>{switch(e){case"Vector3":return new Vector3(t.x,t.y,t.z);case"Vector4":return new Vector4(t.x,t.y,t.z,t.w);case"Color":return new Vector3(t.r,t.g,t.b);default:return t}},ValueToJSON=(t,e)=>{switch(e){case"Vector3":return{x:t.x,y:t.y,z:t.z};case"Vector4":return{x:t.x,y:t.y,z:t.z,w:t.w};case"Color":return{r:t.x,g:t.y,b:t.z};default:return t}};class RandomColor{constructor(t,e){this.a=t,this.b=e,this.type="value"}startGen(t){}genColor(t,e){const i=Math.random();return e.copy(this.a).lerp(this.b,i)}toJSON(){return{type:"RandomColor",a:ColorToJSON(this.a),b:ColorToJSON(this.b)}}static fromJSON(t){return new RandomColor(JSONToColor(t.a),JSONToColor(t.b))}clone(){return new RandomColor(this.a.clone(),this.b.clone())}}class ColorRange{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e){return-1===this.indexCount&&this.startGen(t),e.copy(this.a).lerp(this.b,t[this.indexCount])}toJSON(){return{type:"ColorRange",a:ColorToJSON(this.a),b:ColorToJSON(this.b)}}static fromJSON(t){return new ColorRange(JSONToColor(t.a),JSONToColor(t.b))}clone(){return new ColorRange(this.a.clone(),this.b.clone())}}class ContinuousLinearFunction{constructor(t,e){this.subType=e,this.type="function",this.keys=t}findKey(t){let e=0,i=0,r=this.keys.length-1;for(;i+1this.getEndX(e)))return e;i=e+1}for(let e=i;e<=r;e++)if(t>=this.getStartX(e)&&t<=this.getEndX(e))return e;return-1}getStartX(t){return this.keys[t][1]}getEndX(t){return t+1=this.keys.length?this.keys[this.keys.length-1][0]:(this.keys[i+1][0]-this.keys[i][0])*((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))+this.keys[i][0]:-1===i?t.copy(this.keys[0][0]):i+1>=this.keys.length?t.copy(this.keys[this.keys.length-1][0]):t.copy(this.keys[i][0]).lerp(this.keys[i+1][0],(e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toJSON(){return this.keys[0][0].constructor.name,{type:"CLinearFunction",subType:this.subType,keys:this.keys.map((([t,e])=>({value:ValueToJSON(t,this.subType),pos:e})))}}static fromJSON(t){return new ContinuousLinearFunction(t.keys.map((e=>[JSONToValue(e.value,t.subType),e.pos])),t.subType)}clone(){return"Number"===this.subType?new ContinuousLinearFunction(this.keys.map((([t,e])=>[t,e])),this.subType):new ContinuousLinearFunction(this.keys.map((([t,e])=>[t.clone(),e])),this.subType)}}const M=new Vector3;class Gradient{constructor(t=[[new Vector3(0,0,0),0],[new Vector3(1,1,1),0]],e=[[1,0],[1,1]]){this.type="function",this.color=new ContinuousLinearFunction(t,"Color"),this.alpha=new ContinuousLinearFunction(e,"Number")}genColor(t,e,i){return this.color.genValue(M,i),e.set(M.x,M.y,M.z,this.alpha.genValue(1,i))}toJSON(){return{type:"Gradient",color:this.color.toJSON(),alpha:this.alpha.toJSON()}}static fromJSON(t){if(t.functions){const e=t.functions.map((t=>[ColorRange.fromJSON(t.function).a,t.start]));return t.functions.length>0&&e.push([ColorRange.fromJSON(t.functions[t.functions.length-1].function).b,1]),new Gradient(e.map((t=>[new Vector3(t[0].x,t[0].y,t[0].z),t[1]])),e.map((t=>[t[0].w,t[1]])))}{const e=new Gradient;return e.alpha=ContinuousLinearFunction.fromJSON(t.alpha),e.color=ContinuousLinearFunction.fromJSON(t.color),e}}clone(){const t=new Gradient;return t.alpha=this.alpha.clone(),t.color=this.color.clone(),t}startGen(t){}}const _=new Vector4;class RandomColorBetweenGradient{constructor(t,e){this.indexCount=0,this.type="function",this.gradient1=t,this.gradient2=e}startGen(t){this.indexCount=t.length,t.push(Math.random())}genColor(t,e,i){return this.gradient1.genColor(t,e,i),this.gradient2.genColor(t,_,i),t&&void 0!==t[this.indexCount]?e.lerp(_,t[this.indexCount]):e.lerp(_,Math.random()),e}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(t){return new RandomColorBetweenGradient(Gradient.fromJSON(t.gradient1),Gradient.fromJSON(t.gradient2))}clone(){return new RandomColorBetweenGradient(this.gradient1.clone(),this.gradient2.clone())}}class ConstantColor{constructor(t){this.color=t,this.type="value"}startGen(t){}genColor(t,e){return e.copy(this.color)}toJSON(){return{type:"ConstantColor",color:ColorToJSON(this.color)}}static fromJSON(t){return new ConstantColor(JSONToColor(t.color))}clone(){return new ConstantColor(this.color.clone())}}function ColorGeneratorFromJSON(t){switch(t.type){case"ConstantColor":return ConstantColor.fromJSON(t);case"ColorRange":return ColorRange.fromJSON(t);case"RandomColor":return RandomColor.fromJSON(t);case"Gradient":return Gradient.fromJSON(t);case"RandomColorBetweenGradient":return RandomColorBetweenGradient.fromJSON(t);default:return new ConstantColor(new Vector4(1,1,1,1))}}class ConstantValue{constructor(t){this.value=t,this.type="value"}startGen(t){}genValue(t){return this.value}toJSON(){return{type:"ConstantValue",value:this.value}}static fromJSON(t){return new ConstantValue(t.value)}clone(){return new ConstantValue(this.value)}}class IntervalValue{constructor(t,e){this.a=t,this.b=e,this.indexCount=-1,this.type="value"}startGen(t){this.indexCount=t.length,t.push(Math.random())}genValue(t){return-1===this.indexCount&&this.startGen(t),a.lerp(this.a,this.b,t[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(t){return new IntervalValue(t.a,t.b)}clone(){return new IntervalValue(this.a,this.b)}}class PiecewiseFunction{constructor(){this.functions=new Array}findFunction(t){let e=0,i=0,r=this.functions.length-1;for(;i+1this.getEndX(e)))return e;i=e+1}for(let e=i;e<=r;e++)if(t>=this.functions[e][1]&&t<=this.getEndX(e))return e;return-1}getStartX(t){return this.functions[t][1]}setStartX(t,e){t>0&&(this.functions[t][1]=e)}getEndX(t){return t+1({function:t.toJSON(),start:e})))}}static fromJSON(t){return new PiecewiseBezier(t.functions.map((t=>[Bezier.fromJSON(t.function),t.start])))}clone(){return new PiecewiseBezier(this.functions.map((([t,e])=>[t.clone(),e])))}startGen(t){}}function ValueGeneratorFromJSON(t){switch(t.type){case"ConstantValue":return ConstantValue.fromJSON(t);case"IntervalValue":return IntervalValue.fromJSON(t);case"PiecewiseBezier":return PiecewiseBezier.fromJSON(t);default:return new ConstantValue(0)}}class RandomQuatGenerator{constructor(){this.indexCount=0,this.type="rotation"}startGen(t){let e,i,r,n,s,a;this.indexCount=t.length,t.push(new Quaternion);do{e=2*Math.random()-1,i=2*Math.random()-1,r=e*e+i*i}while(r>1);do{n=2*Math.random()-1,s=2*Math.random()-1,a=n*n+s*s}while(a>1);const o=Math.sqrt((1-r)/a);t[this.indexCount].set(e,i,o*n,o*s)}genValue(t,e,i,r){return-1===this.indexCount&&this.startGen(t),e.copy(t[this.indexCount]),e}toJSON(){return{type:"RandomQuat"}}static fromJSON(t){return new RandomQuatGenerator}clone(){return new RandomQuatGenerator}}class AxisAngleGenerator{constructor(t,e){this.axis=t,this.angle=e,this.type="rotation"}startGen(t){this.angle.startGen(t)}genValue(t,e,i,r){return e.setFromAxisAngle(this.axis,this.angle.genValue(t,r)*i)}toJSON(){return{type:"AxisAngle",axis:{x:this.axis.x,y:this.axis.y,z:this.axis.z},angle:this.angle.toJSON()}}static fromJSON(t){return new AxisAngleGenerator(new Vector3(t.axis.x,t.axis.y,t.axis.z),ValueGeneratorFromJSON(t.angle))}clone(){return new AxisAngleGenerator(this.axis.clone(),this.angle.clone())}}class EulerGenerator{constructor(t,e,i,r){this.angleX=t,this.angleY=e,this.angleZ=i,this.type="rotation",this.eular=new Euler(0,0,0,r)}startGen(t){this.angleX.startGen(t),this.angleY.startGen(t),this.angleZ.startGen(t)}genValue(t,e,i,r){return this.eular.set(this.angleX.genValue(t,r)*i,this.angleY.genValue(t,r)*i,this.angleZ.genValue(t,r)*i),e.setFromEuler(this.eular)}toJSON(){return{type:"Euler",angleX:this.angleX.toJSON(),angleY:this.angleY.toJSON(),angleZ:this.angleZ.toJSON(),eulerOrder:this.eular.order}}static fromJSON(t){return new EulerGenerator(ValueGeneratorFromJSON(t.angleX),ValueGeneratorFromJSON(t.angleY),ValueGeneratorFromJSON(t.angleZ),t.eulerOrder)}clone(){return new EulerGenerator(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function RotationGeneratorFromJSON(t){switch(t.type){case"AxisAngle":return AxisAngleGenerator.fromJSON(t);case"Euler":return EulerGenerator.fromJSON(t);case"RandomQuat":return RandomQuatGenerator.fromJSON(t);default:return new RandomQuatGenerator}}class Vector3Function{constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="vec3function"}startGen(t){this.x.startGen(t),this.y.startGen(t),this.z.startGen(t)}genValue(t,e,i){return e.set(this.x.genValue(t,i),this.y.genValue(t,i),this.z.genValue(t,i))}toJSON(){return{type:"Vector3Function",x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new Vector3Function(ValueGeneratorFromJSON(t.x),ValueGeneratorFromJSON(t.y),ValueGeneratorFromJSON(t.z))}clone(){return new Vector3Function(this.x,this.y,this.z)}}function GeneratorFromJSON(t){switch(t.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return ValueGeneratorFromJSON(t);case"AxisAngle":case"RandomQuat":case"Euler":return RotationGeneratorFromJSON(t);case"Vector3Function":return function Vector3GeneratorFromJSON(t){return"Vector3Function"===t.type?Vector3Function.fromJSON(t):new Vector3Function(new ConstantValue(0),new ConstantValue(0),new ConstantValue(0))}(t);default:return new ConstantValue(0)}}class ConeEmitter{constructor(t={}){var e,i,r,n,s,a,o;this.type="cone",this.currentValue=0,this.radius=null!==(e=t.radius)&&void 0!==e?e:10,this.arc=null!==(i=t.arc)&&void 0!==i?i:2*Math.PI,this.thickness=null!==(r=t.thickness)&&void 0!==r?r:1,this.angle=null!==(n=t.angle)&&void 0!==n?n:Math.PI/6,this.mode=null!==(s=t.mode)&&void 0!==s?s:S.Random,this.spread=null!==(a=t.spread)&&void 0!==a?a:0,this.speed=null!==(o=t.speed)&&void 0!==o?o:new ConstantValue(1),this.memory=[]}update(t,e){S.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,e),r=a.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,s=Math.sqrt(r),o=Math.sin(n),h=Math.cos(n);t.position.x=s*h,t.position.y=s*o,t.position.z=0;const u=this.angle*s;t.velocity.set(0,0,Math.cos(u)).addScaledVector(t.position,Math.sin(u)).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius)}toJSON(){return{type:"cone",radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new ConeEmitter({radius:t.radius,arc:t.arc,thickness:t.thickness,angle:t.angle,mode:t.mode,speed:t.speed?ValueGeneratorFromJSON(t.speed):void 0,spread:t.spread})}clone(){return new ConeEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class CircleEmitter{constructor(t={}){var e,i,r,n,s,a;this.type="circle",this.currentValue=0,this.radius=null!==(e=t.radius)&&void 0!==e?e:10,this.arc=null!==(i=t.arc)&&void 0!==i?i:2*Math.PI,this.thickness=null!==(r=t.thickness)&&void 0!==r?r:1,this.mode=null!==(n=t.mode)&&void 0!==n?n:S.Random,this.spread=null!==(s=t.spread)&&void 0!==s?s:0,this.speed=null!==(a=t.speed)&&void 0!==a?a:new ConstantValue(1),this.memory=[]}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,e),r=a.lerp(1-this.thickness,1,Math.random()),n=i*this.arc;t.position.x=Math.cos(n),t.position.y=Math.sin(n),t.position.z=0,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*r)}toJSON(){return{type:"circle",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new CircleEmitter({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?ValueGeneratorFromJSON(t.speed):void 0,spread:t.spread})}clone(){return new CircleEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class DonutEmitter{constructor(t={}){var e,i,r,n,s,a,o;this.type="donut",this.currentValue=0,this.radius=null!==(e=t.radius)&&void 0!==e?e:10,this.arc=null!==(i=t.arc)&&void 0!==i?i:2*Math.PI,this.thickness=null!==(r=t.thickness)&&void 0!==r?r:1,this.donutRadius=null!==(n=t.donutRadius)&&void 0!==n?n:.2*this.radius,this.mode=null!==(s=t.mode)&&void 0!==s?s:S.Random,this.spread=null!==(a=t.spread)&&void 0!==a?a:0,this.speed=null!==(o=t.speed)&&void 0!==o?o:new ConstantValue(1),this.memory=[]}update(t,e){S.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,e),r=Math.random(),n=a.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,o=r*Math.PI*2,h=Math.sin(s),u=Math.cos(s);t.position.x=this.radius*u,t.position.y=this.radius*h,t.position.z=0,t.velocity.z=this.donutRadius*n*Math.sin(o),t.velocity.x=this.donutRadius*n*Math.cos(o)*u,t.velocity.y=this.donutRadius*n*Math.cos(o)*h,t.position.add(t.velocity),t.velocity.normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"donut",radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new DonutEmitter({radius:t.radius,arc:t.arc,thickness:t.thickness,donutRadius:t.donutRadius,mode:t.mode,speed:t.speed?ValueGeneratorFromJSON(t.speed):void 0,spread:t.spread})}clone(){return new DonutEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class PointEmitter{constructor(){this.type="point"}update(t,e){}initialize(t){const e=Math.random(),i=Math.random(),r=e*Math.PI*2,n=Math.acos(2*i-1),s=Math.cbrt(Math.random()),a=Math.sin(r),o=Math.cos(r),h=Math.sin(n),u=Math.cos(n);t.velocity.x=s*h*o,t.velocity.y=s*h*a,t.velocity.z=s*u,t.velocity.multiplyScalar(t.startSpeed),t.position.setScalar(0)}toJSON(){return{type:"point"}}static fromJSON(t){return new PointEmitter}clone(){return new PointEmitter}}class SphereEmitter{constructor(t={}){var e,i,r,n,s,a;this.type="sphere",this.currentValue=0,this.radius=null!==(e=t.radius)&&void 0!==e?e:10,this.arc=null!==(i=t.arc)&&void 0!==i?i:2*Math.PI,this.thickness=null!==(r=t.thickness)&&void 0!==r?r:1,this.mode=null!==(n=t.mode)&&void 0!==n?n:S.Random,this.spread=null!==(s=t.spread)&&void 0!==s?s:0,this.speed=null!==(a=t.speed)&&void 0!==a?a:new ConstantValue(1),this.memory=[]}update(t,e){S.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,e),r=Math.random(),n=a.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,o=Math.acos(2*r-1),h=Math.sin(s),u=Math.cos(s),c=Math.sin(o),l=Math.cos(o);t.position.x=c*u,t.position.y=c*h,t.position.z=l,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*n)}toJSON(){return{type:"sphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new SphereEmitter({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?ValueGeneratorFromJSON(t.speed):void 0,spread:t.spread})}clone(){return new SphereEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class HemisphereEmitter{constructor(t={}){var e,i,r,n,s,a;this.type="sphere",this.currentValue=0,this.radius=null!==(e=t.radius)&&void 0!==e?e:10,this.arc=null!==(i=t.arc)&&void 0!==i?i:2*Math.PI,this.thickness=null!==(r=t.thickness)&&void 0!==r?r:1,this.mode=null!==(n=t.mode)&&void 0!==n?n:S.Random,this.spread=null!==(s=t.spread)&&void 0!==s?s:0,this.speed=null!==(a=t.speed)&&void 0!==a?a:new ConstantValue(1),this.memory=[]}update(t,e){S.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=getValueFromEmitterMode(this.mode,this.currentValue,this.spread,e),r=Math.random(),n=a.lerp(1-this.thickness,1,Math.random()),s=i*this.arc,o=Math.acos(r),h=Math.sin(s),u=Math.cos(s),c=Math.sin(o),l=Math.cos(o);t.position.x=c*u,t.position.y=c*h,t.position.z=l,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*n)}toJSON(){return{type:"hemisphere",radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new HemisphereEmitter({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?ValueGeneratorFromJSON(t.speed):void 0,spread:t.spread})}clone(){return new HemisphereEmitter({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class GridEmitter{constructor(t={}){var e,i,r,n;this.type="grid",this.width=null!==(e=t.width)&&void 0!==e?e:1,this.height=null!==(i=t.height)&&void 0!==i?i:1,this.column=null!==(r=t.column)&&void 0!==r?r:10,this.row=null!==(n=t.row)&&void 0!==n?n:10}initialize(t){const e=Math.floor(Math.random()*this.row),i=Math.floor(Math.random()*this.column);t.position.x=i*this.width/this.column-this.width/2,t.position.y=e*this.height/this.row-this.height/2,t.position.z=0,t.velocity.set(0,0,t.startSpeed)}toJSON(){return{type:"grid",width:this.width,height:this.height,column:this.column,row:this.row}}static fromJSON(t){return new GridEmitter(t)}clone(){return new GridEmitter({width:this.width,height:this.height,column:this.column,row:this.row})}update(t,e){}}const w={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:CircleEmitter,loadJSON:CircleEmitter.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:ConeEmitter,loadJSON:ConeEmitter.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:DonutEmitter,loadJSON:DonutEmitter.fromJSON},point:{type:"point",params:[],constructor:PointEmitter,loadJSON:PointEmitter.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:SphereEmitter,loadJSON:SphereEmitter.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc"]]],constructor:HemisphereEmitter,loadJSON:HemisphereEmitter.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:GridEmitter,loadJSON:GridEmitter.fromJSON}};class ColorOverLife{constructor(t){this.color=t,this.type="ColorOverLife"}initialize(t){this.color.startGen(t.memory)}update(t,e){this.color.genColor(t.memory,t.color,t.age/t.life),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON()}}static fromJSON(t){return new ColorOverLife(ColorGeneratorFromJSON(t.color))}clone(){return new ColorOverLife(this.color.clone())}reset(){}}class RotationOverLife{constructor(t){this.angularVelocity=t,this.type="RotationOverLife"}initialize(t){"number"==typeof t.rotation&&this.angularVelocity.startGen(t.memory)}update(t,e){"number"==typeof t.rotation&&(t.rotation+=e*this.angularVelocity.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new RotationOverLife(ValueGeneratorFromJSON(t.angularVelocity))}frameUpdate(t){}clone(){return new RotationOverLife(this.angularVelocity.clone())}reset(){}}class Rotation3DOverLife{constructor(t){this.angularVelocity=t,this.type="Rotation3DOverLife",this.tempQuat=new Quaternion,this.tempQuat2=new Quaternion}initialize(t){t.rotation instanceof Quaternion&&(t.angularVelocity=new Quaternion,this.angularVelocity.startGen(t.memory))}update(t,e){t.rotation instanceof Quaternion&&(this.angularVelocity.genValue(t.memory,this.tempQuat,e,t.age/t.life),t.rotation.multiply(this.tempQuat))}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON()}}static fromJSON(t){return new Rotation3DOverLife(RotationGeneratorFromJSON(t.angularVelocity))}frameUpdate(t){}clone(){return new Rotation3DOverLife(this.angularVelocity.clone())}reset(){}}class ForceOverLife{initialize(t,e){this.ps=e,this.x.startGen(t.memory),this.y.startGen(t.memory),this.z.startGen(t.memory)}constructor(t,e,i){this.x=t,this.y=e,this.z=i,this.type="ForceOverLife",this._temp=new Vector3,this._tempScale=new Vector3,this._tempQ=new Quaternion}update(t,e){this._temp.set(this.x.genValue(t.memory,t.age/t.life),this.y.genValue(t.memory,t.age/t.life),this.z.genValue(t.memory,t.age/t.life)),this.ps.worldSpace||this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ),t.velocity.addScaledVector(this._temp,e)}toJSON(){return{type:this.type,x:this.x.toJSON(),y:this.y.toJSON(),z:this.z.toJSON()}}static fromJSON(t){return new ForceOverLife(ValueGeneratorFromJSON(t.x),ValueGeneratorFromJSON(t.y),ValueGeneratorFromJSON(t.z))}frameUpdate(t){if(this.ps&&!this.ps.worldSpace){const t=this._temp,e=this._tempQ,i=this._tempScale;this.ps.emitter.matrixWorld.decompose(t,e,i),e.invert(),i.set(1/i.x,1/i.y,1/i.z)}}clone(){return new ForceOverLife(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}class SizeOverLife{initialize(t){this.size.startGen(t.memory)}constructor(t){this.size=t,this.type="SizeOverLife"}update(t){this.size instanceof Vector3Function?this.size.genValue(t.memory,t.size,t.age/t.life).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,t.age/t.life))}toJSON(){return{type:this.type,size:this.size.toJSON()}}static fromJSON(t){return new SizeOverLife(GeneratorFromJSON(t.size))}frameUpdate(t){}clone(){return new SizeOverLife(this.size.clone())}reset(){}}class SpeedOverLife{initialize(t){this.speed.startGen(t.memory)}constructor(t){this.speed=t,this.type="SpeedOverLife"}update(t){t.speedModifier=this.speed.genValue(t.memory,t.age/t.life)}toJSON(){return{type:this.type,speed:this.speed.toJSON()}}static fromJSON(t){return new SpeedOverLife(ValueGeneratorFromJSON(t.speed))}frameUpdate(t){}clone(){return new SpeedOverLife(this.speed.clone())}reset(){}}class FrameOverLife{constructor(t){this.frame=t,this.type="FrameOverLife"}initialize(t){this.frame.startGen(t.memory)}update(t,e){this.frame instanceof PiecewiseBezier&&(t.uvTile=this.frame.genValue(t.memory,t.age/t.life))}frameUpdate(t){}toJSON(){return{type:this.type,frame:this.frame.toJSON()}}static fromJSON(t){return new FrameOverLife(ValueGeneratorFromJSON(t.frame))}clone(){return new FrameOverLife(this.frame.clone())}reset(){}}new Vector3(0,0,1);class OrbitOverLife{constructor(t,e=new Vector3(0,1,0)){this.orbitSpeed=t,this.axis=e,this.type="OrbitOverLife",this.temp=new Vector3,this.rotation=new Quaternion}initialize(t){this.orbitSpeed.startGen(t.memory)}update(t,e){this.temp.copy(t.position).projectOnVector(this.axis),this.rotation.setFromAxisAngle(this.axis,this.orbitSpeed.genValue(t.memory,t.age/t.life)*e),t.position.sub(this.temp),t.position.applyQuaternion(this.rotation),t.position.add(this.temp)}frameUpdate(t){}toJSON(){return{type:this.type,orbitSpeed:this.orbitSpeed.toJSON(),axis:[this.axis.x,this.axis.y,this.axis.z]}}static fromJSON(t){return new OrbitOverLife(ValueGeneratorFromJSON(t.orbitSpeed),t.axis?new Vector3(t.axis[0],t.axis[1],t.axis[2]):void 0)}clone(){return new OrbitOverLife(this.orbitSpeed.clone())}reset(){}}class LinkedListNode{constructor(t){this.data=t,this.next=null,this.prev=null}hasPrev(){return null!==this.prev}hasNext(){return null!==this.next}}class LinkedList{constructor(){this.length=0,this.head=this.tail=null}isEmpty(){return null===this.head}clear(){this.length=0,this.head=this.tail=null}front(){return null===this.head?null:this.head.data}back(){return null===this.tail?null:this.tail.data}dequeue(){if(this.head){const t=this.head.data;return this.head=this.head.next,this.head?this.head.prev=null:this.tail=null,this.length--,t}}pop(){if(this.tail){const t=this.tail.data;return this.tail=this.tail.prev,this.tail?this.tail.next=null:this.head=null,this.length--,t}}queue(t){const e=new LinkedListNode(t);this.tail||(this.tail=e),this.head&&(this.head.prev=e,e.next=this.head),this.head=e,this.length++}push(t){const e=new LinkedListNode(t);this.head||(this.head=e),this.tail&&(this.tail.next=e,e.prev=this.tail),this.tail=e,this.length++}insertBefore(t,e){const i=new LinkedListNode(e);i.next=t,i.prev=t.prev,null!==i.prev&&(i.prev.next=i),i.next.prev=i,t==this.head&&(this.head=i),this.length++}remove(t){if(null===this.head||null===this.tail)return;let e=this.head;for(t===this.head.data&&(this.head=this.head.next),t===this.tail.data&&(this.tail=this.tail.prev);null!==e.next&&e.data!==t;)e=e.next;e.data===t&&(null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.length--)}*values(){let t=this.head;for(;null!==t;)yield t.data,t=t.next}}class NodeParticle{constructor(){this.position=new Vector3,this.velocity=new Vector3,this.age=0,this.life=1,this.size=new Vector3,this.rotation=0,this.color=new Vector4(1,1,1,1),this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.position.set(0,0,0),this.velocity.set(0,0,0),this.age=0,this.life=1,this.size.set(1,1,1),this.rotation=0,this.color.set(1,1,1,1),this.uvTile=0}}class RecordState{constructor(t,e,i){this.position=t,this.size=e,this.color=i}}class TrailParticle{constructor(){this.startSpeed=0,this.startColor=new Vector4,this.startSize=new Vector3(1,1,1),this.position=new Vector3,this.velocity=new Vector3,this.age=0,this.life=1,this.size=new Vector3(1,1,1),this.length=100,this.speedModifier=1,this.color=new Vector4,this.previous=new LinkedList,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new RecordState(this.position.clone(),this.size.x,this.color.clone())):this.previous.length>0&&this.previous.dequeue();this.previous.length>this.length;)this.previous.dequeue()}get died(){return this.age>=this.life}reset(){this.memory.length=0,this.previous.clear()}}class WidthOverLength{initialize(t){this.width.startGen(t.memory)}constructor(t){this.width=t,this.type="WidthOverLength"}update(t){if(t instanceof TrailParticle){const e=t.previous.values();for(let i=0;i=t.life)&&this.emit(t,e)}emit(t,e){if(!this.subParticleSystem)return;if(Math.random()>this.emitProbability)return;const i=new Matrix4;this.setMatrixFromParticle(i,t),this.subEmissions.push({burstParticleCount:0,burstParticleIndex:0,isBursting:!1,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,matrix:i,travelDistance:0,particle:t})}frameUpdate(t){if(this.subParticleSystem)for(let e=0;e=this.subParticleSystem.system.duration)this.subEmissions[e]=this.subEmissions[this.subEmissions.length-1],this.subEmissions.length=this.subEmissions.length-1,e--;else{const i=this.subEmissions[e];i.particle&&i.particle.age>>0,r-=t,r*=t,t=r>>>0,r-=t,t+=4294967296*r}return 2.3283064365386963e-10*(t>>>0)}}();return e=s(" "),i=s(" "),r=s(" "),e-=s(t),e<0&&(e+=1),i-=s(t),i<0&&(i+=1),r-=s(t),r<0&&(r+=1),function(){const t=2091639*e+2.3283064365386963e-10*n;return e=i,i=r,r=t-(n=0|t)}}(t);this.p=function buildPermutationTable(t){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let i=0;i<255;i++){const r=i+~~(t()*(256-i)),n=e[i];e[i]=e[r],e[r]=n}return e}(e),this.perm=new Uint8Array(512),this.permMod12=new Uint8Array(512);for(let t=0;t<512;t++)this.perm[t]=this.p[255&t],this.permMod12[t]=this.perm[t]%12}noise2D(t,e){const i=this.permMod12,r=this.perm;let n=0,s=0,a=0;const o=(t+e)*V,h=Math.floor(t+o),u=Math.floor(e+o),c=(h+u)*z,l=t-(h-c),d=e-(u-c);let p,m;l>d?(p=1,m=0):(p=0,m=1);const f=l-p+z,y=d-m+z,v=l-1+2*z,g=d-1+2*z,x=255&h,S=255&u;let M=.5-l*l-d*d;if(M>=0){const t=3*i[x+r[S]];M*=M,n=M*M*(A[t]*l+A[t+1]*d)}let _=.5-f*f-y*y;if(_>=0){const t=3*i[x+p+r[S+m]];_*=_,s=_*_*(A[t]*f+A[t+1]*y)}let w=.5-v*v-g*g;if(w>=0){const t=3*i[x+1+r[S+1]];w*=w,a=w*w*(A[t]*v+A[t+1]*g)}return 70*(n+s+a)}noise3D(t,e,i){const r=this.permMod12,n=this.perm;let s,a,o,h;const u=(t+e+i)*P,c=Math.floor(t+u),l=Math.floor(e+u),d=Math.floor(i+u),p=(c+l+d)*E,m=t-(c-p),f=e-(l-p),y=i-(d-p);let v,g,x,S,M,_;m>=f?f>=y?(v=1,g=0,x=0,S=1,M=1,_=0):m>=y?(v=1,g=0,x=0,S=1,M=0,_=1):(v=0,g=0,x=1,S=1,M=0,_=1):fv?S++:M++,y>g?S++:_++,y>x?S++:w++,v>g?M++:_++,v>x?M++:w++,g>x?_++:w++;const b=S>=3?1:0,N=M>=3?1:0,O=_>=3?1:0,V=w>=3?1:0,z=S>=2?1:0,P=M>=2?1:0,E=_>=2?1:0,A=w>=2?1:0,I=S>=1?1:0,k=M>=1?1:0,R=_>=1?1:0,F=w>=1?1:0,L=y-b+T,B=v-N+T,G=g-O+T,J=x-V+T,D=y-z+2*T,q=v-P+2*T,W=g-E+2*T,j=x-A+2*T,Q=y-I+3*T,X=v-k+3*T,Y=g-R+3*T,H=x-F+3*T,Z=y-1+4*T,K=v-1+4*T,$=g-1+4*T,tt=x-1+4*T,et=255&l,it=255&d,rt=255&p,nt=255&m;let st=.6-y*y-v*v-g*g-x*x;if(st<0)s=0;else{const t=n[et+n[it+n[rt+n[nt]]]]%32*4;st*=st,s=st*st*(U[t]*y+U[t+1]*v+U[t+2]*g+U[t+3]*x)}let at=.6-L*L-B*B-G*G-J*J;if(at<0)a=0;else{const t=n[et+b+n[it+N+n[rt+O+n[nt+V]]]]%32*4;at*=at,a=at*at*(U[t]*L+U[t+1]*B+U[t+2]*G+U[t+3]*J)}let ot=.6-D*D-q*q-W*W-j*j;if(ot<0)o=0;else{const t=n[et+z+n[it+P+n[rt+E+n[nt+A]]]]%32*4;ot*=ot,o=ot*ot*(U[t]*D+U[t+1]*q+U[t+2]*W+U[t+3]*j)}let ht=.6-Q*Q-X*X-Y*Y-H*H;if(ht<0)h=0;else{const t=n[et+I+n[it+k+n[rt+R+n[nt+F]]]]%32*4;ht*=ht,h=ht*ht*(U[t]*Q+U[t+1]*X+U[t+2]*Y+U[t+3]*H)}let ut=.6-Z*Z-K*K-$*$-tt*tt;if(ut<0)u=0;else{const t=n[et+1+n[it+1+n[rt+1+n[nt+1]]]]%32*4;ut*=ut,u=ut*ut*(U[t]*Z+U[t+1]*K+U[t+2]*$+U[t+3]*tt)}return 27*(s+a+o+h+u)}}class TurbulenceField{constructor(t,e,i,r){this.scale=t,this.octaves=e,this.velocityMultiplier=i,this.timeScale=r,this.type="TurbulenceField",this.generator=new SimplexNoise,this.timeOffset=new Vector3,this.temp=new Vector3,this.temp2=new Vector3,this.timeOffset.x=Math.random()/this.scale.x*this.timeScale.x,this.timeOffset.y=Math.random()/this.scale.y*this.timeScale.y,this.timeOffset.z=Math.random()/this.scale.z*this.timeScale.z}initialize(t){}update(t,e){const i=t.position.x/this.scale.x,r=t.position.y/this.scale.y,n=t.position.z/this.scale.z;this.temp.set(0,0,0);let s=1;for(let t=0;t0&&void 0!==t.lastPosNoise&&(t.position.sub(t.lastPosNoise),k.set(I[t.generatorIndex[0]].noise2D(0,t.age*i)*r*n,I[t.generatorIndex[1]].noise2D(0,t.age*i)*r*n,I[t.generatorIndex[2]].noise2D(0,t.age*i)*r*n),t.position.add(k),t.lastPosNoise.copy(k)),s>0&&void 0!==t.lastRotNoise&&("number"==typeof t.rotation?(t.rotation-=t.lastRotNoise,t.rotation+=I[t.generatorIndex[3]].noise2D(0,t.age*i)*Math.PI*r*s):(t.lastRotNoise.invert(),t.rotation.multiply(t.lastRotNoise),R.set(I[t.generatorIndex[0]].noise2D(0,t.age*i)*r*s,I[t.generatorIndex[1]].noise2D(0,t.age*i)*r*s,I[t.generatorIndex[2]].noise2D(0,t.age*i)*r*s,I[t.generatorIndex[3]].noise2D(0,t.age*i)*r*s).normalize(),t.rotation.multiply(R),t.lastRotNoise.copy(R)))}toJSON(){return{type:this.type,frequency:this.frequency.toJSON(),power:this.power.toJSON(),positionAmount:this.positionAmount.toJSON(),rotationAmount:this.rotationAmount.toJSON()}}frameUpdate(t){this.duration+=t}static fromJSON(t){return new Noise(ValueGeneratorFromJSON(t.frequency),ValueGeneratorFromJSON(t.power),ValueGeneratorFromJSON(t.positionAmount),ValueGeneratorFromJSON(t.rotationAmount))}clone(){return new Noise(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class ColorBySpeed{constructor(t,e){this.color=t,this.speedRange=e,this.type="ColorBySpeed"}initialize(t){this.color.startGen(t.memory)}update(t,e){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.color.genColor(t.memory,t.color,i),t.color.x*=t.startColor.x,t.color.y*=t.startColor.y,t.color.z*=t.startColor.z,t.color.w*=t.startColor.w}frameUpdate(t){}toJSON(){return{type:this.type,color:this.color.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new ColorBySpeed(ColorGeneratorFromJSON(t.color),IntervalValue.fromJSON(t.speedRange))}clone(){return new ColorBySpeed(this.color.clone(),this.speedRange.clone())}reset(){}}class SizeBySpeed{initialize(t){this.size.startGen(t.memory)}constructor(t,e){this.size=t,this.speedRange=e,this.type="SizeBySpeed"}update(t){const e=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);this.size instanceof Vector3Function?this.size.genValue(t.memory,t.size,e).multiply(t.startSize):t.size.copy(t.startSize).multiplyScalar(this.size.genValue(t.memory,e))}toJSON(){return{type:this.type,size:this.size.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new SizeBySpeed(GeneratorFromJSON(t.size),IntervalValue.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new SizeBySpeed(this.size.clone(),this.speedRange.clone())}reset(){}}class RotationBySpeed{constructor(t,e){this.angularVelocity=t,this.speedRange=e,this.type="RotationBySpeed",this.tempQuat=new Quaternion}initialize(t){"number"==typeof t.rotation&&this.angularVelocity.startGen(t.memory)}update(t,e){if("number"==typeof t.rotation){const i=(t.startSpeed-this.speedRange.a)/(this.speedRange.b-this.speedRange.a);t.rotation+=e*this.angularVelocity.genValue(t.memory,i)}}toJSON(){return{type:this.type,angularVelocity:this.angularVelocity.toJSON(),speedRange:this.speedRange.toJSON()}}static fromJSON(t){return new RotationBySpeed(ValueGeneratorFromJSON(t.angularVelocity),IntervalValue.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new RotationBySpeed(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class LimitSpeedOverLife{initialize(t){this.speed.startGen(t.memory)}constructor(t,e){this.speed=t,this.dampen=e,this.type="LimitSpeedOverLife"}update(t,e){let i=t.velocity.length(),r=this.speed.genValue(t.memory,t.age/t.life);if(i>r){const n=(i-r)/i;t.velocity.multiplyScalar(1-n*this.dampen*e*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(t){return new LimitSpeedOverLife(ValueGeneratorFromJSON(t.speed),t.dampen)}frameUpdate(t){}clone(){return new LimitSpeedOverLife(this.speed.clone(),this.dampen)}reset(){}}const F={ApplyForce:{type:"ApplyForce",constructor:ApplyForce,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:ApplyForce.fromJSON},Noise:{type:"Noise",constructor:Noise,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Noise.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:TurbulenceField,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:TurbulenceField.fromJSON},GravityForce:{type:"GravityForce",constructor:GravityForce,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:GravityForce.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:ColorOverLife,params:[["color",["colorFunc"]]],loadJSON:ColorOverLife.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:RotationOverLife,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:RotationOverLife.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Rotation3DOverLife,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Rotation3DOverLife.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:SizeOverLife,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:SizeOverLife.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:ColorBySpeed,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:ColorBySpeed.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:RotationBySpeed,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:RotationBySpeed.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:SizeBySpeed,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:SizeBySpeed.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:SpeedOverLife,params:[["speed",["value","valueFunc"]]],loadJSON:SpeedOverLife.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:FrameOverLife,params:[["frame",["value","valueFunc"]]],loadJSON:FrameOverLife.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:ForceOverLife,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:ForceOverLife.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:OrbitOverLife,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:OrbitOverLife.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:WidthOverLength,params:[["width",["value","valueFunc"]]],loadJSON:WidthOverLength.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:ChangeEmitDirection,params:[["angle",["value"]]],loadJSON:ChangeEmitDirection.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:EmitSubParticleSystem,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:EmitSubParticleSystem.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:LimitSpeedOverLife,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:LimitSpeedOverLife.fromJSON}},L=[];var B=function(t){return t[t.Number=0]="Number",t[t.Vec2=1]="Vec2",t[t.Vec3=2]="Vec3",t[t.Vec4=3]="Vec4",t[t.Boolean=4]="Boolean",t[t.AnyType=5]="AnyType",t[t.NullableAnyType=6]="NullableAnyType",t[t.EventStream=7]="EventStream",t}({}),G=function getAlignOfNodeValueType(t){switch(t){case B.Boolean:case B.Number:return 4;case B.Vec2:return 8;case B.Vec3:case B.Vec4:return 16;case B.AnyType:case B.NullableAnyType:default:return 0}},J=function getSizeOfNodeValueType(t){switch(t){case B.Boolean:return 1;case B.Number:return 4;case B.Vec2:return 8;case B.Vec3:return 12;case B.Vec4:return 16;case B.AnyType:case B.NullableAnyType:default:return 0}},D=function genDefaultForNodeValueType(t){switch(t){case B.Boolean:return!1;case B.Number:return 0;case B.Vec2:return new Vector2;case B.Vec3:return new Vector3;case B.Vec4:return new Vector4;case B.AnyType:return 0;case B.NullableAnyType:return}},q=function(){return _createClass((function Node(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};_classCallCheck(this,Node),_defineProperty(this,"id",void 0),_defineProperty(this,"inputs",[]),_defineProperty(this,"outputs",[]),_defineProperty(this,"definition",void 0),_defineProperty(this,"signatureIndex",-1),_defineProperty(this,"data",void 0),_defineProperty(this,"position",new Vector2),_defineProperty(this,"outputValues",[]),this.id=""+Math.round(1e5*Math.random()),this.definition=t,this.signatureIndex=e,this.data=i;for(var r=-1===e?0:e,n=0;ni[1]})),K.greaterThan=St;var Mt=new H("lessThanOrEqual",Y.Expression);Mt.addSignature([B.Number,B.Number],[B.Boolean],(function(t,e,i,r){r[0]=i[0]<=i[1]})),K.lessThanOrEqual=Mt;var _t=new H("greaterThanOrEqual",Y.Expression);_t.addSignature([B.Number,B.Number],[B.Boolean],(function(t,e,i,r){r[0]=i[0]>=i[1]})),K.greaterThanOrEqual=_t;var wt=new H("if",Y.Expression);wt.addSignature([B.Boolean,B.AnyType,B.AnyType],[B.AnyType],(function(t,e,i,r){r[0]=i[0]?i[1]:i[2]})),K.if=wt;var bt=new H("number",Y.Expression);bt.addSignature([],[B.Number],(function(t,e,i,r){r[0]=e.value})),K.number=bt;var Nt=new H("vec2",Y.Expression);Nt.addSignature([B.Number,B.Number],[B.Vec2],(function(t,e,i,r){r[0].x=i[0],r[0].y=i[1]})),K.vec2=Nt;var Ot=new H("vec3",Y.Expression);Ot.addSignature([B.Number,B.Number,B.Number],[B.Vec3],(function(t,e,i,r){r[0].x=i[0],r[0].y=i[1],r[0].z=i[2]})),K.vec3=Ot;var Vt=new H("vec4",Y.Expression);Vt.addSignature([B.Number,B.Number,B.Number,B.Number],[B.Vec4],(function(t,e,i,r){r[0].x=i[0],r[0].y=i[1],r[0].z=i[2],r[0].w=i[3]})),K.vec4=Vt;var zt=new H("bool",Y.Expression);zt.addSignature([],[B.Boolean],(function(t,e,i,r){r[0]=e.value})),K.bool=zt;var Pt=new H("particleProperty",Y.Storage);Pt.addSignature([B.NullableAnyType],[B.NullableAnyType],(function(t,e,i,r){void 0!==i[0]&&(e.type!==B.Number?t.particle[e.property].copy(i[0]):t.particle[e.property]=i[0]),void 0!==t.particle[e.property]&&(e.type!==B.Number?r[0].copy(t.particle[e.property]):r[0]=t.particle[e.property])})),K.particleProperty=Pt;var Et=new H("emit",Y.Function);Et.addSignature([B.EventStream],[],(function(t,e,i,r){for(var n=i[0],s=0;s"ParticleSystemPreview"!==t.type));const r=super.toJSON(t);return this.children=i,null!==this.system&&(r.object.ps=this.system.toJSON(t,e)),r}}var Kt;!function(t){t[t.BillBoard=0]="BillBoard",t[t.StretchedBillBoard=1]="StretchedBillBoard",t[t.Mesh=2]="Mesh",t[t.Trail=3]="Trail",t[t.HorizontalBillBoard=4]="HorizontalBillBoard",t[t.VerticalBillBoard=5]="VerticalBillBoard"}(Kt||(Kt={})),new Vector3(0,0,1),new Vector3,new Vector3,new Vector3,new e.PlaneGeometry(1,1,1,1),new Vector3(0,0,1),new Vector3(0,0,1);class MeshSurfaceEmitter{get geometry(){return this._geometry}set geometry(t){if(this._geometry=t,void 0===t)return;if("string"==typeof t)return;const i=new e.Triangle;this._triangleIndexToArea.length=0;let r=0;if(!t.getIndex())return;const n=t.getIndex().array,s=n.length/3;this._triangleIndexToArea.push(0);for(let e=0;e1&&(a=1-a,o=1-o);const h=e.getIndex().array[3*r],u=e.getIndex().array[3*r+1],c=e.getIndex().array[3*r+2],l=e.getAttribute("position");this._tempA.fromBufferAttribute(l,h),this._tempB.fromBufferAttribute(l,u),this._tempC.fromBufferAttribute(l,c),this._tempB.sub(this._tempA),this._tempC.sub(this._tempA),this._tempA.addScaledVector(this._tempB,a).addScaledVector(this._tempC,o),t.position.copy(this._tempA),this._tempA.copy(this._tempB).cross(this._tempC).normalize(),t.velocity.copy(this._tempA).normalize().multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._geometry?this._geometry.uuid:""}}static fromJSON(t,e){return new MeshSurfaceEmitter(e.geometries[t.geometry])}clone(){return new MeshSurfaceEmitter(this._geometry)}update(t,e){}}!function loadPlugin(t){if(!L.find((e=>e.id===t.id))){t.initialize();for(const e of t.emitterShapes)w[e.type]||(w[e.type]=e);for(const e of t.behaviors)F[e.type]||(F[e.type]=e)}}({id:"three.quarks",initialize:()=>{},emitterShapes:[{type:"mesh_surface",params:[["geometry",["geometry"]]],constructor:MeshSurfaceEmitter,loadJSON:MeshSurfaceEmitter.fromJSON}],behaviors:[]}),function registerShaderChunks(){Zt.tile_pars_vertex="\n#ifdef UV_TILE\n attribute float uvTile;\n uniform vec2 tileCount;\n \n mat3 makeTileTransform(float uvTile) {\n float col = mod(uvTile, tileCount.x);\n float row = (tileCount.y - floor(uvTile / tileCount.x) - 1.0);\n \n return mat3(\n 1.0 / tileCount.x, 0.0, 0.0,\n 0.0, 1.0 / tileCount.y, 0.0, \n col / tileCount.x, row / tileCount.y, 1.0);\n }\n#else\n mat3 makeTileTransform(float uvTile) {\n return mat3(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0);\n }\n#endif\n\n#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\n\tvarying vec2 vUv;\n#ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n#endif\n\n#endif\n#ifdef USE_MAP\n\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#ifdef TILE_BLEND\n varying vec2 vMapUvNext;\n#endif\n\n#endif\n#ifdef USE_ALPHAMAP\n\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n\n#endif\n#ifdef USE_LIGHTMAP\n\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n\n#endif\n#ifdef USE_AOMAP\n\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n\n#endif\n#ifdef USE_BUMPMAP\n\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n\n#endif\n#ifdef USE_NORMALMAP\n\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n\n#endif\n#ifdef USE_EMISSIVEMAP\n\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n\n#endif\n#ifdef USE_METALNESSMAP\n\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n\n#endif\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n\n#endif\n#ifdef USE_ANISOTROPYMAP\n\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n\n#endif\n#ifdef USE_CLEARCOATMAP\n\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n\n#endif\n#ifdef USE_SPECULARMAP\n\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n\n#endif\n#ifdef USE_THICKNESSMAP\n\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n\n#endif\n",Zt.tile_vertex="\n#ifdef UV_TILE\n mat3 tileTransform = makeTileTransform(floor(uvTile));\n #ifdef TILE_BLEND\n mat3 nextTileTransform = makeTileTransform(ceil(uvTile));\n vUvBlend = fract(uvTile);\n #endif\n#else\n mat3 tileTransform = makeTileTransform(0.0);\n#endif\n\n#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\nvUv = (tileTransform *vec3( uv, 1 )).xy;\n#if defined( TILE_BLEND ) && defined( UV_TILE )\n vUvNext = (nextTileTransform *vec3( uv, 1 )).xy;\n#endif\n\n#endif\n#ifdef USE_MAP\n\nvMapUv = ( tileTransform * (mapTransform * vec3( MAP_UV, 1 ) )).xy;\n#if defined( TILE_BLEND ) && defined( UV_TILE )\n vMapUvNext = (nextTileTransform * (mapTransform * vec3( MAP_UV, 1 ))).xy;\n#endif\n\n#endif\n#ifdef USE_ALPHAMAP\n\nvAlphaMapUv = ( tileTransform * (alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) )).xy;\n \n#endif\n#ifdef USE_LIGHTMAP\n\nvLightMapUv = ( tileTransform * (lightMapTransform * vec3( LIGHTMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_AOMAP\n\nvAoMapUv = ( tileTransform * (aoMapTransform * vec3( AOMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_BUMPMAP\n\nvBumpMapUv = ( tileTransform * (bumpMapTransform * vec3( BUMPMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_NORMALMAP\n\nvNormalMapUv = ( tileTransform * (normalMapTransform * vec3( NORMALMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\nvDisplacementMapUv = ( tileTransform * (displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_EMISSIVEMAP\n\nvEmissiveMapUv = ( tileTransform * (emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_METALNESSMAP\n\nvMetalnessMapUv = ( tileTransform * (metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_ROUGHNESSMAP\n\nvRoughnessMapUv = ( tileTransform * (roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_ANISOTROPYMAP\n\nvAnisotropyMapUv = ( tileTransform * (anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_CLEARCOATMAP\n\nvClearcoatMapUv = ( tileTransform * (clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\nvClearcoatNormalMapUv = ( tileTransform * (clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\nvClearcoatRoughnessMapUv = ( tileTransform * (clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\nvIridescenceMapUv = ( tileTransform * (iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\nvIridescenceThicknessMapUv = ( tileTransform * (iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\nvSheenColorMapUv = ( tileTransform * (sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\nvSheenRoughnessMapUv = ( tileTransform * (sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SPECULARMAP\n\nvSpecularMapUv = ( tileTransform * (specularMapTransform * vec3( SPECULARMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\nvSpecularColorMapUv = ( tileTransform * (specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\nvSpecularIntensityMapUv = ( tileTransform * (specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\nvTransmissionMapUv = ( tileTransform * transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) )).xy;\n\n#endif\n#ifdef USE_THICKNESSMAP\n\nvThicknessMapUv = ( tileTransform * thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) )).xy;\n\n#endif\n\n",Zt.tile_pars_fragment="\n#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n\n\tvarying vec2 vUv;\n#ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n#endif\n\n#endif\n#ifdef USE_MAP\n\n\tuniform mat3 mapTransform;\n\tvarying vec2 vMapUv;\n#ifdef TILE_BLEND\n varying vec2 vMapUvNext;\n#endif\n\n#endif\n#ifdef USE_ALPHAMAP\n\n\tuniform mat3 alphaMapTransform;\n\tvarying vec2 vAlphaMapUv;\n\n#endif\n#ifdef USE_LIGHTMAP\n\n\tuniform mat3 lightMapTransform;\n\tvarying vec2 vLightMapUv;\n\n#endif\n#ifdef USE_AOMAP\n\n\tuniform mat3 aoMapTransform;\n\tvarying vec2 vAoMapUv;\n\n#endif\n#ifdef USE_BUMPMAP\n\n\tuniform mat3 bumpMapTransform;\n\tvarying vec2 vBumpMapUv;\n\n#endif\n#ifdef USE_NORMALMAP\n\n\tuniform mat3 normalMapTransform;\n\tvarying vec2 vNormalMapUv;\n\n#endif\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform mat3 displacementMapTransform;\n\tvarying vec2 vDisplacementMapUv;\n\n#endif\n#ifdef USE_EMISSIVEMAP\n\n\tuniform mat3 emissiveMapTransform;\n\tvarying vec2 vEmissiveMapUv;\n\n#endif\n#ifdef USE_METALNESSMAP\n\n\tuniform mat3 metalnessMapTransform;\n\tvarying vec2 vMetalnessMapUv;\n\n#endif\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform mat3 roughnessMapTransform;\n\tvarying vec2 vRoughnessMapUv;\n\n#endif\n#ifdef USE_ANISOTROPYMAP\n\n\tuniform mat3 anisotropyMapTransform;\n\tvarying vec2 vAnisotropyMapUv;\n\n#endif\n#ifdef USE_CLEARCOATMAP\n\n\tuniform mat3 clearcoatMapTransform;\n\tvarying vec2 vClearcoatMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform mat3 clearcoatNormalMapTransform;\n\tvarying vec2 vClearcoatNormalMapUv;\n\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform mat3 clearcoatRoughnessMapTransform;\n\tvarying vec2 vClearcoatRoughnessMapUv;\n\n#endif\n#ifdef USE_SHEEN_COLORMAP\n\n\tuniform mat3 sheenColorMapTransform;\n\tvarying vec2 vSheenColorMapUv;\n\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n\n\tuniform mat3 sheenRoughnessMapTransform;\n\tvarying vec2 vSheenRoughnessMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCEMAP\n\n\tuniform mat3 iridescenceMapTransform;\n\tvarying vec2 vIridescenceMapUv;\n\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n\n\tuniform mat3 iridescenceThicknessMapTransform;\n\tvarying vec2 vIridescenceThicknessMapUv;\n\n#endif\n#ifdef USE_SPECULARMAP\n\n\tuniform mat3 specularMapTransform;\n\tvarying vec2 vSpecularMapUv;\n\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n\n\tuniform mat3 specularColorMapTransform;\n\tvarying vec2 vSpecularColorMapUv;\n\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n\n\tuniform mat3 specularIntensityMapTransform;\n\tvarying vec2 vSpecularIntensityMapUv;\n\n#endif\n#ifdef USE_TRANSMISSIONMAP\n\n\tuniform mat3 transmissionMapTransform;\n\tvarying vec2 vTransmissionMapUv;\n\n#endif\n#ifdef USE_THICKNESSMAP\n\n\tuniform mat3 thicknessMapTransform;\n\tvarying vec2 vThicknessMapUv;\n\n#endif\n",Zt.tile_fragment="\n#ifdef USE_MAP\n vec4 texelColor = texture2D( map, vUv);\n #ifdef TILE_BLEND\n texelColor = mix( texelColor, texture2D( map, vUvNext ), vUvBlend );\n #endif\n diffuseColor *= texelColor;\n#endif\n",Zt.soft_pars_vertex="\n#ifdef SOFT_PARTICLES\n varying vec4 projPosition;\n varying float linearDepth;\n#endif\n",Zt.soft_vertex="\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n",Zt.soft_pars_fragment="\n#ifdef SOFT_PARTICLES\n\n uniform sampler2D depthTexture;\n uniform vec4 projParams;\n uniform vec2 softParams;\n\n varying vec4 projPosition;\n varying float linearDepth;\n\n #define SOFT_NEAR_FADE softParams.x\n #define SOFT_INV_FADE_DISTANCE softParams.y\n\n #define zNear projParams.x\n #define zFar projParams.y\n\n float linearize_depth(float d)\n {\n return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n\n#endif\n",Zt.soft_fragment="\n#ifdef SOFT_PARTICLES\n\n /* #ifdef LOGDEPTH\n float distSample = linearize_depth_log(sampleDepth, near, far);\n #else\n float distSample = ortho ? linearize_depth_ortho(sampleDepth, near, far) : linearize_depth(sampleDepth, near, far);\n #endif */\n\n vec2 p2 = projPosition.xy / projPosition.w;\n \n p2 = 0.5 * p2 + 0.5;\n\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float viewDepth = linearize_depth(readDepth);\n\n float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));\n \n gl_FragColor *= softParticlesFade;\n\n //gl_FragColor = vec4(softParticlesFade , 0, 0, 1);\n#endif\n"}(),console.log("%c Particle system powered by three.quarks. https://quarks.art/","font-size: 14px; font-weight: bold;"),new Vector3(0,0,1);var $t=new Quaternion,te=new Vector3,ee=new Vector3,ie=new e.PlaneGeometry(1,1,1,1),re=function(){return _createClass((function NodeVFX(t){var i,r,n,s,a,o,h;_classCallCheck(this,NodeVFX),_defineProperty(this,"emissionGraph",void 0),_defineProperty(this,"updateGraph",void 0),_defineProperty(this,"interpreter",void 0),_defineProperty(this,"autoDestroy",void 0),_defineProperty(this,"prewarm",void 0),_defineProperty(this,"looping",void 0),_defineProperty(this,"duration",void 0),_defineProperty(this,"particleNum",void 0),_defineProperty(this,"paused",void 0),_defineProperty(this,"particles",void 0),_defineProperty(this,"emitter",void 0),_defineProperty(this,"rendererSettings",void 0),_defineProperty(this,"neededToUpdateRender",void 0),_defineProperty(this,"rendererEmitterSettings",void 0),_defineProperty(this,"worldSpace",void 0),_defineProperty(this,"prewarmed",void 0),_defineProperty(this,"emissionState",void 0),_defineProperty(this,"emitEnded",void 0),_defineProperty(this,"markForDestroy",void 0),_defineProperty(this,"previousWorldPos",void 0),_defineProperty(this,"temp",new Vector3),_defineProperty(this,"travelDistance",0),_defineProperty(this,"normalMatrix",new Matrix3),_defineProperty(this,"_renderer",void 0),_defineProperty(this,"speedFactor",0),_defineProperty(this,"listeners",{}),this.autoDestroy=void 0!==t.autoDestroy&&t.autoDestroy,this.duration=null!==(i=t.duration)&&void 0!==i?i:1,this.looping=void 0===t.looping||t.looping,this.prewarm=void 0!==t.prewarm&&t.prewarm,this.worldSpace=null!==(r=t.worldSpace)&&void 0!==r&&r,this.rendererEmitterSettings=null!==(n=t.rendererEmitterSettings)&&void 0!==n?n:{},this.emissionGraph=t.emissionGraph,this.updateGraph=t.updateGraph,this.interpreter=new X,this.rendererSettings={instancingGeometry:null!==(s=t.instancingGeometry)&&void 0!==s?s:ie,renderMode:null!==(a=t.renderMode)&&void 0!==a?a:Kt.BillBoard,renderOrder:null!==(o=t.renderOrder)&&void 0!==o?o:0,material:t.material,layers:null!==(h=t.layers)&&void 0!==h?h:new e.Layers,uTileCount:1,vTileCount:1,blendTiles:!1,softParticles:!1,softNearFade:0,softFarFade:0},this.neededToUpdateRender=!0,this.particles=new Array,this.emitter=new ParticleEmitter(this),this.paused=!1,this.particleNum=0,this.emissionState={burstIndex:0,burstParticleCount:0,burstParticleIndex:0,burstWaveIndex:0,isBursting:!1,travelDistance:0,waitEmiting:0,time:0},this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}),[{key:"time",get:function get(){return this.emissionState.time},set:function set(t){this.emissionState.time=t}},{key:"layers",get:function get(){return this.rendererSettings.layers}},{key:"texture",get:function get(){return this.rendererSettings.material.map},set:function set(t){this.rendererSettings.material.map=t,this.neededToUpdateRender=!0}},{key:"material",get:function get(){return this.rendererSettings.material},set:function set(t){this.rendererSettings.material=t,this.neededToUpdateRender=!0}},{key:"instancingGeometry",get:function get(){return this.rendererSettings.instancingGeometry},set:function set(t){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=t,this.neededToUpdateRender=!0}},{key:"renderMode",get:function get(){return this.rendererSettings.renderMode},set:function set(t){if((this.rendererSettings.renderMode!=Kt.Trail&&t===Kt.Trail||this.rendererSettings.renderMode==Kt.Trail&&t!==Kt.Trail)&&(this.restart(),this.particles.length=0),this.rendererSettings.renderMode!==t)switch(t){case Kt.Trail:this.rendererEmitterSettings={startLength:30,followLocalOrigin:!1};break;case Kt.Mesh:this.rendererEmitterSettings={geometry:new e.PlaneGeometry(1,1)};break;case Kt.BillBoard:case Kt.VerticalBillBoard:case Kt.HorizontalBillBoard:case Kt.StretchedBillBoard:this.rendererEmitterSettings={}}this.rendererSettings.renderMode=t,this.neededToUpdateRender=!0}},{key:"renderOrder",get:function get(){return this.rendererSettings.renderOrder},set:function set(t){this.rendererSettings.renderOrder=t,this.neededToUpdateRender=!0}},{key:"blending",get:function get(){return this.rendererSettings.material.blending},set:function set(t){this.rendererSettings.material.blending=t,this.neededToUpdateRender=!0}},{key:"stop",value:function stop(){this.restart(),this.pause()}},{key:"pause",value:function pause(){this.paused=!0}},{key:"play",value:function play(){this.paused=!1}},{key:"spawn",value:function spawn(t,e){$t.setFromRotationMatrix(e);var i=te,r=$t,n=ee;for(e.decompose(i,r,n),this.particleNum++;this.particles.length.1&&(t=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1),this.emit(t,this.emissionState,e.matrixWorld);for(var n={particle:void 0,emissionState:this.emissionState,delta:t},s=0;sthis.duration&&(this.looping?e.time-=this.duration:this.emitEnded||this.endEmit()),this.normalMatrix.getNormalMatrix(i);var n={signal:function signal(){r.spawn(e,i)},emissionState:e,delta:t};this.emitEnded||this.interpreter.run(this.emissionGraph,n),void 0===this.previousWorldPos&&(this.previousWorldPos=new Vector3),this.emitter.getWorldPosition(this.previousWorldPos),e.time+=t}},{key:"toJSON",value:function toJSON(t){return{}}},{key:"getRendererSettings",value:function getRendererSettings(){return this.rendererSettings}},{key:"clone",value:function clone(){return this}},{key:"addEventListener",value:function addEventListener(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}},{key:"removeAllEventListeners",value:function removeAllEventListeners(t){this.listeners[t]&&(this.listeners[t]=[])}},{key:"removeEventListener",value:function removeEventListener(t,e){if(this.listeners[t]){var i=this.listeners[t].indexOf(e);-1!==i&&this.listeners[t].splice(i,1)}}},{key:"fire",value:function fire(t){this.listeners[t.type]&&this.listeners[t.type].forEach((function(e){return e(t)}))}}])}(),ne={number:{buildBySigIndex:[function(t,e,i){return"".concat(e[0])}]},vec2:{buildBySigIndex:[function(t,e,i){return"vec2(".concat(e[0],", ").concat(e[1],")")}]},vec3:{buildBySigIndex:[function(t,e,i){return"vec3(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")}]},vec4:{buildBySigIndex:[function(t,e,i){return"vec4(".concat(e[0],", ").concat(e[1],", ").concat(e[2],", ").concat(e[3],")")}]},add:{buildBySigIndex:[function(t,e,i){return"(".concat(e[0]," + ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," + ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," + ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," + ").concat(e[1],")")}]},subtract:{buildBySigIndex:[function(t,e,i){return"(".concat(e[0]," - ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," - ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," - ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," - ").concat(e[1],")")}]},mul:{buildBySigIndex:[function(t,e,i){return"(".concat(e[0]," * ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," * ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," * ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," * ").concat(e[1],")")}]},div:{buildBySigIndex:[function(t,e,i){return"(".concat(e[0]," / ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," / ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," / ").concat(e[1],")")},function(t,e,i){return"(".concat(e[0]," / ").concat(e[1],")")}]},power:{buildBySigIndex:[function(t,e,i){return"pow(".concat(e[0],", ").concat(e[1],")")}]},sqrt:{buildBySigIndex:[function(t,e,i){return"sqrt(".concat(e[0],")")}]},sin:{buildBySigIndex:[function(t,e,i){return"sin(".concat(e[0],")")}]},cos:{buildBySigIndex:[function(t,e,i){return"cos(".concat(e[0],")")}]},tan:{buildBySigIndex:[function(t,e,i){return"tan(".concat(e[0],")")}]},asin:{buildBySigIndex:[function(t,e,i){return"asin(".concat(e[0],")")}]},acos:{buildBySigIndex:[function(t,e,i){return"acos(".concat(e[0],")")}]},atan:{buildBySigIndex:[function(t,e,i){return"atan(".concat(e[0],")")}]},atan2:{buildBySigIndex:[function(t,e,i){return"atan(".concat(e[0],", ").concat(e[1],")")}]},abs:{buildBySigIndex:[function(t,e,i){return"abs(".concat(e[0],")")}]},floor:{buildBySigIndex:[function(t,e,i){return"floor(".concat(e[0],")")}]},ceil:{buildBySigIndex:[function(t,e,i){return"ceil(".concat(e[0],")")}]},round:{buildBySigIndex:[function(t,e,i){return"round(".concat(e[0],")")}]},min:{buildBySigIndex:[function(t,e,i){return"min(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"min(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"min(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"min(".concat(e[0],", ").concat(e[1],")")}]},max:{buildBySigIndex:[function(t,e,i){return"max(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"max(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"max(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"max(".concat(e[0],", ").concat(e[1],")")}]},clamp:{buildBySigIndex:[function(t,e,i){return"clamp(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"clamp(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"clamp(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"clamp(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")}]},mix:{buildBySigIndex:[function(t,e,i){return"mix(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"mix(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"mix(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"mix(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")}]},step:{buildBySigIndex:[function(t,e,i){return"step(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"step(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"step(".concat(e[0],", ").concat(e[1],")")},function(t,e,i){return"step(".concat(e[0],", ").concat(e[1],")")}]},smoothstep:{buildBySigIndex:[function(t,e,i){return"smoothstep(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"smoothstep(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"smoothstep(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")},function(t,e,i){return"smoothstep(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")")}]},length:{buildBySigIndex:[function(t,e,i){return"length(".concat(e[0],")")},function(t,e,i){return"length(".concat(e[0],")")},function(t,e,i){return"length(".concat(e[0],")")}]},delta:{buildBySigIndex:[function(t,e,i){return"sim_params.delta"}]},particleProperty:{buildBySigIndex:[function(t,e,i){return"particle.".concat(t.data.property)}]}},se=function(t){function WebGPUCompiler(){var t;return _classCallCheck(this,WebGPUCompiler),_defineProperty(t=_callSuper(this,WebGPUCompiler),"nodeResult",new Map),_defineProperty(t,"particleInstanceByteSize",0),_defineProperty(t,"hasRandom",!1),t}return _inherits(WebGPUCompiler,t),_createClass(WebGPUCompiler,[{key:"run",value:function run(t,e){throw new Error("Method not implemented.")}},{key:"calculateMemoryLayout",value:function calculateMemoryLayout(t){for(var e=0,i=0;i,"),t.push("}"),t.push("struct Particle {"),t.push(" color: vec4,"),t.push(" position: vec3,");var n=e.outputNodes.filter((function(t){return"particleProperty"===t.definition.name&&"position"!==t.data.property&&"color"!==t.data.property&&"life"!==t.data.property&&"size"!==t.data.property&&"rotation"!==t.data.property&&"age"!==t.data.property})).sort((function(t,e){return J(t.data.type)-J(e.data.type)}));this.particleInstanceByteSize=this.calculateMemoryLayout([B.Vec4,B.Vec3].concat(n.map((function(t){return t.data.type}))).concat([B.Number,B.Number,B.Number,B.Number])),n.forEach((function(e){t.push(" ".concat(e.data.property,": ").concat(r.getTypeFromNodeType(e.data.type),","))})),t.push(" size: f32,"),t.push(" rotation: f32,"),t.push(" life: f32,"),t.push(" age: f32,"),t.push("}"),t.push("struct Particles {"),t.push(" particles : array,"),t.push("}")}},{key:"buildHeader",value:function buildHeader(t,e,i){t.push(he),this.buildPredefinedStructs(t,e,i),t.push("@binding(0) @group(0) var sim_params : SimulationParams;"),t.push("@binding(1) @group(0) var data : Particles;"),t.push("@binding(2) @group(0) var indexList : array;"),t.push("@compute @workgroup_size(64)"),t.push("fn simulate(@builtin(global_invocation_id) global_invocation_id : vec3) {"),t.push(" let invo_id = global_invocation_id.x;"),t.push(" let idx = indexList[invo_id];"),this.hasRandom&&t.push(" init_rand(invo_id, sim_params.seed);"),t.push(" var particle = data.particles[idx];")}},{key:"buildFooter",value:function buildFooter(t,e,i){t.push(" particle.age += sim_params.delta;"),t.push(" data.particles[idx] = particle;"),t.push("}")}},{key:"buildWebGPUCode",value:function buildWebGPUCode(t,e){var i=[];return this.buildHeader(i,t,e),this.buildDataFlow(t,i,e),this.buildFooter(i,t,e),i.join("\n")}},{key:"buildDataFlow",value:function buildDataFlow(t,e,i){for(var r=0;r0&&e.push("".concat(c," = ").concat(o[0],";")),this.nodeResult.set(n,c)):n.outputs[0].length>1?(e.push("let v".concat(e.length," = ").concat(c,";")),this.nodeResult.set(n,"v"+(e.length-1))):n.outputs[0].length>0&&this.nodeResult.set(n,c))}}},{key:"build",value:function build(t,e){return t.compiled||this.buildExecutionOrder(t,e),this.buildWebGPUCode(t,e)}},{key:"buildFromValue",value:function buildFromValue(t){if("number"==typeof t)return""+t;if(t instanceof Vector2)return"vec2(".concat(t.x,", ").concat(t.y,")");if(t instanceof Vector3)return"vec3(".concat(t.x,", ").concat(t.y,", ").concat(t.z,")");if(t instanceof Vector4)return"vec4(".concat(t.x,", ").concat(t.y,", ").concat(t.z,", ").concat(t.w,")");throw new Error("Unknown value type ".concat(_typeof(t)))}},{key:"getTypeFromNodeType",value:function getTypeFromNodeType(t){switch(t){case B.Number:return"f32";case B.Vec2:return"vec";case B.Vec3:return"vec3";case B.Vec4:return"vec4";default:throw new Error("Unknown node value type ".concat(t))}}},{key:"buildFromAdapter",value:function buildFromAdapter(t,e,i){if(t.isInput)switch(t.node.definition.type){case Y.Storage:for(var r=0;r rand_seed : vec2;\n\nfn init_rand(invocation_id : u32, seed : vec4) {\n rand_seed = seed.xz;\n rand_seed = fract(rand_seed * cos(35.456+f32(invocation_id) * seed.yw));\n rand_seed = fract(rand_seed * cos(41.235+f32(invocation_id) * seed.xw));\n}\n\nfn rand() -> f32 {\n rand_seed.x = fract(cos(dot(rand_seed, vec2(23.14077926, 232.61690225))) * 136.8168);\n rand_seed.y = fract(cos(dot(rand_seed, vec2(54.47856553, 345.84153136))) * 534.7645);\n return rand_seed.y;\n}\n";function _initWebGPU(){return(_initWebGPU=_asyncToGenerator(_regeneratorRuntime().mark((function _callee2(){var t,e,i;return _regeneratorRuntime().wrap((function _callee2$(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,null===(t=navigator.gpu)||void 0===t?void 0:t.requestAdapter();case 2:if(e=r.sent){r.next=5;break}throw"need a browser that supports WebGPU";case 5:return r.next=7,null==e?void 0:e.requestDevice();case 7:if(i=r.sent){r.next=10;break}throw"need a browser that supports WebGPU";case 10:return r.abrupt("return",{adapter:e,device:i});case 11:case"end":return r.stop()}}),_callee2)})))).apply(this,arguments)}var ue=function(){return _createClass((function WebGPURenderer(t,e,i,r,n){var s=this,a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"";_classCallCheck(this,WebGPURenderer),_defineProperty(this,"numLiveParticles",0),_defineProperty(this,"simulationUBOBuffer",void 0),_defineProperty(this,"simulationParams",void 0),_defineProperty(this,"particlesBuffer",void 0),_defineProperty(this,"particleIndexBuffer",void 0),_defineProperty(this,"computeBindGroup",void 0),_defineProperty(this,"computePipeline",void 0),_defineProperty(this,"context",void 0),_defineProperty(this,"mvp",new Matrix4),_defineProperty(this,"uniformBuffer",void 0),_defineProperty(this,"quadVertexBuffer",void 0),_defineProperty(this,"renderBindGroup",void 0),_defineProperty(this,"renderPassDescriptor",void 0),_defineProperty(this,"renderPipeline",void 0),_defineProperty(this,"cpuReadableBuffer",void 0),_defineProperty(this,"frame",function(){var t=_asyncToGenerator(_regeneratorRuntime().mark((function _callee(t){var e,i,r,n;return _regeneratorRuntime().wrap((function _callee$(a){for(;;)switch(a.prev=a.next){case 0:s.deviceContext.device.queue.writeBuffer(s.simulationUBOBuffer,0,new Float32Array([s.simulationParams.simulate?s.simulationParams.deltaTime:0,0,0,0,100*Math.random(),100*Math.random(),1+Math.random(),1+Math.random()])),s.mvp.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),s.deviceContext.device.queue.writeBuffer(s.uniformBuffer,0,new Float32Array([t.matrixWorldInverse.elements[0],t.matrixWorldInverse.elements[1],t.matrixWorldInverse.elements[2],t.matrixWorldInverse.elements[3],t.matrixWorldInverse.elements[4],t.matrixWorldInverse.elements[5],t.matrixWorldInverse.elements[6],t.matrixWorldInverse.elements[7],t.matrixWorldInverse.elements[8],t.matrixWorldInverse.elements[9],t.matrixWorldInverse.elements[10],t.matrixWorldInverse.elements[11],t.matrixWorldInverse.elements[12],t.matrixWorldInverse.elements[13],t.matrixWorldInverse.elements[14],t.matrixWorldInverse.elements[15],t.projectionMatrix.elements[0],t.projectionMatrix.elements[1],t.projectionMatrix.elements[2],t.projectionMatrix.elements[3],t.projectionMatrix.elements[4],t.projectionMatrix.elements[5],t.projectionMatrix.elements[6],t.projectionMatrix.elements[7],t.projectionMatrix.elements[8],t.projectionMatrix.elements[9],t.projectionMatrix.elements[10],t.projectionMatrix.elements[11],t.projectionMatrix.elements[12],t.projectionMatrix.elements[13],t.projectionMatrix.elements[14],t.projectionMatrix.elements[15]])),e=s.context.getCurrentTexture(),s.renderPassDescriptor.colorAttachments[0].view=e.createView(),i=s.deviceContext.device.createCommandEncoder(),(r=i.beginComputePass()).setPipeline(s.computePipeline),r.setBindGroup(0,s.computeBindGroup),r.dispatchWorkgroups(Math.ceil(s.numParticles/64)),r.end(),(n=i.beginRenderPass(s.renderPassDescriptor)).setPipeline(s.renderPipeline),n.setBindGroup(0,s.renderBindGroup),n.setVertexBuffer(0,s.quadVertexBuffer),n.draw(6,s.numLiveParticles,0,0),n.end(),s.debug&&i.copyBufferToBuffer(s.particlesBuffer,0,s.cpuReadableBuffer,0,s.numParticles*s.particleInstanceByteSize),s.deviceContext.device.queue.submit([i.finish()]);case 19:case"end":return a.stop()}}),_callee)})));return function(e){return t.apply(this,arguments)}}()),this.deviceContext=t,this.canvas=e,this.numParticles=i,this.particleInstanceByteSize=r,this.debug=a,this.renderCode=o,this.initBuffers(),this.initRenderPipeline(),this.initSimulationPipeline(n)}),[{key:"initBuffers",value:function initBuffers(){this.numLiveParticles=this.numParticles,this.particlesBuffer=this.deviceContext.device.createBuffer({size:this.numParticles*this.particleInstanceByteSize,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC}),this.particleIndexBuffer=this.deviceContext.device.createBuffer({size:4*this.numParticles,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST}),this.debug&&(this.cpuReadableBuffer=this.deviceContext.device.createBuffer({size:this.numParticles*this.particleInstanceByteSize,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}));for(var t=new Uint32Array(this.numParticles),e=0;e,\n up : vec3\n}\n\nstruct Particle {\n color: vec4,\n position: vec3,\n velocity: vec3,\n life: f32,\n age: f32,\n}\n\n@group(0) @binding(0) var render_params : RenderParams;\n@group(0) @binding(1) var particles: array;\n@group(0) @binding(2) var particleIndices: array;\n\nstruct VertexInput {\n /*@location(0) position : vec3f,\n @location(1) color : vec4f,*/\n @location(0) quad_pos : vec2f, // -1..+1\n @builtin(instance_index) instanceIndex: u32,\n}\n\nstruct VertexOutput {\n @builtin(position) position : vec4f,\n @location(0) color : vec4f,\n @location(1) quad_pos : vec2f, // -1..+1\n}\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var quad_pos = mat2x3f(render_params.right, render_params.up) * in.quad_pos;\n \n var particle = particles[particleIndices[in.instanceIndex]];\n var position = particle.position + quad_pos * 0.01;\n var out : VertexOutput;\n out.position = render_params.modelViewProjectionMatrix * vec4f(position, 1.0);\n out.color = particle.color;\n out.quad_pos = in.quad_pos;\n return out;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Fragment shader\n////////////////////////////////////////////////////////////////////////////////\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4f {\n var color = vec4(1.0, 0.0, 0.0, 1.0); //in.color;\n // Apply a circular particle alpha mask\n color.a = color.a * max(1.0 - length(in.quad_pos), 0.0);\n return color;\n}\n\n":this.renderCode});this.renderPipeline=this.deviceContext.device.createRenderPipeline({layout:"auto",vertex:{module:i,entryPoint:"vs_main",buffers:[{arrayStride:8,stepMode:"vertex",attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]}]},fragment:{module:i,entryPoint:"fs_main",targets:[{format:e,blend:{color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"},alpha:{srcFactor:"zero",dstFactor:"one",operation:"add"}}}]},primitive:{topology:"triangle-list"},depthStencil:{depthWriteEnabled:!1,depthCompare:"less",format:"depth24plus"}});var r=this.deviceContext.device.createTexture({size:[this.canvas.width,this.canvas.height],format:"depth24plus",usage:GPUTextureUsage.RENDER_ATTACHMENT});this.uniformBuffer=this.deviceContext.device.createBuffer({size:128,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.renderBindGroup=this.deviceContext.device.createBindGroup({layout:this.renderPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.uniformBuffer}},{binding:1,resource:{buffer:this.particlesBuffer}},{binding:2,resource:{buffer:this.particleIndexBuffer}}]}),this.renderPassDescriptor={colorAttachments:[{view:void 0,clearValue:[0,0,0,1],loadOp:"clear",storeOp:"store"}],depthStencilAttachment:{view:r.createView(),depthClearValue:1,depthLoadOp:"clear",depthStoreOp:"store"}},this.quadVertexBuffer=this.deviceContext.device.createBuffer({size:48,usage:GPUBufferUsage.VERTEX,mappedAtCreation:!0}),new Float32Array(this.quadVertexBuffer.getMappedRange()).set([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),this.quadVertexBuffer.unmap()}},{key:"initSimulationPipeline",value:function initSimulationPipeline(t){this.simulationUBOBuffer=this.deviceContext.device.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.simulationParams={simulate:!0,deltaTime:.01},this.computePipeline=this.deviceContext.device.createComputePipeline({layout:"auto",compute:{module:this.deviceContext.device.createShaderModule({code:t}),entryPoint:"simulate"}}),this.computeBindGroup=this.deviceContext.device.createBindGroup({layout:this.computePipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.simulationUBOBuffer}},{binding:1,resource:{buffer:this.particlesBuffer,offset:0,size:this.numParticles*this.particleInstanceByteSize}},{binding:2,resource:{buffer:this.particleIndexBuffer,offset:0,size:4*this.numParticles}}]})}}])}();t.Adapter=j,t.BaseCompiler=Q,t.GraphNodeType=Z,t.Interpreter=X,t.Node=q,t.NodeDef=H,t.NodeGraph=Yt,t.NodeGraphBehavior=Ht,t.NodeType=Y,t.NodeTypes=K,t.NodeVFX=re,t.NodeValueType=B,t.OutputNodeTypeNames=Xt,t.WebGPUCompiler=se,t.WebGPURenderer=ue,t.Wire=W,t.genDefaultForNodeValueType=D,t.getAlignOfNodeValueType=G,t.getSizeOfNodeValueType=J,t.initWebGPU=function initWebGPU(){return _initWebGPU.apply(this,arguments)}},"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).QUARKS=t.QUARKS||{},t.QUARKS.NODES={}),t.THREE)}));