babylon.quarks 0.17.9 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("@babylonjs/core/Buffers/buffer"),e=require("@babylonjs/core/Meshes/transformNode"),i=require("@babylonjs/core/Meshes/mesh"),s=require("@babylonjs/core/Materials/shaderMaterial"),r=require("@babylonjs/core/Meshes/mesh.vertexData"),n=require("@babylonjs/core/Materials/effect"),o=require("@babylonjs/core/Engines/constants"),a=require("@babylonjs/core/Maths/math.vector"),h=require("@babylonjs/core/Culling/boundingInfo"),l=require("@babylonjs/core/Materials/Textures/texture"),c=require("@babylonjs/core/Materials/standardMaterial"),u=require("@babylonjs/core/Materials/PBR/pbrMaterial");const d=["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 m=1234567;const p=Math.PI/180,y=180/Math.PI;function f(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return(d[255&t]+d[t>>8&255]+d[t>>16&255]+d[t>>24&255]+"-"+d[255&e]+d[e>>8&255]+"-"+d[e>>16&15|64]+d[e>>24&255]+"-"+d[63&i|128]+d[i>>8&255]+"-"+d[i>>16&255]+d[i>>24&255]+d[255&s]+d[s>>8&255]+d[s>>16&255]+d[s>>24&255]).toLowerCase()}function x(t,e,i){return Math.max(e,Math.min(i,t))}function g(t,e){return(t%e+e)%e}function v(t,e,i,s,r){return s+(t-e)*(r-s)/(i-e)}function S(t,e,i){return t!==e?(i-t)/(e-t):0}function M(t,e,i){return(1-i)*t+i*e}function w(t,e,i,s){return M(t,e,1-Math.exp(-i*s))}function b(t,e=1){return e-Math.abs(g(t,2*e)-e)}function _(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}function z(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)}function T(t,e){return t+Math.floor(Math.random()*(e-t+1))}function O(t,e){return t+Math.random()*(e-t)}function P(t){return t*(.5-Math.random())}function B(t){void 0!==t&&(m=t);let e=m+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}function N(t){return t*p}function C(t){return t*y}function V(t){return!(t&t-1)&&0!==t}function F(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function A(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function E(t,e,i,s,r){const n=Math.cos,o=Math.sin,a=n(i/2),h=o(i/2),l=n((e+s)/2),c=o((e+s)/2),u=n((e-s)/2),d=o((e-s)/2),m=n((s-e)/2),p=o((s-e)/2);switch(r){case"XYX":t.set(a*c,h*u,h*d,a*l);break;case"YZY":t.set(h*d,a*c,h*u,a*l);break;case"ZXZ":t.set(h*u,h*d,a*c,a*l);break;case"XZX":t.set(a*c,h*p,h*m,a*l);break;case"YXY":t.set(h*m,a*c,h*p,a*l);break;case"ZYZ":t.set(h*p,h*m,a*c,a*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function D(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.")}}function R(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.")}}const J={DEG2RAD:p,RAD2DEG:y,generateUUID:f,clamp:x,euclideanModulo:g,mapLinear:v,inverseLerp:S,lerp:M,damp:w,pingpong:b,smoothstep:_,smootherstep:z,randInt:T,randFloat:O,randFloatSpread:P,seededRandom:B,degToRad:N,radToDeg:C,isPowerOfTwo:V,ceilPowerOfTwo:F,floorPowerOfTwo:A,setQuaternionFromProperEuler:E,normalize:R,denormalize:D};class I{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,n,o){let a=i[s+0],h=i[s+1],l=i[s+2],c=i[s+3];const u=r[n+0],d=r[n+1],m=r[n+2],p=r[n+3];if(0===o)return t[e+0]=a,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===o)return t[e+0]=u,t[e+1]=d,t[e+2]=m,void(t[e+3]=p);if(c!==p||a!==u||h!==d||l!==m){let t=1-o;const e=a*u+h*d+l*m+c*p,i=e>=0?1:-1,s=1-e*e;if(s>Number.EPSILON){const r=Math.sqrt(s),n=Math.atan2(r,e*i);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r}const r=o*i;if(a=a*t+u*r,h=h*t+d*r,l=l*t+m*r,c=c*t+p*r,t===1-o){const t=1/Math.sqrt(a*a+h*h+l*l+c*c);a*=t,h*=t,l*=t,c*=t}}t[e]=a,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,s,r,n){const o=i[s],a=i[s+1],h=i[s+2],l=i[s+3],c=r[n],u=r[n+1],d=r[n+2],m=r[n+3];return t[e]=o*m+l*c+a*d-h*u,t[e+1]=a*m+l*u+h*c-o*d,t[e+2]=h*m+l*d+o*u-a*c,t[e+3]=l*m-o*c-a*u-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,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new I(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,s=t._y,r=t._z,n=t._order,o=Math.cos,a=Math.sin,h=o(i/2),l=o(s/2),c=o(r/2),u=a(i/2),d=a(s/2),m=a(r/2);switch(n){case"XYZ":this._x=u*l*c+h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c-u*d*m;break;case"YXZ":this._x=u*l*c+h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c+u*d*m;break;case"ZXY":this._x=u*l*c-h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c-u*d*m;break;case"ZYX":this._x=u*l*c-h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c+u*d*m;break;case"YZX":this._x=u*l*c+h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c-u*d*m;break;case"XZY":this._x=u*l*c-h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c+u*d*m;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],r=e[8],n=e[1],o=e[5],a=e[9],h=e[2],l=e[6],c=e[10],u=i+o+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(l-a)*t,this._y=(r-h)*t,this._z=(n-s)*t}else if(i>o&&i>c){const t=2*Math.sqrt(1+i-o-c);this._w=(l-a)/t,this._x=.25*t,this._y=(s+n)/t,this._z=(r+h)/t}else if(o>c){const t=2*Math.sqrt(1+o-i-c);this._w=(r-h)/t,this._x=(s+n)/t,this._y=.25*t,this._z=(a+l)/t}else{const t=2*Math.sqrt(1+c-i-o);this._w=(n-s)/t,this._x=(r+h)/t,this._y=(a+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(x(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const s=Math.min(1,e/i);return this.slerp(t,s),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,s=t._y,r=t._z,n=t._w,o=e._x,a=e._y,h=e._z,l=e._w;return this._x=i*l+n*o+s*h-r*a,this._y=s*l+n*a+r*o-i*h,this._z=r*l+n*h+i*a-s*o,this._w=n*l-i*o-s*a-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,s=this._y,r=this._z,n=this._w;let o=n*t._w+i*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=n,this._x=i,this._y=s,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-e;return this._w=t*n+e*this._w,this._x=t*i+e*this._x,this._y=t*s+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const h=Math.sqrt(a),l=Math.atan2(h,o),c=Math.sin((1-e)*l)/h,u=Math.sin(e*l)/h;return this._w=n*c+this._w*u,this._x=i*c+this._x*u,this._y=s*c+this._y*u,this._z=r*c+this._z*u,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(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*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 k{constructor(t=0,e=0,i=0){this.isVector3=!0,k.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 k(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(L.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(L.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,r=t.elements,n=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*n,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*n,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*n,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,r=t.x,n=t.y,o=t.z,a=t.w,h=2*(n*s-o*i),l=2*(o*e-r*s),c=2*(r*i-n*e);return this.x=e+a*h+n*c-o*l,this.y=i+a*l+o*h-r*c,this.z=s+a*c+r*l-n*h,this}transformDirection(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,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,s=t.y,r=t.z,n=e.x,o=e.y,a=e.z;return this.x=s*a-r*o,this.y=r*n-i*a,this.z=i*o-s*n,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 U.copy(this).projectOnVector(t),this.sub(U)}reflect(t){return this.sub(U.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(x(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}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 s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*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(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,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 U=new k,L=new I,q=2e3,G=2001;class Q{constructor(t,e,i,s,r,n,o,a,h,l,c,u,d,m,p,y){this.isMatrix4=!0,Q.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,s,r,n,o,a,h,l,c,u,d,m,p,y)}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,s,r,n,o,a,h,l,c,u,d,m,p,y){const f=this.elements;return f[0]=t,f[4]=e,f[8]=i,f[12]=s,f[1]=r,f[5]=n,f[9]=o,f[13]=a,f[2]=h,f[6]=l,f[10]=c,f[14]=u,f[3]=d,f[7]=m,f[11]=p,f[15]=y,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 Q).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,s=1/X.setFromMatrixColumn(t,0).length(),r=1/X.setFromMatrixColumn(t,1).length(),n=1/X.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*n,e[9]=i[9]*n,e[10]=i[10]*n,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,s=t.y,r=t.z,n=Math.cos(i),o=Math.sin(i),a=Math.cos(s),h=Math.sin(s),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=n*l,i=n*c,s=o*l,r=o*c;e[0]=a*l,e[4]=-a*c,e[8]=h,e[1]=i+s*h,e[5]=t-r*h,e[9]=-o*a,e[2]=r-t*h,e[6]=s+i*h,e[10]=n*a}else if("YXZ"===t.order){const t=a*l,i=a*c,s=h*l,r=h*c;e[0]=t+r*o,e[4]=s*o-i,e[8]=n*h,e[1]=n*c,e[5]=n*l,e[9]=-o,e[2]=i*o-s,e[6]=r+t*o,e[10]=n*a}else if("ZXY"===t.order){const t=a*l,i=a*c,s=h*l,r=h*c;e[0]=t-r*o,e[4]=-n*c,e[8]=s+i*o,e[1]=i+s*o,e[5]=n*l,e[9]=r-t*o,e[2]=-n*h,e[6]=o,e[10]=n*a}else if("ZYX"===t.order){const t=n*l,i=n*c,s=o*l,r=o*c;e[0]=a*l,e[4]=s*h-i,e[8]=t*h+r,e[1]=a*c,e[5]=r*h+t,e[9]=i*h-s,e[2]=-h,e[6]=o*a,e[10]=n*a}else if("YZX"===t.order){const t=n*a,i=n*h,s=o*a,r=o*h;e[0]=a*l,e[4]=r-t*c,e[8]=s*c+i,e[1]=c,e[5]=n*l,e[9]=-o*l,e[2]=-h*l,e[6]=i*c+s,e[10]=t-r*c}else if("XZY"===t.order){const t=n*a,i=n*h,s=o*a,r=o*h;e[0]=a*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=n*l,e[9]=i*c-s,e[2]=s*c-i,e[6]=o*l,e[10]=r*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(j,t,H)}lookAt(t,e,i){const s=this.elements;return K.subVectors(t,e),0===K.lengthSq()&&(K.z=1),K.normalize(),Y.crossVectors(i,K),0===Y.lengthSq()&&(1===Math.abs(i.z)?K.x+=1e-4:K.z+=1e-4,K.normalize(),Y.crossVectors(i,K)),Y.normalize(),Z.crossVectors(K,Y),s[0]=Y.x,s[4]=Z.x,s[8]=K.x,s[1]=Y.y,s[5]=Z.y,s[9]=K.y,s[2]=Y.z,s[6]=Z.z,s[10]=K.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,n=i[0],o=i[4],a=i[8],h=i[12],l=i[1],c=i[5],u=i[9],d=i[13],m=i[2],p=i[6],y=i[10],f=i[14],x=i[3],g=i[7],v=i[11],S=i[15],M=s[0],w=s[4],b=s[8],_=s[12],z=s[1],T=s[5],O=s[9],P=s[13],B=s[2],N=s[6],C=s[10],V=s[14],F=s[3],A=s[7],E=s[11],D=s[15];return r[0]=n*M+o*z+a*B+h*F,r[4]=n*w+o*T+a*N+h*A,r[8]=n*b+o*O+a*C+h*E,r[12]=n*_+o*P+a*V+h*D,r[1]=l*M+c*z+u*B+d*F,r[5]=l*w+c*T+u*N+d*A,r[9]=l*b+c*O+u*C+d*E,r[13]=l*_+c*P+u*V+d*D,r[2]=m*M+p*z+y*B+f*F,r[6]=m*w+p*T+y*N+f*A,r[10]=m*b+p*O+y*C+f*E,r[14]=m*_+p*P+y*V+f*D,r[3]=x*M+g*z+v*B+S*F,r[7]=x*w+g*T+v*N+S*A,r[11]=x*b+g*O+v*C+S*E,r[15]=x*_+g*P+v*V+S*D,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],s=t[8],r=t[12],n=t[1],o=t[5],a=t[9],h=t[13],l=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*a*c-s*h*c-r*o*u+i*h*u+s*o*d-i*a*d)+t[7]*(+e*a*d-e*h*u+r*n*u-s*n*d+s*h*l-r*a*l)+t[11]*(+e*h*c-e*o*d-r*n*c+i*n*d+r*o*l-i*h*l)+t[15]*(-s*o*l-e*a*c+e*o*u+s*n*c-i*n*u+i*a*l)}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 s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11],m=t[12],p=t[13],y=t[14],f=t[15],x=c*y*h-p*u*h+p*a*d-o*y*d-c*a*f+o*u*f,g=m*u*h-l*y*h-m*a*d+n*y*d+l*a*f-n*u*f,v=l*p*h-m*c*h+m*o*d-n*p*d-l*o*f+n*c*f,S=m*c*a-l*p*a-m*o*u+n*p*u+l*o*y-n*c*y,M=e*x+i*g+s*v+r*S;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/M;return t[0]=x*w,t[1]=(p*u*r-c*y*r-p*s*d+i*y*d+c*s*f-i*u*f)*w,t[2]=(o*y*r-p*a*r+p*s*h-i*y*h-o*s*f+i*a*f)*w,t[3]=(c*a*r-o*u*r-c*s*h+i*u*h+o*s*d-i*a*d)*w,t[4]=g*w,t[5]=(l*y*r-m*u*r+m*s*d-e*y*d-l*s*f+e*u*f)*w,t[6]=(m*a*r-n*y*r-m*s*h+e*y*h+n*s*f-e*a*f)*w,t[7]=(n*u*r-l*a*r+l*s*h-e*u*h-n*s*d+e*a*d)*w,t[8]=v*w,t[9]=(m*c*r-l*p*r-m*i*d+e*p*d+l*i*f-e*c*f)*w,t[10]=(n*p*r-m*o*r+m*i*h-e*p*h-n*i*f+e*o*f)*w,t[11]=(l*o*r-n*c*r-l*i*h+e*c*h+n*i*d-e*o*d)*w,t[12]=S*w,t[13]=(l*p*s-m*c*s+m*i*u-e*p*u-l*i*y+e*c*y)*w,t[14]=(m*o*s-n*p*s-m*i*a+e*p*a+n*i*y-e*o*y)*w,t[15]=(n*c*s-l*o*s+l*i*a-e*c*a-n*i*u+e*o*u)*w,this}scale(t){const e=this.elements,i=t.x,s=t.y,r=t.z;return e[0]*=i,e[4]*=s,e[8]*=r,e[1]*=i,e[5]*=s,e[9]*=r,e[2]*=i,e[6]*=s,e[10]*=r,e[3]*=i,e[7]*=s,e[11]*=r,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],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}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),s=Math.sin(e),r=1-i,n=t.x,o=t.y,a=t.z,h=r*n,l=r*o;return this.set(h*n+i,h*o-s*a,h*a+s*o,0,h*o+s*a,l*o+i,l*a-s*n,0,h*a-s*o,l*a+s*n,r*a*a+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,s,r,n){return this.set(1,i,r,0,t,1,n,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,r=e._x,n=e._y,o=e._z,a=e._w,h=r+r,l=n+n,c=o+o,u=r*h,d=r*l,m=r*c,p=n*l,y=n*c,f=o*c,x=a*h,g=a*l,v=a*c,S=i.x,M=i.y,w=i.z;return s[0]=(1-(p+f))*S,s[1]=(d+v)*S,s[2]=(m-g)*S,s[3]=0,s[4]=(d-v)*M,s[5]=(1-(u+f))*M,s[6]=(y+x)*M,s[7]=0,s[8]=(m+g)*w,s[9]=(y-x)*w,s[10]=(1-(u+p))*w,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let r=X.set(s[0],s[1],s[2]).length();const n=X.set(s[4],s[5],s[6]).length(),o=X.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],W.copy(this);const a=1/r,h=1/n,l=1/o;return W.elements[0]*=a,W.elements[1]*=a,W.elements[2]*=a,W.elements[4]*=h,W.elements[5]*=h,W.elements[6]*=h,W.elements[8]*=l,W.elements[9]*=l,W.elements[10]*=l,e.setFromRotationMatrix(W),i.x=r,i.y=n,i.z=o,this}makePerspective(t,e,i,s,r,n,o=2e3){const a=this.elements,h=2*r/(e-t),l=2*r/(i-s),c=(e+t)/(e-t),u=(i+s)/(i-s);let d,m;if(o===q)d=-(n+r)/(n-r),m=-2*n*r/(n-r);else{if(o!==G)throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);d=-n/(n-r),m=-n*r/(n-r)}return a[0]=h,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,s,r,n,o=2e3){const a=this.elements,h=1/(e-t),l=1/(i-s),c=1/(n-r),u=(e+t)*h,d=(i+s)*l;let m,p;if(o===q)m=(n+r)*c,p=-2*c;else{if(o!==G)throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);m=r*c,p=-1*c}return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=p,a[14]=-m,a[3]=0,a[7]=0,a[11]=0,a[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 X=new k,W=new Q,j=new k(0,0,0),H=new k(1,1,1),Y=new k,Z=new k,K=new k,$=new Q,tt=new I;class et{constructor(t=0,e=0,i=0,s=et.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}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,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new et(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 s=t.elements,r=s[0],n=s[4],o=s[8],a=s[1],h=s[5],l=s[9],c=s[2],u=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(x(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-x(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(x(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-x(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(x(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-x(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,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 $.makeRotationFromQuaternion(t),this.setFromRotationMatrix($,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return tt.setFromEuler(this),this.setFromQuaternion(tt,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}}et.DEFAULT_ORDER="XYZ";class it{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 it(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,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[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(x(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),s=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*i-n*s+t.x,this.y=r*s+n*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}it.isVector2=!0;class st{constructor(t=0,e=0,i=0,s=1){st.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}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,s){return this.x=t,this.y=e,this.z=i,this.w=s,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 st(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,s=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12]*r,this.y=n[1]*e+n[5]*i+n[9]*s+n[13]*r,this.z=n[2]*e+n[6]*i+n[10]*s+n[14]*r,this.w=n[3]*e+n[7]*i+n[11]*s+n[15]*r,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,s,r;const n=.01,o=.1,a=t.elements,h=a[0],l=a[4],c=a[8],u=a[1],d=a[5],m=a[9],p=a[2],y=a[6],f=a[10];if(Math.abs(l-u)<n&&Math.abs(c-p)<n&&Math.abs(m-y)<n){if(Math.abs(l+u)<o&&Math.abs(c+p)<o&&Math.abs(m+y)<o&&Math.abs(h+d+f-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(h+1)/2,a=(d+1)/2,x=(f+1)/2,g=(l+u)/4,v=(c+p)/4,S=(m+y)/4;return t>a&&t>x?t<n?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(t),s=g/i,r=v/i):a>x?a<n?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(a),i=g/s,r=S/s):x<n?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(x),i=v/r,s=S/r),this.set(i,s,r,e),this}let x=Math.sqrt((y-m)*(y-m)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(x)<.001&&(x=1),this.x=(y-m)/x,this.y=(c-p)/x,this.z=(u-l)/x,this.w=Math.acos((h+d+f-1)/2),this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),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.w=Math.max(t.w,Math.min(e.w,this.w)),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.w=Math.max(t,Math.min(e,this.w)),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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(t.w-this.w)*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.w=t.w+(e.w-t.w)*i,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class rt{constructor(t,e,i,s,r,n,o,a,h){rt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,o,a,h)}set(t,e,i,s,r,n,o,a,h){const l=this.elements;return l[0]=t,l[1]=s,l[2]=o,l[3]=e,l[4]=r,l[5]=a,l[6]=i,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}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],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,n=i[0],o=i[3],a=i[6],h=i[1],l=i[4],c=i[7],u=i[2],d=i[5],m=i[8],p=s[0],y=s[3],f=s[6],x=s[1],g=s[4],v=s[7],S=s[2],M=s[5],w=s[8];return r[0]=n*p+o*x+a*S,r[3]=n*y+o*g+a*M,r[6]=n*f+o*v+a*w,r[1]=h*p+l*x+c*S,r[4]=h*y+l*g+c*M,r[7]=h*f+l*v+c*w,r[2]=u*p+d*x+m*S,r[5]=u*y+d*g+m*M,r[8]=u*f+d*v+m*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*n*l-e*o*h-i*r*l+i*o*a+s*r*h-s*n*a}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],l=t[8],c=l*n-o*h,u=o*a-l*r,d=h*r-n*a,m=e*c+i*u+s*d;if(0===m)return this.set(0,0,0,0,0,0,0,0,0);const p=1/m;return t[0]=c*p,t[1]=(s*h-l*i)*p,t[2]=(o*i-s*n)*p,t[3]=u*p,t[4]=(l*e-s*a)*p,t[5]=(s*r-o*e)*p,t[6]=d*p,t[7]=(i*a-h*e)*p,t[8]=(n*e-i*r)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,r,n,o){const a=Math.cos(r),h=Math.sin(r);return this.set(i*a,i*h,-i*(a*n+h*o)+n+t,-s*h,s*a,-s*(-h*n+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(nt.makeScale(t,e)),this}rotate(t){return this.premultiply(nt.makeRotation(-t)),this}translate(t,e){return this.premultiply(nt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;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}clone(){return(new rt).fromArray(this.elements)}}const nt=new rt;var ot;function at(t,e,i,s){let r;switch(exports.EmitterMode.Random===t?e=Math.random():exports.EmitterMode.Burst===t&&s.isBursting&&(e=s.burstParticleIndex/s.burstParticleCount),r=i>0?Math.floor(e/i)*i:e,t){case exports.EmitterMode.Loop:r%=1;break;case exports.EmitterMode.PingPong:r=Math.abs(r%2-1)}return r}exports.EmitterMode=void 0,(ot=exports.EmitterMode||(exports.EmitterMode={}))[ot.Random=0]="Random",ot[ot.Loop=1]="Loop",ot[ot.PingPong=2]="PingPong",ot[ot.Burst=3]="Burst";class ht{constructor(t,e,i,s){this.p=[t,e,i,s]}genValue(t){const e=t*t,i=t*t*t,s=1-t,r=s*s,n=r*s;return this.p[0]*n+this.p[1]*r*t*3+this.p[2]*s*e*3+this.p[3]*i}derivativeCoefficients(t){const e=[];for(let i=t,s=i.length-1;s>0;s--){const t=[];for(let e=0;e<s;e++){const r=s*(i[e+1]-i[e]);t.push(r)}e.push(t),i=t}return e}getSlope(t){const e=this.derivativeCoefficients(this.p)[0],i=1-t,s=i*t*2,r=t*t;return i*i*e[0]+s*e[1]+r*e[2]}controlCurve(t,e){this.p[1]=t/3+this.p[0],this.p[2]=this.p[3]-e/3}hull(t){let e,i=this.p,s=[],r=0,n=0,o=0;const a=[];for(a[r++]=i[0],a[r++]=i[1],a[r++]=i[2],a[r++]=i[3];i.length>1;){for(s=[],n=0,o=i.length-1;n<o;n++)e=t*i[n]+(1-t)*i[n+1],a[r++]=e,s.push(e);i=s}return a}split(t){const e=this.hull(t);return{left:new ht(e[0],e[4],e[7],e[9]),right:new ht(e[9],e[8],e[6],e[3]),span:e}}clone(){return new ht(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(t){return new ht(t.p0,t.p1,t.p2,t.p3)}}const lt=t=>({r:t.x,g:t.y,b:t.z,a:t.w}),ct=t=>new st(t.r,t.g,t.b,t.a),ut=(t,e)=>{switch(e){case"Vector3":return new k(t.x,t.y,t.z);case"Vector4":return new st(t.x,t.y,t.z,t.w);case"Color":return new k(t.r,t.g,t.b);default:return t}},dt=(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 mt{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:lt(this.a),b:lt(this.b)}}static fromJSON(t){return new mt(ct(t.a),ct(t.b))}clone(){return new mt(this.a.clone(),this.b.clone())}}class pt{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:lt(this.a),b:lt(this.b)}}static fromJSON(t){return new pt(ct(t.a),ct(t.b))}clone(){return new pt(this.a.clone(),this.b.clone())}}class yt{constructor(t,e){this.subType=e,this.type="function",this.keys=t}findKey(t){let e=0,i=0,s=this.keys.length-1;for(;i+1<s;)if(e=Math.floor((i+s)/2),t<this.getStartX(e))s=e-1;else{if(!(t>this.getEndX(e)))return e;i=e+1}for(let e=i;e<=s;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[t+1][1]:1}genValue(t,e){const i=this.findKey(e);return"Number"===this.subType?-1===i?this.keys[0][0]:i+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:dt(t,this.subType),pos:e}))}}static fromJSON(t){return new yt(t.keys.map(e=>[ut(e.value,t.subType),e.pos]),t.subType)}clone(){return"Number"===this.subType?new yt(this.keys.map(([t,e])=>[t,e]),this.subType):new yt(this.keys.map(([t,e])=>[t.clone(),e]),this.subType)}}const ft=new k;class xt{constructor(t=[[new k(0,0,0),0],[new k(1,1,1),0]],e=[[1,0],[1,1]]){this.type="function",this.color=new yt(t,"Color"),this.alpha=new yt(e,"Number")}genColor(t,e,i){return this.color.genValue(ft,i),e.set(ft.x,ft.y,ft.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=>[pt.fromJSON(t.function).a,t.start]);return t.functions.length>0&&e.push([pt.fromJSON(t.functions[t.functions.length-1].function).b,1]),new xt(e.map(t=>[new k(t[0].x,t[0].y,t[0].z),t[1]]),e.map(t=>[t[0].w,t[1]]))}{const e=new xt;return e.alpha=yt.fromJSON(t.alpha),e.color=yt.fromJSON(t.color),e}}clone(){const t=new xt;return t.alpha=this.alpha.clone(),t.color=this.color.clone(),t}startGen(t){}}const gt=new st;class vt{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,gt,i),t&&void 0!==t[this.indexCount]?e.lerp(gt,t[this.indexCount]):e.lerp(gt,Math.random()),e}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(t){return new vt(xt.fromJSON(t.gradient1),xt.fromJSON(t.gradient2))}clone(){return new vt(this.gradient1.clone(),this.gradient2.clone())}}class St{constructor(t){this.color=t,this.type="value"}startGen(t){}genColor(t,e){return e.copy(this.color)}toJSON(){return{type:"ConstantColor",color:lt(this.color)}}static fromJSON(t){return new St(ct(t.color))}clone(){return new St(this.color.clone())}}function Mt(t){switch(t.type){case"ConstantColor":return St.fromJSON(t);case"ColorRange":return pt.fromJSON(t);case"RandomColor":return mt.fromJSON(t);case"Gradient":return xt.fromJSON(t);case"RandomColorBetweenGradient":return vt.fromJSON(t);default:return new St(new st(1,1,1,1))}}class wt{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 wt(t.value)}clone(){return new wt(this.value)}}class bt{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),J.lerp(this.a,this.b,t[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(t){return new bt(t.a,t.b)}clone(){return new bt(this.a,this.b)}}class _t{constructor(){this.functions=new Array}findFunction(t){let e=0,i=0,s=this.functions.length-1;for(;i+1<s;)if(e=Math.floor((i+s)/2),t<this.getStartX(e))s=e-1;else{if(!(t>this.getEndX(e)))return e;i=e+1}for(let e=i;e<=s;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<this.functions.length?this.functions[t+1][1]:1}setEndX(t,e){t+1<this.functions.length&&(this.functions[t+1][1]=e)}insertFunction(t,e){const i=this.findFunction(t);this.functions.splice(i+1,0,[e,t])}removeFunction(t){return this.functions.splice(t,1)[0][0]}getFunction(t){return this.functions[t][0]}setFunction(t,e){this.functions[t][0]=e}get numOfFunctions(){return this.functions.length}}class zt extends _t{constructor(t=[[new ht(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=t}genValue(t,e=0){const i=this.findFunction(e);return-1===i?0:this.functions[i][0].genValue((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toSVG(t,e){if(e<1)return"";let i=["M",0,this.functions[0][0].p[0]].join(" ");for(let s=1/e;s<=1;s+=1/e)i=[i,"L",s*t,this.genValue(void 0,s)].join(" ");return i}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([t,e])=>({function:t.toJSON(),start:e}))}}static fromJSON(t){return new zt(t.functions.map(t=>[ht.fromJSON(t.function),t.start]))}clone(){return new zt(this.functions.map(([t,e])=>[t.clone(),e]))}startGen(t){}}function Tt(t){switch(t.type){case"ConstantValue":return wt.fromJSON(t);case"IntervalValue":return bt.fromJSON(t);case"PiecewiseBezier":return zt.fromJSON(t);default:return new wt(0)}}class Ot{constructor(){this.indexCount=0,this.type="rotation"}startGen(t){let e,i,s,r,n,o;this.indexCount=t.length,t.push(new I);do{e=2*Math.random()-1,i=2*Math.random()-1,s=e*e+i*i}while(s>1);do{r=2*Math.random()-1,n=2*Math.random()-1,o=r*r+n*n}while(o>1);const a=Math.sqrt((1-s)/o);t[this.indexCount].set(e,i,a*r,a*n)}genValue(t,e,i,s){return-1===this.indexCount&&this.startGen(t),e.copy(t[this.indexCount]),e}toJSON(){return{type:"RandomQuat"}}static fromJSON(t){return new Ot}clone(){return new Ot}}class Pt{constructor(t,e){this.axis=t,this.angle=e,this.type="rotation"}startGen(t){this.angle.startGen(t)}genValue(t,e,i,s){return e.setFromAxisAngle(this.axis,this.angle.genValue(t,s)*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 Pt(new k(t.axis.x,t.axis.y,t.axis.z),Tt(t.angle))}clone(){return new Pt(this.axis.clone(),this.angle.clone())}}class Bt{constructor(t,e,i,s){this.angleX=t,this.angleY=e,this.angleZ=i,this.type="rotation",this.eular=new et(0,0,0,s)}startGen(t){this.angleX.startGen(t),this.angleY.startGen(t),this.angleZ.startGen(t)}genValue(t,e,i,s){return this.eular.set(this.angleX.genValue(t,s)*i,this.angleY.genValue(t,s)*i,this.angleZ.genValue(t,s)*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 Bt(Tt(t.angleX),Tt(t.angleY),Tt(t.angleZ),t.eulerOrder)}clone(){return new Bt(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Nt(t){switch(t.type){case"AxisAngle":return Pt.fromJSON(t);case"Euler":return Bt.fromJSON(t);case"RandomQuat":return Ot.fromJSON(t);default:return new Ot}}class Ct{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 Ct(Tt(t.x),Tt(t.y),Tt(t.z))}clone(){return new Ct(this.x,this.y,this.z)}}function Vt(t){return"Vector3Function"===t.type?Ct.fromJSON(t):new Ct(new wt(0),new wt(0),new wt(0))}function Ft(t){switch(t.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return Tt(t);case"AxisAngle":case"RandomQuat":case"Euler":return Nt(t);case"Vector3Function":return Vt(t);default:return new wt(0)}}class At{constructor(t={}){this.type="cone",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.angle=t.angle??Math.PI/6,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[]}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=J.lerp(1-this.thickness,1,Math.random()),r=i*this.arc,n=Math.sqrt(s),o=Math.sin(r),a=Math.cos(r);t.position.x=n*a,t.position.y=n*o,t.position.z=0;const h=this.angle*n;t.velocity.set(0,0,Math.cos(h)).addScaledVector(t.position,Math.sin(h)).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 At({radius:t.radius,arc:t.arc,thickness:t.thickness,angle:t.angle,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new At({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Et{constructor(t={}){this.type="circle",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[]}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=J.lerp(1-this.thickness,1,Math.random()),r=i*this.arc;t.position.x=Math.cos(r),t.position.y=Math.sin(r),t.position.z=0,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*s)}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 Et({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Et({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function Dt(t,e){return Math.floor(Math.random()*(e-t))+t}const Rt=new k(0,1,0),Jt=new k(0,0,0),It=new k(1,1,1),kt=new k(0,0,1);class Ut{constructor(t={}){this.type="donut",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.donutRadius=t.donutRadius??.2*this.radius,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=Math.random(),r=J.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,o=s*Math.PI*2,a=Math.sin(n),h=Math.cos(n);if(t.position.x=this.radius*h,t.position.y=this.radius*a,t.position.z=0,t.velocity.z=this.donutRadius*r*Math.sin(o),t.velocity.x=this.donutRadius*r*Math.cos(o)*h,t.velocity.y=this.donutRadius*r*Math.cos(o)*a,t.position.add(t.velocity),t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.velocity,Rt),t.rotation.setFromRotationMatrix(this._m1))}}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 Ut({radius:t.radius,arc:t.arc,thickness:t.thickness,donutRadius:t.donutRadius,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Ut({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Lt{constructor(){this.type="point",this._m1=new Q}update(t,e){}initialize(t){const e=Math.random(),i=Math.random(),s=e*Math.PI*2,r=Math.acos(2*i-1),n=Math.cbrt(Math.random()),o=Math.sin(s),a=Math.cos(s),h=Math.sin(r),l=Math.cos(r);if(t.velocity.x=n*h*a,t.velocity.y=n*h*o,t.velocity.z=n*l,t.velocity.multiplyScalar(t.startSpeed),t.position.setScalar(0),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.velocity,Rt),t.rotation.setFromRotationMatrix(this._m1))}}toJSON(){return{type:"point"}}static fromJSON(t){return new Lt}clone(){return new Lt}}class qt{constructor(t={}){this.type="sphere",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=Math.random(),r=J.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,o=Math.acos(2*s-1),a=Math.sin(n),h=Math.cos(n),l=Math.sin(o),c=Math.cos(o);if(t.position.x=l*h,t.position.y=l*a,t.position.z=c,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*r),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.position,Rt),t.rotation.setFromRotationMatrix(this._m1))}}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 qt({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new qt({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Gt{constructor(t={}){this.type="hemisphere",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=Math.random(),r=J.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,o=Math.acos(s),a=Math.sin(n),h=Math.cos(n),l=Math.sin(o),c=Math.cos(o);if(t.position.x=l*h,t.position.y=l*a,t.position.z=c,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*r),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.position,Rt),t.rotation.setFromRotationMatrix(this._m1))}}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 Gt({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Gt({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Qt{constructor(t={}){this.type="grid",this.width=t.width??1,this.height=t.height??1,this.column=t.column??10,this.row=t.row??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 Qt(t)}clone(){return new Qt({width:this.width,height:this.height,column:this.column,row:this.row})}update(t,e){}}class Xt{constructor(t={}){this.type="rectangle",this.currentValue=0,this.width=t.width??10,this.height=t.height??10,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e)*(2*(this.width+this.height));let s,r;i<this.width?(s=i-this.width/2,r=-this.height/2):i<this.width+this.height?(s=this.width/2,r=i-this.width-this.height/2):i<2*this.width+this.height?(s=this.width/2-(i-this.width-this.height),r=this.height/2):(s=-this.width/2,r=this.height/2-(i-2*this.width-this.height));const n=Math.random(),o=1-this.thickness*n;if(t.position.x=s*o,t.position.y=r*o,t.position.z=0,t.velocity.x=s,t.velocity.y=r,t.velocity.z=0,t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.velocity,Rt),t.rotation.setFromRotationMatrix(this._m1))}}toJSON(){return{type:"rectangle",width:this.width,height:this.height,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new Xt({width:t.width,height:t.height,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Xt({width:this.width,height:this.height,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}const Wt={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Et,loadJSON:Et.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:At,loadJSON:At.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Ut,loadJSON:Ut.fromJSON},point:{type:"point",params:[],constructor:Lt,loadJSON:Lt.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:qt,loadJSON:qt.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Gt,loadJSON:Gt.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Qt,loadJSON:Qt.fromJSON},rectangle:{type:"rectangle",params:[["width",["number"]],["height",["number"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Xt,loadJSON:Xt.fromJSON}};function jt(t,e){return Wt[t.type].loadJSON(t,e)}class Ht{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 Ht(Mt(t.color))}clone(){return new Ht(this.color.clone())}reset(){}}class Yt{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 Yt(Tt(t.angularVelocity))}frameUpdate(t){}clone(){return new Yt(this.angularVelocity.clone())}reset(){}}class Zt{constructor(t){this.angularVelocity=t,this.type="Rotation3DOverLife",this.tempQuat=new I,this.tempQuat2=new I}initialize(t){t.rotation instanceof I&&(t.angularVelocity=new I,this.angularVelocity.startGen(t.memory))}update(t,e){t.rotation instanceof I&&(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 Zt(Nt(t.angularVelocity))}frameUpdate(t){}clone(){return new Zt(this.angularVelocity.clone())}reset(){}}class Kt{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 k,this._tempScale=new k,this._tempQ=new I}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 Kt(Tt(t.x),Tt(t.y),Tt(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 Kt(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}const $t=new k(1,0,0),te=new k(0,1,0),ee=new k(0,0,1);class ie{constructor(t=new wt(0),e=new wt(0),i=new wt(0),s=new wt(0),r=new wt(0),n=new wt(0),o="local"){this.linearX=t,this.linearY=e,this.linearZ=i,this.orbitalX=s,this.orbitalY=r,this.orbitalZ=n,this.space=o,this.type="VelocityOverLife",this._temp=new k,this._tempEmitterPos=new k,this._tempQ=new I,this._tempQInv=new I,this._tempScale=new k(1,1,1),this._tempScaleInv=new k(1,1,1),this._tempRot=new I,this._tempAxis=new k}initialize(t,e){this.ps=e,this.linearX.startGen(t.memory),this.linearY.startGen(t.memory),this.linearZ.startGen(t.memory),this.orbitalX.startGen(t.memory),this.orbitalY.startGen(t.memory),this.orbitalZ.startGen(t.memory)}frameUpdate(t){this.ps&&(this.ps.emitter.matrixWorld.decompose(this._tempEmitterPos,this._tempQ,this._tempScale),this._tempQInv.copy(this._tempQ).invert(),this._tempScaleInv.set(1/this._tempScale.x,1/this._tempScale.y,1/this._tempScale.z))}update(t,e){const i=t.age/t.life;this._temp.set(this.linearX.genValue(t.memory,i),this.linearY.genValue(t.memory,i),this.linearZ.genValue(t.memory,i)),this.ps.worldSpace&&"local"===this.space?this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ):this.ps.worldSpace||"world"!==this.space||this._temp.multiply(this._tempScaleInv).applyQuaternion(this._tempQInv),t.position.addScaledVector(this._temp,e);const s=this.orbitalX.genValue(t.memory,i)*e,r=this.orbitalY.genValue(t.memory,i)*e,n=this.orbitalZ.genValue(t.memory,i)*e;if(0!==s||0!==r||0!==n){const e=this.ps.worldSpace;e&&t.position.sub(this._tempEmitterPos),this.orbit(t.position,$t,s,e),this.orbit(t.position,te,r,e),this.orbit(t.position,ee,n,e),e&&t.position.add(this._tempEmitterPos)}}orbit(t,e,i,s){0!==i&&(this._tempAxis.copy(e),s&&this._tempAxis.applyQuaternion(this._tempQ),this._tempRot.setFromAxisAngle(this._tempAxis,i),t.applyQuaternion(this._tempRot))}toJSON(){return{type:this.type,linearX:this.linearX.toJSON(),linearY:this.linearY.toJSON(),linearZ:this.linearZ.toJSON(),orbitalX:this.orbitalX.toJSON(),orbitalY:this.orbitalY.toJSON(),orbitalZ:this.orbitalZ.toJSON(),space:this.space}}static fromJSON(t){const e=t=>t?Tt(t):new wt(0);return new ie(e(t.linearX),e(t.linearY),e(t.linearZ),e(t.orbitalX),e(t.orbitalY),e(t.orbitalZ),"world"===t.space?"world":"local")}clone(){return new ie(this.linearX.clone(),this.linearY.clone(),this.linearZ.clone(),this.orbitalX.clone(),this.orbitalY.clone(),this.orbitalZ.clone(),this.space)}reset(){}}class se{constructor(t=new wt(1),e="initial"){this.multiplier=t,this.mode=e,this.type="InheritVelocity",this._temp=new k,this._tempPos=new k,this._tempQInv=new I,this._tempScaleInv=new k(1,1,1)}initialize(t,e){this.ps=e,this.multiplier.startGen(t.memory),"initial"===this.mode&&e.emitterVelocity&&(this._temp.copy(e.emitterVelocity),e.worldSpace||(this.decomposeInverse(e),this._temp.multiply(this._tempScaleInv).applyQuaternion(this._tempQInv)),t.velocity.addScaledVector(this._temp,this.multiplier.genValue(t.memory,0)))}frameUpdate(t){this.ps&&!this.ps.worldSpace&&this.decomposeInverse(this.ps)}update(t,e){"current"===this.mode&&this.ps.emitterVelocity&&(this._temp.copy(this.ps.emitterVelocity),this.ps.worldSpace||this._temp.multiply(this._tempScaleInv).applyQuaternion(this._tempQInv),t.position.addScaledVector(this._temp,this.multiplier.genValue(t.memory,t.age/t.life)*e))}decomposeInverse(t){t.emitter.matrixWorld.decompose(this._tempPos,this._tempQInv,this._tempScaleInv),this._tempQInv.invert(),this._tempScaleInv.set(1/this._tempScaleInv.x,1/this._tempScaleInv.y,1/this._tempScaleInv.z)}toJSON(){return{type:this.type,multiplier:this.multiplier.toJSON(),mode:this.mode}}static fromJSON(t){return new se(t.multiplier?Tt(t.multiplier):new wt(1),"current"===t.mode?"current":"initial")}clone(){return new se(this.multiplier.clone(),this.mode)}reset(){}}class re{initialize(t){this.size.startGen(t.memory)}constructor(t){this.size=t,this.type="SizeOverLife"}update(t){this.size instanceof Ct?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 re(Ft(t.size))}frameUpdate(t){}clone(){return new re(this.size.clone())}reset(){}}class ne{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 ne(Tt(t.speed))}frameUpdate(t){}clone(){return new ne(this.speed.clone())}reset(){}}class oe{constructor(t){this.frame=t,this.type="FrameOverLife"}initialize(t){this.frame.startGen(t.memory)}update(t,e){this.frame instanceof zt&&(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 oe(Tt(t.frame))}clone(){return new oe(this.frame.clone())}reset(){}}class ae{constructor(t,e=new k(0,1,0)){this.orbitSpeed=t,this.axis=e,this.type="OrbitOverLife",this.temp=new k,this.rotation=new I}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 ae(Tt(t.orbitSpeed),t.axis?new k(t.axis[0],t.axis[1],t.axis[2]):void 0)}clone(){return new ae(this.orbitSpeed.clone())}reset(){}}class he{constructor(t){this.data=t,this.next=null,this.prev=null}hasPrev(){return null!==this.prev}hasNext(){return null!==this.next}}class le{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 he(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 he(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 he(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 ce{constructor(){this.startSpeed=0,this.startColor=new st,this.startSize=new k(1,1,1),this.position=new k,this.velocity=new k,this.age=0,this.life=1,this.size=new k(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new st,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class ue{constructor(t,e,i){this.position=t,this.size=e,this.color=i}}class de{constructor(){this.startSpeed=0,this.startColor=new st,this.startSize=new k(1,1,1),this.position=new k,this.velocity=new k,this.age=0,this.life=1,this.size=new k(1,1,1),this.length=100,this.speedModifier=1,this.color=new st,this.previous=new le,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new ue(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 me{initialize(t){this.width.startGen(t.memory)}constructor(t){this.width=t,this.type="WidthOverLength"}update(t){if(t instanceof de){const e=t.previous.values();for(let i=0;i<t.previous.length;i++){e.next().value.size=this.width.genValue(t.memory,(t.previous.length-i)/t.length)}}}frameUpdate(t){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(t){return new me(Tt(t.width))}clone(){return new me(this.width.clone())}reset(){}}class pe{constructor(t,e){this.direction=t,this.magnitude=e,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(t){}update(t,e){t.velocity.addScaledVector(this.direction,this.magnitudeValue*e)}frameUpdate(t){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(t){return new pe(new k(t.direction[0],t.direction[1],t.direction[2]),Tt(t.magnitude??t.force))}clone(){return new pe(this.direction.clone(),this.magnitude.clone())}reset(){}}class ye{constructor(t,e){this.center=t,this.magnitude=e,this.type="GravityForce",this.temp=new k}initialize(t){}update(t,e){this.temp.copy(this.center).sub(t.position).normalize(),t.velocity.addScaledVector(this.temp,this.magnitude/t.position.distanceToSquared(this.center)*e)}frameUpdate(t){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(t){return new ye(new k(t.center[0],t.center[1],t.center[2]),t.magnitude)}clone(){return new ye(this.center.clone(),this.magnitude)}reset(){}}class fe{constructor(t){this.angle=t,this.type="ChangeEmitDirection",this._temp=new k,this._q=new I,this.memory={data:[],dataCount:0}}initialize(t){const e=t.velocity.length();0!=e&&(t.velocity.normalize(),0===t.velocity.x&&0===t.velocity.y?this._temp.set(0,t.velocity.z,0):this._temp.set(-t.velocity.y,t.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(t.velocity),t.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),t.velocity.applyQuaternion(this._q),t.velocity.setLength(e))}update(t,e){}frameUpdate(t){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(t){return new fe(Tt(t.angle))}clone(){return new fe(this.angle)}reset(){}}var xe;exports.SubParticleEmitMode=void 0,(xe=exports.SubParticleEmitMode||(exports.SubParticleEmitMode={}))[xe.Death=0]="Death",xe[xe.Birth=1]="Birth",xe[xe.Frame=2]="Frame";class ge{constructor(t,e,i,s=exports.SubParticleEmitMode.Frame,r=1){this.particleSystem=t,this.useVelocityAsBasis=e,this.subParticleSystem=i,this.mode=s,this.emitProbability=r,this.type="EmitSubParticleSystem",this.q_=new I,this.v_=new k,this.v2_=new k,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(t){}update(t,e){(this.mode===exports.SubParticleEmitMode.Frame||this.mode===exports.SubParticleEmitMode.Birth&&0===t.age||this.mode===exports.SubParticleEmitMode.Death&&t.age+e>=t.life)&&this.emit(t,e)}emit(t,e){if(!this.subParticleSystem)return;if(Math.random()>this.emitProbability)return;const i=new Q;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.subEmissions.length;e++)if(this.subEmissions[e].time>=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<i.particle.life?this.setMatrixFromParticle(i.matrix,i.particle):i.particle=void 0,this.subParticleSystem.system.emit(t,i,i.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(t,e){return new ge(e,t.useVelocityAsBasis,t.subParticleSystem,t.mode,t.emitProbability)}clone(){return new ge(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(t,e){let i;if(void 0===e.rotation||this.useVelocityAsBasis)if(0!==e.velocity.x||0!==e.velocity.y||1!==e.velocity.z&&0!==e.velocity.z){this.v_.copy(kt).cross(e.velocity),this.v2_.copy(e.velocity).cross(this.v_);const i=this.v_.length(),s=this.v2_.length();t.set(this.v_.x/i,this.v2_.x/s,e.velocity.x,e.position.x,this.v_.y/i,this.v2_.y/s,e.velocity.y,e.position.y,this.v_.z/i,this.v2_.z/s,e.velocity.z,e.position.z,0,0,0,1)}else t.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1);else e.rotation instanceof I?i=e.rotation:(this.q_.setFromAxisAngle(kt,e.rotation),i=this.q_),t.compose(e.position,i,It);this.particleSystem.worldSpace||t.multiplyMatrices(this.particleSystem.emitter.matrixWorld,t)}}const ve=.5*(Math.sqrt(3)-1),Se=(3-Math.sqrt(3))/6,Me=1/3,we=1/6,be=(Math.sqrt(5)-1)/4,_e=(5-Math.sqrt(5))/20,ze=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),Te=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);class Oe{constructor(t=Math.random){const e="function"==typeof t?t:function(t){let e=0,i=0,s=0,r=1;const n=function(){let t=4022871197;return function(e){e=e.toString();for(let i=0;i<e.length;i++){t+=e.charCodeAt(i);let s=.02519603282416938*t;t=s>>>0,s-=t,s*=t,t=s>>>0,s-=t,t+=4294967296*s}return 2.3283064365386963e-10*(t>>>0)}}();e=n(" "),i=n(" "),s=n(" "),e-=n(t),e<0&&(e+=1);i-=n(t),i<0&&(i+=1);s-=n(t),s<0&&(s+=1);return function(){const t=2091639*e+2.3283064365386963e-10*r;return e=i,i=s,s=t-(r=0|t)}}(t);this.p=function(t){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let i=0;i<255;i++){const s=i+~~(t()*(256-i)),r=e[i];e[i]=e[s],e[s]=r}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,s=this.perm;let r=0,n=0,o=0;const a=(t+e)*ve,h=Math.floor(t+a),l=Math.floor(e+a),c=(h+l)*Se,u=t-(h-c),d=e-(l-c);let m,p;u>d?(m=1,p=0):(m=0,p=1);const y=u-m+Se,f=d-p+Se,x=u-1+2*Se,g=d-1+2*Se,v=255&h,S=255&l;let M=.5-u*u-d*d;if(M>=0){const t=3*i[v+s[S]];M*=M,r=M*M*(ze[t]*u+ze[t+1]*d)}let w=.5-y*y-f*f;if(w>=0){const t=3*i[v+m+s[S+p]];w*=w,n=w*w*(ze[t]*y+ze[t+1]*f)}let b=.5-x*x-g*g;if(b>=0){const t=3*i[v+1+s[S+1]];b*=b,o=b*b*(ze[t]*x+ze[t+1]*g)}return 70*(r+n+o)}noise3D(t,e,i){const s=this.permMod12,r=this.perm;let n,o,a,h;const l=(t+e+i)*Me,c=Math.floor(t+l),u=Math.floor(e+l),d=Math.floor(i+l),m=(c+u+d)*we,p=t-(c-m),y=e-(u-m),f=i-(d-m);let x,g,v,S,M,w;p>=y?y>=f?(x=1,g=0,v=0,S=1,M=1,w=0):p>=f?(x=1,g=0,v=0,S=1,M=0,w=1):(x=0,g=0,v=1,S=1,M=0,w=1):y<f?(x=0,g=0,v=1,S=0,M=1,w=1):p<f?(x=0,g=1,v=0,S=0,M=1,w=1):(x=0,g=1,v=0,S=1,M=1,w=0);const b=p-x+we,_=y-g+we,z=f-v+we,T=p-S+2*we,O=y-M+2*we,P=f-w+2*we,B=p-1+.5,N=y-1+.5,C=f-1+.5,V=255&c,F=255&u,A=255&d;let E=.6-p*p-y*y-f*f;if(E<0)n=0;else{const t=3*s[V+r[F+r[A]]];E*=E,n=E*E*(ze[t]*p+ze[t+1]*y+ze[t+2]*f)}let D=.6-b*b-_*_-z*z;if(D<0)o=0;else{const t=3*s[V+x+r[F+g+r[A+v]]];D*=D,o=D*D*(ze[t]*b+ze[t+1]*_+ze[t+2]*z)}let R=.6-T*T-O*O-P*P;if(R<0)a=0;else{const t=3*s[V+S+r[F+M+r[A+w]]];R*=R,a=R*R*(ze[t]*T+ze[t+1]*O+ze[t+2]*P)}let J=.6-B*B-N*N-C*C;if(J<0)h=0;else{const t=3*s[V+1+r[F+1+r[A+1]]];J*=J,h=J*J*(ze[t]*B+ze[t+1]*N+ze[t+2]*C)}return 32*(n+o+a+h)}noise4D(t,e,i,s){const r=this.perm;let n,o,a,h,l;const c=(t+e+i+s)*be,u=Math.floor(t+c),d=Math.floor(e+c),m=Math.floor(i+c),p=Math.floor(s+c),y=(u+d+m+p)*_e,f=t-(u-y),x=e-(d-y),g=i-(m-y),v=s-(p-y);let S=0,M=0,w=0,b=0;f>x?S++:M++,f>g?S++:w++,f>v?S++:b++,x>g?M++:w++,x>v?M++:b++,g>v?w++:b++;const _=S>=3?1:0,z=M>=3?1:0,T=w>=3?1:0,O=b>=3?1:0,P=S>=2?1:0,B=M>=2?1:0,N=w>=2?1:0,C=b>=2?1:0,V=S>=1?1:0,F=M>=1?1:0,A=w>=1?1:0,E=b>=1?1:0,D=f-_+_e,R=x-z+_e,J=g-T+_e,I=v-O+_e,k=f-P+2*_e,U=x-B+2*_e,L=g-N+2*_e,q=v-C+2*_e,G=f-V+3*_e,Q=x-F+3*_e,X=g-A+3*_e,W=v-E+3*_e,j=f-1+4*_e,H=x-1+4*_e,Y=g-1+4*_e,Z=v-1+4*_e,K=255&u,$=255&d,tt=255&m,et=255&p;let it=.6-f*f-x*x-g*g-v*v;if(it<0)n=0;else{const t=r[K+r[$+r[tt+r[et]]]]%32*4;it*=it,n=it*it*(Te[t]*f+Te[t+1]*x+Te[t+2]*g+Te[t+3]*v)}let st=.6-D*D-R*R-J*J-I*I;if(st<0)o=0;else{const t=r[K+_+r[$+z+r[tt+T+r[et+O]]]]%32*4;st*=st,o=st*st*(Te[t]*D+Te[t+1]*R+Te[t+2]*J+Te[t+3]*I)}let rt=.6-k*k-U*U-L*L-q*q;if(rt<0)a=0;else{const t=r[K+P+r[$+B+r[tt+N+r[et+C]]]]%32*4;rt*=rt,a=rt*rt*(Te[t]*k+Te[t+1]*U+Te[t+2]*L+Te[t+3]*q)}let nt=.6-G*G-Q*Q-X*X-W*W;if(nt<0)h=0;else{const t=r[K+V+r[$+F+r[tt+A+r[et+E]]]]%32*4;nt*=nt,h=nt*nt*(Te[t]*G+Te[t+1]*Q+Te[t+2]*X+Te[t+3]*W)}let ot=.6-j*j-H*H-Y*Y-Z*Z;if(ot<0)l=0;else{const t=r[K+1+r[$+1+r[tt+1+r[et+1]]]]%32*4;ot*=ot,l=ot*ot*(Te[t]*j+Te[t+1]*H+Te[t+2]*Y+Te[t+3]*Z)}return 27*(n+o+a+h+l)}}class Pe{constructor(t,e,i,s){this.scale=t,this.octaves=e,this.velocityMultiplier=i,this.timeScale=s,this.type="TurbulenceField",this.generator=new Oe,this.timeOffset=new k,this.temp=new k,this.temp2=new k,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,s=t.position.y/this.scale.y,r=t.position.z/this.scale.z;this.temp.set(0,0,0);let n=1;for(let t=0;t<this.octaves;t++)this.temp2.set(this.generator.noise4D(i*n,s*n,r*n,this.timeOffset.x*n)/n,this.generator.noise4D(i*n,s*n,r*n,this.timeOffset.y*n)/n,this.generator.noise4D(i*n,s*n,r*n,this.timeOffset.z*n)/n),this.temp.add(this.temp2),n*=2;this.temp.multiply(this.velocityMultiplier),t.velocity.addScaledVector(this.temp,e)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(t){this.timeOffset.x+=t*this.timeScale.x,this.timeOffset.y+=t*this.timeScale.y,this.timeOffset.z+=t*this.timeScale.z}static fromJSON(t){return new Pe(new k(t.scale[0],t.scale[1],t.scale[2]),t.octaves,new k(t.velocityMultiplier[0],t.velocityMultiplier[1],t.velocityMultiplier[2]),new k(t.timeScale[0],t.timeScale[1],t.timeScale[2]))}clone(){return new Pe(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const Be=[],Ne=new k,Ce=new I;class Ve{constructor(t,e,i=new wt(1),s=new wt(0)){if(this.frequency=t,this.power=e,this.positionAmount=i,this.rotationAmount=s,this.type="Noise",this.duration=0,0===Be.length)for(let t=0;t<100;t++)Be.push(new Oe)}initialize(t){t.lastPosNoise=new k,"number"==typeof t.rotation?t.lastRotNoise=0:t.lastRotNoise=new I,t.generatorIndex=[Dt(0,100),Dt(0,100),Dt(0,100),Dt(0,100)],this.positionAmount.startGen(t.memory),this.rotationAmount.startGen(t.memory),this.frequency.startGen(t.memory),this.power.startGen(t.memory)}update(t,e){let i=this.frequency.genValue(t.memory,t.age/t.life),s=this.power.genValue(t.memory,t.age/t.life),r=this.positionAmount.genValue(t.memory,t.age/t.life),n=this.rotationAmount.genValue(t.memory,t.age/t.life);r>0&&void 0!==t.lastPosNoise&&(t.position.sub(t.lastPosNoise),Ne.set(Be[t.generatorIndex[0]].noise2D(0,t.age*i)*s*r,Be[t.generatorIndex[1]].noise2D(0,t.age*i)*s*r,Be[t.generatorIndex[2]].noise2D(0,t.age*i)*s*r),t.position.add(Ne),t.lastPosNoise.copy(Ne)),n>0&&void 0!==t.lastRotNoise&&("number"==typeof t.rotation?(t.rotation-=t.lastRotNoise,t.rotation+=Be[t.generatorIndex[3]].noise2D(0,t.age*i)*Math.PI*s*n):(t.lastRotNoise.invert(),t.rotation.multiply(t.lastRotNoise),Ce.set(Be[t.generatorIndex[0]].noise2D(0,t.age*i)*s*n,Be[t.generatorIndex[1]].noise2D(0,t.age*i)*s*n,Be[t.generatorIndex[2]].noise2D(0,t.age*i)*s*n,Be[t.generatorIndex[3]].noise2D(0,t.age*i)*s*n).normalize(),t.rotation.multiply(Ce),t.lastRotNoise.copy(Ce)))}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 Ve(Tt(t.frequency),Tt(t.power),Tt(t.positionAmount),Tt(t.rotationAmount))}clone(){return new Ve(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class Fe{constructor(t=0,e=0,i=new k){this.scaleX=t,this.scaleY=e,this.position=i,this.locations=[]}transform(t,e){t.x=this.locations[e%this.locations.length].x*this.scaleX+this.position.x,t.y=this.locations[e%this.locations.length].y*this.scaleY+this.position.y,t.z=this.position.z}static fromJSON(t){const e=new Fe(t.scaleX,t.scaleY,new k(t.position[0],t.position[1],t.position[2]));return e.locations=t.locations.map(t=>new it(t.x,t.y)),e}clone(){const t=new Fe(this.scaleX,this.scaleY,this.position.clone());return t.locations=this.locations.map(t=>t.clone()),t}toJSON(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(t=>({x:t.x,y:t.y}))}}fromImage(t,e){const i=document.createElement("canvas");i.width=t.width,i.height=t.height;const s=i.getContext("2d");if(!s)return;s.drawImage(t,0,0);const r=s.getImageData(0,0,i.width,i.height,{colorSpace:"srgb"});i.remove(),this.locations.length=0;for(let t=0;t<r.height;t++)for(let i=0;i<r.width;i++)r.data[4*(t*r.width+i)+3]>e&&this.locations.push(new it(i,r.height-t))}}function Ae(t){return"TextureSequencer"===t.type?Fe.fromJSON(t):new Fe}class Ee{constructor(t){this.type="ApplySequences",this.sequencers=[],this.time=0,this.index=0,this.pCount=0,this.tempV=new k,this.delay=t}initialize(t){t.id=this.pCount,t.dst=new k,t.begin=new k,t.inMotion=!1,this.pCount++}reset(){this.time=0,this.index=0,this.pCount=0}update(t,e){const i=this.sequencers[this.index],s=t.id*this.delay;this.time>=i[0].a+s&&this.time<=i[0].b+s?(t.inMotion||(t.inMotion=!0,t.begin.copy(t.position),i[1].transform(t.dst,t.id)),t.position.lerpVectors(t.begin,t.dst,Ee.BEZIER.genValue((this.time-i[0].a-s)/(i[0].b-i[0].a)))):this.time>i[0].b+s&&(t.inMotion=!1)}frameUpdate(t){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=t}appendSequencer(t,e){this.sequencers.push([t,e])}toJSON(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(([t,e])=>({range:t.toJSON(),sequencer:e.toJSON()}))}}static fromJSON(t){const e=new Ee(t.delay);return t.sequencers.forEach(t=>{e.sequencers.push([Tt(t.range),Ae(t.sequencer)])}),e}clone(){const t=new Ee(this.delay);return t.sequencers=this.sequencers.map(t=>[t[0].clone(),t[1].clone()]),t}}let De;function Re(){return De}Ee.BEZIER=new ht(0,0,1,1);class Je{constructor(t,e){this.resolver=t,this.bounce=e,this.type="ApplyCollision",this.tempV=new k}initialize(t){}update(t,e){this.resolver&&this.resolver.resolve(t.position,this.tempV)&&t.velocity.reflect(this.tempV).multiplyScalar(this.bounce)}frameUpdate(t){}toJSON(){return{type:this.type,bounce:this.bounce}}static fromJSON(t){return new Je(Re(),t.bounce)}clone(){return new Je(this.resolver,this.bounce)}reset(){}}class Ie{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 Ie(Mt(t.color),bt.fromJSON(t.speedRange))}clone(){return new Ie(this.color.clone(),this.speedRange.clone())}reset(){}}class ke{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 Ct?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 ke(Ft(t.size),bt.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new ke(this.size.clone(),this.speedRange.clone())}reset(){}}class Ue{constructor(t,e){this.angularVelocity=t,this.speedRange=e,this.type="RotationBySpeed",this.tempQuat=new I}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 Ue(Tt(t.angularVelocity),bt.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new Ue(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Le{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(),s=this.speed.genValue(t.memory,t.age/t.life);if(i>s){const r=(i-s)/i;t.velocity.multiplyScalar(1-r*this.dampen*e*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(t){return new Le(Tt(t.speed),t.dampen)}frameUpdate(t){}clone(){return new Le(this.speed.clone(),this.dampen)}reset(){}}const qe={ApplyForce:{type:"ApplyForce",constructor:pe,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:pe.fromJSON},Noise:{type:"Noise",constructor:Ve,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Ve.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Pe,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Pe.fromJSON},GravityForce:{type:"GravityForce",constructor:ye,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:ye.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Ht,params:[["color",["colorFunc"]]],loadJSON:Ht.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Yt,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Yt.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Zt,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Zt.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:re,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:re.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:Ie,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:Ie.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Ue,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Ue.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:ke,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:ke.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:ne,params:[["speed",["value","valueFunc"]]],loadJSON:ne.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:oe,params:[["frame",["value","valueFunc"]]],loadJSON:oe.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Kt,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Kt.fromJSON},VelocityOverLife:{type:"VelocityOverLife",constructor:ie,params:[["linearX",["value","valueFunc"]],["linearY",["value","valueFunc"]],["linearZ",["value","valueFunc"]],["orbitalX",["value","valueFunc"]],["orbitalY",["value","valueFunc"]],["orbitalZ",["value","valueFunc"]],["space",["string"]]],loadJSON:ie.fromJSON},InheritVelocity:{type:"InheritVelocity",constructor:se,params:[["multiplier",["value","valueFunc"]],["mode",["string"]]],loadJSON:se.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:ae,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:ae.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:me,params:[["width",["value","valueFunc"]]],loadJSON:me.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:fe,params:[["angle",["value"]]],loadJSON:fe.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:ge,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:ge.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Le,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Le.fromJSON},ApplyCollision:{type:"ApplyCollision",constructor:Je,params:[["bounce",["number"]]],loadJSON:Je.fromJSON}};function Ge(t,e){return qe[t.type]?qe[t.type].loadJSON(t,e):null}const Qe=[];function Xe(t){if(!Qe.find(e=>e.id===t.id)){t.initialize();for(const e of t.emitterShapes)Wt[e.type]||(Wt[e.type]=e);for(const e of t.behaviors)qe[e.type]||(qe[e.type]=e)}}class We{get mesh(){return this._mesh}set mesh(e){if(this._mesh=e,!e)return;const i=e.getVerticesData(t.VertexBuffer.PositionKind),s=e.getIndices();if(!i||!s)return;this._positions=new Float32Array(i),this._indices=new Int32Array(s),this._triangleIndexToArea.length=0;let r=0;const n=s.length/3;this._triangleIndexToArea.push(0);const o=new k,a=new k,h=new k;for(let t=0;t<n;t++){const e=s[3*t],n=s[3*t+1],l=s[3*t+2];o.set(i[3*e],i[3*e+1],i[3*e+2]),a.set(i[3*n],i[3*n+1],i[3*n+2]),h.set(i[3*l],i[3*l+1],i[3*l+2]),a.sub(o),h.sub(o);const c=new k;c.crossVectors(a,h),r+=.5*c.length(),this._triangleIndexToArea.push(r)}}constructor(t,e){this.type="mesh_surface",this._triangleIndexToArea=[],this._meshReferenceId=e,t&&(this.mesh=t)}initialize(t){if(!this._positions||!this._indices)return t.position.set(0,0,0),void t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);const e=this._triangleIndexToArea.length-1;let i=0,s=e;const r=Math.random()*this._triangleIndexToArea[e];for(;i+1<s;){const t=Math.floor((i+s)/2);r<this._triangleIndexToArea[t]?s=t:i=t}let n=Math.random(),o=Math.random();n+o>1&&(n=1-n,o=1-o);const a=this._indices[3*i],h=this._indices[3*i+1],l=this._indices[3*i+2],c=this._positions[3*a],u=this._positions[3*a+1],d=this._positions[3*a+2],m=this._positions[3*h]-c,p=this._positions[3*h+1]-u,y=this._positions[3*h+2]-d,f=this._positions[3*l]-c,x=this._positions[3*l+1]-u,g=this._positions[3*l+2]-d;t.position.set(c+m*n+f*o,u+p*n+x*o,d+y*n+g*o);const v=p*g-y*x,S=y*f-m*g,M=m*x-p*f,w=Math.sqrt(v*v+S*S+M*M)||1;t.velocity.set(v/w,S/w,M/w).multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._mesh?this._mesh.uniqueId?.toString():this._meshReferenceId??""}}static fromJSON(t){return new We(void 0,t?.mesh)}clone(){return new We(this._mesh,this._meshReferenceId)}update(t,e){}}const je={id:"babylon.quarks",initialize:()=>{},emitterShapes:[{type:"mesh_surface",params:[["mesh",["mesh"]]],constructor:We,loadJSON:t=>We.fromJSON(t)}],behaviors:[]};const He={};let Ye=!1;function Ze(){Ye||(He.tile_pars_vertex="\n#ifdef UV_TILE\n attribute float uvTile;\n uniform vec2 tileCount;\n\n mat3 makeTileTransform(float tileIndex) {\n float col = mod(tileIndex, tileCount.x);\n float row = (tileCount.y - floor(tileIndex / tileCount.x) - 1.0);\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 }\n#else\n mat3 makeTileTransform(float tileIndex) {\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)\n varying vec2 vUv;\n #ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n #endif\n#endif\n",He.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)\n vUv = (tileTransform * vec3(uv, 1.0)).xy;\n #if defined(TILE_BLEND) && defined(UV_TILE)\n vUvNext = (nextTileTransform * vec3(uv, 1.0)).xy;\n #endif\n#endif\n",He.tile_pars_fragment="\n#if defined(USE_UV)\n varying vec2 vUv;\n #ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n #endif\n#endif\n",He.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",He.soft_pars_vertex="\n#ifdef SOFT_PARTICLES\n varying vec4 projPosition;\n varying float linearDepth;\n#endif\n",He.soft_vertex="\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n",He.soft_pars_fragment="\n#ifdef SOFT_PARTICLES\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 return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n#endif\n",He.soft_fragment="\n#ifdef SOFT_PARTICLES\n\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float viewDepth = linearize_depth(readDepth);\n float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));\n\n gl_FragColor *= softParticlesFade;\n#endif\n",Ye=!0)}var Ke,$e="\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float c = cos(rotation);\n float s = sin(rotation);\n\n vec2 alignedPosition = position.xy * size.xy;\n vec2 rotatedPosition;\n rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;\n rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;\n\n#ifdef HORIZONTAL\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.x += rotatedPosition.x;\n mvPosition.z -= rotatedPosition.y;\n mvPosition = view * mvPosition;\n#elif defined(VERTICAL)\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.y += rotatedPosition.y;\n mvPosition = view * mvPosition;\n mvPosition.x += rotatedPosition.x;\n#else\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n mvPosition.xy += rotatedPosition;\n#endif\n\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n",ti="\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_COLOR_AS_ALPHA\n baseColor.a *= (baseColor.r + baseColor.g + baseColor.b) / 3.0;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n gl_FragColor = baseColor;\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n",ei="\nattribute vec3 position;\nattribute vec2 uv;\nattribute vec3 normal;\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute vec4 rotation;\nattribute float uvTile;\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\nvarying vec3 vWorldPos;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 qVec = q.xyz;\n float qW = q.w;\n vec3 t = 2.0 * cross(qVec, v);\n return v + qW * t + cross(qVec, t);\n}\n\nvoid main() {\n vec3 scaledPosition = position * size;\n vec3 rotatedPosition = applyQuaternion(scaledPosition, rotation);\n vec3 rotatedNormal = normalize(applyQuaternion(normal, rotation));\n vec3 localPos = rotatedPosition + offset;\n\n vec4 worldPos = world * vec4(localPos, 1.0);\n vec4 viewPos = view * worldPos;\n gl_Position = projection * viewPos;\n\n vWorldPos = worldPos.xyz;\n vNormal = normalize((world * vec4(rotatedNormal, 0.0)).xyz);\n\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -viewPos.z;\n#endif\n\n#ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n#else\n vUV = uv;\n#endif\n\n vColor = color;\n}\n",ii="\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\n\nuniform vec3 lightDirection;\nuniform vec3 lightColor;\nuniform vec3 ambientColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n vec3 N = normalize(vNormal);\n vec3 L = normalize(-lightDirection);\n float NdotL = max(dot(N, L), 0.0);\n vec3 litColor = ambientColor + lightColor * NdotL;\n\n gl_FragColor = vec4(baseColor.rgb * litColor, baseColor.a);\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n",si="\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\nattribute vec4 velocity;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform float speedFactor;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n vec3 viewVelocity = mat3(view * world) * velocity.xyz;\n float vlength = length(viewVelocity);\n // Stretch direction is the velocity direction; only a genuinely motionless particle has none.\n // Deriving it via normalize keeps the stretch aligned even when the speed contribution is ~0\n // (e.g. speedFactor 0), instead of collapsing the whole burst onto a fixed screen axis.\n vec3 vdir = vlength > 0.000001 ? viewVelocity / vlength : vec3(0.0, 0.0, 1.0);\n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, vdir)) * avgSize;\n // Equivalent to viewVelocity * (1.0 + lengthFactor / vlength) for moving particles, but the\n // size-based term (vdir * lengthFactor) survives when the velocity contribution vanishes.\n mvPosition.xyz -= (position.x + 0.5) * (viewVelocity + vdir * lengthFactor) * avgSize;\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n",ri="\nattribute vec3 position;\nattribute vec3 previous;\nattribute vec3 next;\nattribute float side;\nattribute float width;\nattribute vec2 uv;\nattribute vec4 color;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform float lineWidth;\nuniform vec2 resolution;\nuniform float sizeAttenuation;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 fix(vec4 i, float aspect) {\n vec2 res = i.xy / i.w;\n res.x *= aspect;\n return res;\n}\n\nvoid main() {\n float aspect = resolution.x / resolution.y;\n vec4 finalPosition = projection * view * vec4(position, 1.0);\n vec4 prevPos = projection * view * vec4(previous, 1.0);\n vec4 nextPos = projection * view * vec4(next, 1.0);\n\n vec2 currentP = fix(finalPosition, aspect);\n vec2 prevP = fix(prevPos, aspect);\n vec2 nextP = fix(nextPos, aspect);\n\n float w = lineWidth * width;\n vec2 dir;\n if (distance(nextP, currentP) < 0.0001) {\n dir = normalize(currentP - prevP);\n } else if (distance(prevP, currentP) < 0.0001) {\n dir = normalize(nextP - currentP);\n } else {\n vec2 dir1 = normalize(currentP - prevP);\n vec2 dir2 = normalize(nextP - currentP);\n dir = normalize(dir1 + dir2);\n }\n vec4 normal = vec4(-dir.y, dir.x, 0.0, 1.0);\n normal.xy *= 0.5 * w;\n normal *= projection;\n if (sizeAttenuation == 0.0) {\n normal.xy *= finalPosition.w;\n normal.xy /= (vec4(resolution, 0.0, 1.0) * projection).xy;\n }\n finalPosition.xy += normal.xy * side;\n gl_Position = finalPosition;\n vUV = uv;\n vColor = color;\n}\n",ni="\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n baseColor *= texColor;\n#endif\n\n if (baseColor.a < 0.01) discard;\n\n gl_FragColor = baseColor;\n}\n";exports.RenderMode=void 0,(Ke=exports.RenderMode||(exports.RenderMode={}))[Ke.BillBoard=0]="BillBoard",Ke[Ke.StretchedBillBoard=1]="StretchedBillBoard",Ke[Ke.Mesh=2]="Mesh",Ke[Ke.Trail=3]="Trail",Ke[Ke.HorizontalBillBoard=4]="HorizontalBillBoard",Ke[Ke.VerticalBillBoard=5]="VerticalBillBoard";class oi{constructor(t,e){this.scene=e,this.maxParticles=1e3,this.systems=new Set,this.settings={instancingGeometry:t.instancingGeometry,instancingIndices:t.instancingIndices,instancingUVs:t.instancingUVs,instancingNormals:t.instancingNormals,renderMode:t.renderMode,renderOrder:t.renderOrder,uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softNearFade:t.softNearFade,softFarFade:t.softFarFade,materialBlendMode:t.materialBlendMode,materialTransparent:t.materialTransparent,materialDepthTest:t.materialDepthTest,materialDepthWrite:t.materialDepthWrite,materialAlphaTest:t.materialAlphaTest,texture:t.texture,layerMask:t.layerMask},this.mesh=new i.Mesh("vfxBatch",e),this.mesh.alwaysSelectAsActiveMesh=!0}addSystem(t){this.systems.add(t)}removeSystem(t){this.systems.delete(t)}getVisibleSystems(){const t=[];for(const e of this.systems)e.emitter.visible&&t.push(e);return t}applyDepthTexture(t){const e=this.mesh.material;e&&e instanceof s.ShaderMaterial&&e.setTexture("depthTexture",t)}dispose(){this.mesh.dispose()}}class ai extends oi{constructor(t,e){super(t,e),this.vector_=new k,this.vector2_=new k,this.vector3_=new k,this.quaternion_=new I,this.quaternion2_=new I,this.quaternion3_=new I,this.rotationMat_=new rt,this.rotationMat2_=new rt,this.lastStretchedSpeedFactor=Number.NaN,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.mesh.dispose(),this.mesh=new i.Mesh("spriteBatch",this.scene),this.mesh.alwaysSelectAsActiveMesh=!0;const t=new r.VertexData;t.positions=this.settings.instancingGeometry,t.indices=this.settings.instancingIndices,this.settings.instancingUVs&&(t.uvs=this.settings.instancingUVs),this.settings.instancingNormals&&(t.normals=this.settings.instancingNormals),t.applyToMesh(this.mesh,!1),this.buildExpandableBuffers()}buildExpandableBuffers(){const e=this.scene.getEngine();this.offsetBuffer=new Float32Array(3*this.maxParticles),this.offsetVB=new t.VertexBuffer(e,this.offsetBuffer,"offset",!0,!1,3,!0),this.mesh.setVerticesBuffer(this.offsetVB),this.colorBuffer=new Float32Array(4*this.maxParticles),this.colorVB=new t.VertexBuffer(e,this.colorBuffer,"color",!0,!1,4,!0),this.mesh.setVerticesBuffer(this.colorVB),this.sizeBuffer=new Float32Array(3*this.maxParticles),this.sizeVB=new t.VertexBuffer(e,this.sizeBuffer,"size",!0,!1,3,!0),this.mesh.setVerticesBuffer(this.sizeVB),this.uvTileBuffer=new Float32Array(this.maxParticles),this.uvTileVB=new t.VertexBuffer(e,this.uvTileBuffer,"uvTile",!0,!1,1,!0),this.mesh.setVerticesBuffer(this.uvTileVB),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new Float32Array(4*this.maxParticles),this.rotationVB=new t.VertexBuffer(e,this.rotationBuffer,"rotation",!0,!1,4,!0)):(this.rotationBuffer=new Float32Array(this.maxParticles),this.rotationVB=new t.VertexBuffer(e,this.rotationBuffer,"rotation",!0,!1,1,!0)),this.mesh.setVerticesBuffer(this.rotationVB),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new Float32Array(4*this.maxParticles),this.velocityVB=new t.VertexBuffer(e,this.velocityBuffer,"velocity",!0,!1,4,!0),this.mesh.setVerticesBuffer(this.velocityVB)),this.mesh.forcedInstanceCount=0,this.mesh.doNotSyncBoundingInfo=!0}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.buildExpandableBuffers()}rebuildMaterial(){const t=`quarksParticle_${this.settings.renderMode}_${Date.now()}`;let e,i;this.lastStretchedSpeedFactor=Number.NaN;const r=[];this.settings.renderMode===exports.RenderMode.Mesh?(e=ei,i=ii):this.settings.renderMode===exports.RenderMode.StretchedBillBoard?(e=si,i=ti):(e=$e,i=ti),this.settings.texture&&r.push("USE_MAP"),(this.settings.uTileCount>1||this.settings.vTileCount>1)&&r.push("UV_TILE"),this.settings.blendTiles&&r.push("TILE_BLEND"),this.settings.softParticles&&r.push("SOFT_PARTICLES"),this.settings.materialAlphaTest>0&&r.push("USE_ALPHATEST"),this.settings.renderMode===exports.RenderMode.VerticalBillBoard&&r.push("VERTICAL"),this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&r.push("HORIZONTAL"),n.Effect.ShadersStore[t+"VertexShader"]=e,n.Effect.ShadersStore[t+"FragmentShader"]=i;const h=["position","uv","offset","color","size","rotation","uvTile"];this.settings.renderMode===exports.RenderMode.Mesh&&h.push("normal"),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&h.push("velocity");const l=["world","view","projection","worldView","worldViewProjection"],c=[];(this.settings.uTileCount>1||this.settings.vTileCount>1)&&(l.push("tileCountX"),l.push("tileCountY")),this.settings.texture&&c.push("map"),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&l.push("speedFactor"),this.settings.softParticles&&(l.push("softParams"),l.push("projParams"),c.push("depthTexture")),this.settings.materialAlphaTest>0&&l.push("alphaTest"),this.settings.renderMode===exports.RenderMode.Mesh&&(l.push("lightDirection"),l.push("lightColor"),l.push("ambientColor"));const u=new s.ShaderMaterial(t,this.scene,{vertex:t,fragment:t},{attributes:h,uniforms:l,samplers:c,defines:r,needAlphaBlending:this.settings.materialTransparent});this.settings.texture&&u.setTexture("map",this.settings.texture),(this.settings.uTileCount>1||this.settings.vTileCount>1)&&(u.setFloat("tileCountX",this.settings.uTileCount),u.setFloat("tileCountY",this.settings.vTileCount)),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&u.setFloat("speedFactor",this.settings.softNearFade>0?this.settings.softNearFade:1),this.settings.softParticles&&(u.setVector2("softParams",new a.Vector2(this.settings.softNearFade,1/Math.max(this.settings.softFarFade-this.settings.softNearFade,1e-4))),u.onBindObservable.add(()=>{const t=this.scene.activeCamera;t&&u.setVector4("projParams",new a.Vector4(t.minZ,t.maxZ,0,0))})),this.settings.materialAlphaTest>0&&u.setFloat("alphaTest",this.settings.materialAlphaTest),this.settings.renderMode===exports.RenderMode.Mesh&&(u.setVector3("lightDirection",new a.Vector3(.4,-1,.6)),u.setVector3("lightColor",new a.Vector3(1,1,1)),u.setVector3("ambientColor",new a.Vector3(.35,.35,.35))),u.backFaceCulling=!1,this.settings.materialTransparent?u.alphaMode=this.settings.materialBlendMode:u.alphaMode=o.Constants.ALPHA_DISABLE,u.needDepthPrePass=this.settings.materialDepthWrite,u.forceDepthWrite=this.settings.materialDepthWrite,u.disableDepthWrite=!this.settings.materialDepthWrite,this.mesh.material=u}update(){let t=0,e=0;const i=this.settings.renderMode,r=i===exports.RenderMode.Mesh,n=i===exports.RenderMode.StretchedBillBoard,o=this.getVisibleSystems();for(const t of o)e+=t.particleNum;e>this.maxParticles&&this.expandBuffers(e);for(const e of o){const i=e.particles,s=e.particleNum,o=this.quaternion2_,a=this.vector2_,h=this.vector3_,l=e.worldSpace;e.emitter.matrixWorld.decompose(a,o,h),this.rotationMat_.setFromMatrix4(e.emitter.matrixWorld);const c=Math.abs(h.x),u=Math.abs(h.y),d=Math.abs(h.z);for(let a=0;a<s;a++,t++){const s=i[a];if(r){let e;if(l)e=s.rotation;else{let t;t=s.parentMatrix?this.quaternion3_.setFromRotationMatrix(s.parentMatrix):o,e=this.quaternion_,e.copy(t).multiply(s.rotation)}const i=4*t;this.rotationBuffer[i]=e.x,this.rotationBuffer[i+1]=e.y,this.rotationBuffer[i+2]=e.z,this.rotationBuffer[i+3]=e.w}else this.rotationBuffer[t]=s.rotation;let h;l?h=s.position:(h=this.vector_,s.parentMatrix?h.copy(s.position).applyMatrix4(s.parentMatrix):h.copy(s.position).applyMatrix4(e.emitter.matrixWorld));const m=3*t;this.offsetBuffer[m]=h.x,this.offsetBuffer[m+1]=h.y,this.offsetBuffer[m+2]=h.z;const p=4*t;this.colorBuffer[p]=s.color.x,this.colorBuffer[p+1]=s.color.y,this.colorBuffer[p+2]=s.color.z,this.colorBuffer[p+3]=s.color.w;const y=3*t;if(l||s.parentMatrix?(this.sizeBuffer[y]=s.size.x,this.sizeBuffer[y+1]=s.size.y,this.sizeBuffer[y+2]=s.size.z):(this.sizeBuffer[y]=s.size.x*c,this.sizeBuffer[y+1]=s.size.y*u,this.sizeBuffer[y+2]=s.size.z*d),this.uvTileBuffer[t]=s.uvTile,n&&this.velocityBuffer){let i=e.rendererEmitterSettings.speedFactor;0===i&&(i=.001);const r=e.rendererEmitterSettings.lengthFactor;let n;l?n=s.velocity:(n=this.vector_,s.parentMatrix?(this.rotationMat2_.setFromMatrix4(s.parentMatrix),n.copy(s.velocity).applyMatrix3(this.rotationMat2_)):n.copy(s.velocity).applyMatrix3(this.rotationMat_));const o=4*t;this.velocityBuffer[o]=n.x*i,this.velocityBuffer[o+1]=n.y*i,this.velocityBuffer[o+2]=n.z*i,this.velocityBuffer[o+3]=r}}}if(n&&this.mesh.material instanceof s.ShaderMaterial&&o.length>0){const t=o[0].rendererEmitterSettings.speedFactor??1,e=0===t?.001:t;e!==this.lastStretchedSpeedFactor&&(this.mesh.material.setFloat("speedFactor",e),this.lastStretchedSpeedFactor=e)}this.mesh.forcedInstanceCount=t,t>0&&(this.offsetVB.update(this.offsetBuffer),this.sizeVB.update(this.sizeBuffer),this.colorVB.update(this.colorBuffer),this.uvTileVB.update(this.uvTileBuffer),this.rotationVB.update(this.rotationBuffer),n&&this.velocityVB&&this.velocityBuffer&&this.velocityVB.update(this.velocityBuffer))}dispose(){this.mesh.material&&this.mesh.material.dispose(),super.dispose()}}class hi extends oi{getTrailHistoryCount(t){const e=t._trailHistoryCount;return"number"==typeof e?e:t.previous.length}constructor(t,e){super(t,e),this.vector_=new k,this.vector2_=new k,this.vector3_=new k,this.quaternion_=new I,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.mesh.dispose(),this.mesh=new i.Mesh("trailBatch",this.scene),this.mesh.alwaysSelectAsActiveMesh=!0,this.buildGeometryBuffers()}buildGeometryBuffers(){this.positionBuffer=new Float32Array(6*this.maxParticles),this.previousBuffer=new Float32Array(6*this.maxParticles),this.nextBuffer=new Float32Array(6*this.maxParticles),this.uvBuffer=new Float32Array(4*this.maxParticles),this.sideBuffer=new Float32Array(2*this.maxParticles),this.widthBuffer=new Float32Array(2*this.maxParticles),this.colorBuffer=new Float32Array(8*this.maxParticles),this.indexBuffer=new Uint32Array(6*this.maxParticles),this.positionBuffer[0]=0,this.positionBuffer[1]=0,this.positionBuffer[2]=0,this.positionBuffer[3]=1,this.positionBuffer[4]=0,this.positionBuffer[5]=0,this.positionBuffer[6]=0,this.positionBuffer[7]=1,this.positionBuffer[8]=0,this.positionBuffer[9]=1,this.positionBuffer[10]=1,this.positionBuffer[11]=0,this.indexBuffer[0]=0,this.indexBuffer[1]=1,this.indexBuffer[2]=2,this.indexBuffer[3]=1,this.indexBuffer[4]=3,this.indexBuffer[5]=2,this.mesh.setVerticesData(t.VertexBuffer.PositionKind,this.positionBuffer,!0),this.mesh.setVerticesData(t.VertexBuffer.UVKind,this.uvBuffer,!0),this.mesh.setVerticesData(t.VertexBuffer.ColorKind,this.colorBuffer,!0,4),this.mesh.setIndices(this.indexBuffer.subarray(0,6),null,!0);const e=this.scene.getEngine();this.previousVB=new t.VertexBuffer(e,this.previousBuffer,"previous",!0,!1,3,!1),this.nextVB=new t.VertexBuffer(e,this.nextBuffer,"next",!0,!1,3,!1),this.sideVB=new t.VertexBuffer(e,this.sideBuffer,"side",!0,!1,1,!1),this.widthVB=new t.VertexBuffer(e,this.widthBuffer,"width",!0,!1,1,!1),this.mesh.setVerticesBuffer(this.previousVB),this.mesh.setVerticesBuffer(this.nextVB),this.mesh.setVerticesBuffer(this.sideVB),this.mesh.setVerticesBuffer(this.widthVB),this.mesh.doNotSyncBoundingInfo=!0;const i=new a.Vector3(-1e4,-1e4,-1e4),s=new a.Vector3(1e4,1e4,1e4);if(this.mesh.setBoundingInfo(new h.BoundingInfo(i,s)),this.mesh.subMeshes)for(const t of this.mesh.subMeshes)t._boundingInfo=this.mesh.getBoundingInfo()}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.buildGeometryBuffers()}rebuildMaterial(){const t=`quarksTrail_${Date.now()}`,e=[];this.settings.texture&&e.push("USE_MAP"),n.Effect.ShadersStore[t+"VertexShader"]=ri,n.Effect.ShadersStore[t+"FragmentShader"]=ni;const i=[];this.settings.texture&&i.push("map");const r=new s.ShaderMaterial(t,this.scene,{vertex:t,fragment:t},{attributes:["position","previous","next","side","width","uv","color"],uniforms:["world","view","projection","worldViewProjection","lineWidth","resolution","sizeAttenuation"],samplers:i,defines:e,needAlphaBlending:this.settings.materialTransparent});this.settings.texture&&r.setTexture("map",this.settings.texture);const h=this.scene.getEngine();r.setFloat("lineWidth",1),r.setVector2("resolution",new a.Vector2(h.getRenderWidth(),h.getRenderHeight())),r.setFloat("sizeAttenuation",1),r.onBindObservable.add(()=>{const t=this.scene.getEngine();r.setVector2("resolution",new a.Vector2(t.getRenderWidth(),t.getRenderHeight()))}),r.backFaceCulling=!1,this.settings.materialTransparent?r.alphaMode=this.settings.materialBlendMode:r.alphaMode=o.Constants.ALPHA_DISABLE,r.needDepthPrePass=this.settings.materialDepthWrite,r.forceDepthWrite=this.settings.materialDepthWrite,r.disableDepthWrite=!this.settings.materialDepthWrite,this.mesh.material=r}update(){let e=0,i=0,s=0;const r=this.getVisibleSystems();for(const t of r)for(let e=0;e<t.particleNum;e++)s+=2*this.getTrailHistoryCount(t.particles[e]);s>this.maxParticles&&this.expandBuffers(s);for(const t of r){t.emitter.computeWorldMatrix&&t.emitter.computeWorldMatrix(!0);const s=this.quaternion_,r=this.vector2_,n=this.vector3_;t.emitter.matrixWorld.decompose(r,s,n);const o=t.particles,a=t.particleNum,h=this.settings.uTileCount,l=this.settings.vTileCount,c=1/h,u=1/l,d=t.worldSpace,m=(Math.abs(n.x)+Math.abs(n.y)+Math.abs(n.z))/3;for(let s=0;s<a;s++){const r=o[s],n=r,a=n._trailHistoryCount,h=n._trailHistoryCapacity,p=n._trailHistoryHead,y=n._trailHistoryPositions,f=n._trailHistorySizes,x=n._trailHistoryColors,g="number"==typeof a&&a>0&&"number"==typeof h&&"number"==typeof p&&y instanceof Float32Array&&f instanceof Float32Array&&x instanceof Float32Array,v=g?h:0,S=g?p:0,M=y,w=f,b=x,_=r.previous,z=g?a:_.length;if(0===z)continue;const T=r.uvTile%l,O=Math.floor(r.uvTile/l+.001),P=r.parentMatrix??t.emitter.matrixWorld;let B=_.head,N=B,C=N?.next??N;const V=g?(S-z+v)%v:0;for(let t=0;t<z;t++,e+=2){let s,n,o,a,h,p,y,f,x,S,_,F,A,E;if(g){const e=(V+t)%v,i=3*e,r=3*(0===t?e:(V+t-1)%v),l=3*(t+1<z?(V+t+1)%v:e);s=M[i],n=M[i+1],o=M[i+2],x=M[r],S=M[r+1],_=M[r+2],F=M[l],A=M[l+1],E=M[l+2],a=w[e];const c=4*e;h=b[c],p=b[c+1],y=b[c+2],f=b[c+3]}else{const t=B.data,e=N.data,i=C.data;s=e.position.x,n=e.position.y,o=e.position.z,x=t.position.x,S=t.position.y,_=t.position.z,F=i.position.x,A=i.position.y,E=i.position.z,a=e.size,h=e.color.x,p=e.color.y,y=e.color.z,f=e.color.w}d||(this.vector_.set(s,n,o).applyMatrix4(P),s=this.vector_.x,n=this.vector_.y,o=this.vector_.z,this.vector_.set(x,S,_).applyMatrix4(P),x=this.vector_.x,S=this.vector_.y,_=this.vector_.z,this.vector_.set(F,A,E).applyMatrix4(P),F=this.vector_.x,A=this.vector_.y,E=this.vector_.z);const D=3*e;this.positionBuffer[D]=s,this.positionBuffer[D+1]=n,this.positionBuffer[D+2]=o,this.positionBuffer[D+3]=s,this.positionBuffer[D+4]=n,this.positionBuffer[D+5]=o,this.previousBuffer[D]=x,this.previousBuffer[D+1]=S,this.previousBuffer[D+2]=_,this.previousBuffer[D+3]=x,this.previousBuffer[D+4]=S,this.previousBuffer[D+5]=_,this.nextBuffer[D]=F,this.nextBuffer[D+1]=A,this.nextBuffer[D+2]=E,this.nextBuffer[D+3]=F,this.nextBuffer[D+4]=A,this.nextBuffer[D+5]=E,this.sideBuffer[e]=1,this.sideBuffer[e+1]=-1,d||r.parentMatrix?(this.widthBuffer[e]=a,this.widthBuffer[e+1]=a):(this.widthBuffer[e]=a*m,this.widthBuffer[e+1]=a*m);const R=2*e;this.uvBuffer[R]=(t/z+T)*c,this.uvBuffer[R+1]=(l-O-1)*u,this.uvBuffer[R+2]=(t/z+T)*c,this.uvBuffer[R+3]=(l-O)*u;const J=4*e;this.colorBuffer[J]=h,this.colorBuffer[J+1]=p,this.colorBuffer[J+2]=y,this.colorBuffer[J+3]=f,this.colorBuffer[J+4]=h,this.colorBuffer[J+5]=p,this.colorBuffer[J+6]=y,this.colorBuffer[J+7]=f,t+1<z&&(this.indexBuffer[3*i]=e,this.indexBuffer[3*i+1]=e+1,this.indexBuffer[3*i+2]=e+2,i++,this.indexBuffer[3*i]=e+2,this.indexBuffer[3*i+1]=e+1,this.indexBuffer[3*i+2]=e+3,i++),g||(B=N,N=C,C=C?.next??C)}}}if(e>0&&i>0){this.mesh.updateVerticesData(t.VertexBuffer.PositionKind,this.positionBuffer),this.mesh.updateVerticesData(t.VertexBuffer.UVKind,this.uvBuffer),this.mesh.updateIndices(this.indexBuffer.subarray(0,3*i)),this.previousVB.update(this.previousBuffer),this.nextVB.update(this.nextBuffer),this.sideVB.update(this.sideBuffer),this.widthVB.update(this.widthBuffer);const s=this.mesh.getVertexBuffer(t.VertexBuffer.ColorKind);if(s&&s.update(this.colorBuffer),this.mesh.subMeshes&&this.mesh.subMeshes.length>0){const t=this.mesh.getBoundingInfo();for(const e of this.mesh.subMeshes)e._boundingInfo=t;this.mesh.subMeshes[0].indexCount=3*i,this.mesh.subMeshes[0].verticesCount=e}}else this.mesh.subMeshes&&this.mesh.subMeshes.length>0&&(this.mesh.subMeshes[0].indexCount=0,this.mesh.subMeshes[0].verticesCount=0)}dispose(){this.mesh.material&&this.mesh.material.dispose(),super.dispose()}}class li extends e.TransformNode{constructor(t,e){super(t,e),this.batches=[],this.systemToBatchIndex=new Map,this.depthTexture=null,this.adaptivePerformanceState={enabled:!1,targetFrameMs:16.7,minQuality:.35,maxQuality:1,decreaseStep:.08,increaseStep:.02,currentQuality:1,lastFrameCpuMs:0},this.lastAppliedQuality=Number.NaN}static clamp(t,e,i){return Math.max(e,Math.min(i,t))}static equals(t,e){return t.materialBlendMode===e.materialBlendMode&&t.materialTransparent===e.materialTransparent&&t.materialDepthTest===e.materialDepthTest&&t.materialDepthWrite===e.materialDepthWrite&&t.materialAlphaTest===e.materialAlphaTest&&t.texture===e.texture&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layerMask===e.layerMask}addSystem(t){const e=t;e._renderer=this,this.adaptivePerformanceState.enabled&&e.setQualityFactor(this.adaptivePerformanceState.currentQuality);const i=e.getRendererSettings();for(let e=0;e<this.batches.length;e++)if(li.equals(this.batches[e].settings,i))return this.batches[e].addSystem(t),void this.systemToBatchIndex.set(t,e);let s;const r=this.getScene();switch(i.renderMode){case exports.RenderMode.Trail:s=new hi(i,r);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:s=new ai(i,r);break;default:throw new Error(`Unsupported render mode: ${i.renderMode}`)}s.mesh.parent=this,this.depthTexture&&s.applyDepthTexture(this.depthTexture),s.addSystem(t),this.batches.push(s),this.systemToBatchIndex.set(t,this.batches.length-1)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);void 0!==e&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}configureAdaptivePerformance(t={}){const e=this.adaptivePerformanceState,i=li.clamp(t.minQuality??e.minQuality,.05,1),s=li.clamp(t.maxQuality??e.maxQuality,i,1);e.targetFrameMs=Math.max(t.targetFrameMs??e.targetFrameMs,.1),e.minQuality=i,e.maxQuality=s,e.decreaseStep=Math.max(t.decreaseStep??e.decreaseStep,.001),e.increaseStep=Math.max(t.increaseStep??e.increaseStep,.001),e.currentQuality=li.clamp(e.currentQuality,e.minQuality,e.maxQuality),e.enabled=!0,this.lastAppliedQuality=Number.NaN}disableAdaptivePerformance(t=!0){this.adaptivePerformanceState.enabled=!1,t&&(this.adaptivePerformanceState.currentQuality=this.adaptivePerformanceState.maxQuality,this.applyAdaptiveQuality())}getAdaptivePerformanceState(){return{...this.adaptivePerformanceState}}applyAdaptiveQuality(){const t=this.adaptivePerformanceState.currentQuality;if(t!==this.lastAppliedQuality){for(const e of this.systemToBatchIndex.keys())e.setQualityFactor(t);this.lastAppliedQuality=t}}update(t){const e=this.adaptivePerformanceState,i=e.enabled?performance.now():0;e.enabled&&this.applyAdaptiveQuality();for(const e of this.systemToBatchIndex.keys())e.update(t);for(let t=0;t<this.batches.length;t++)this.batches[t].update();e.enabled&&(e.lastFrameCpuMs=performance.now()-i,e.lastFrameCpuMs>e.targetFrameMs?e.currentQuality=li.clamp(e.currentQuality-e.decreaseStep,e.minQuality,e.maxQuality):e.currentQuality=li.clamp(e.currentQuality+e.increaseStep,e.minQuality,e.maxQuality))}dispose(){for(const t of this.batches)t.dispose();this.batches=[],this.systemToBatchIndex.clear(),super.dispose()}}const ci=li;class ui extends e.TransformNode{get matrixWorld(){const t=this.getWorldMatrix(),e=this._matrixWorld.elements;return e[0]=t.m[0],e[1]=t.m[1],e[2]=t.m[2],e[3]=t.m[3],e[4]=t.m[4],e[5]=t.m[5],e[6]=t.m[6],e[7]=t.m[7],e[8]=t.m[8],e[9]=t.m[9],e[10]=t.m[10],e[11]=t.m[11],e[12]=t.m[12],e[13]=t.m[13],e[14]=t.m[14],e[15]=t.m[15],this._matrixWorld}get visible(){return this.isEnabled()}set visible(t){this.setEnabled(t)}get uuid(){return this.uniqueId.toString()}constructor(t,e){super("particleEmitter",e||void 0),this._matrixWorld=new Q,this.system=t}dispose(){super.dispose()}extractFromCache(t){const e=[];for(const i in t){const s=t[i];s&&"object"==typeof s&&delete s.metadata,e.push(s)}return e}clone(t){const e=this.system.clone().emitter;return e.name=t??this.name,e.position.copyFrom(this.position),e.rotation.copyFrom(this.rotation),e.scaling.copyFrom(this.scaling),this.rotationQuaternion&&(e.rotationQuaternion=this.rotationQuaternion.clone()),e.setEnabled(this.isEnabled()),e}toJSON(t,e={}){return{uuid:this._quarksUUID??this.uniqueId.toString(),type:"ParticleEmitter",name:this.name,position:[this.position.x,this.position.y,this.position.z],rotation:[this.rotation.x,this.rotation.y,this.rotation.z],quaternion:this.rotationQuaternion?[this.rotationQuaternion.x,this.rotationQuaternion.y,this.rotationQuaternion.z,this.rotationQuaternion.w]:void 0,scale:[this.scaling.x,this.scaling.y,this.scaling.z],visible:this.isEnabled(),ps:this.system.toJSON(t,e)}}}function di(t,e){if(e&&e.length>0)return e;const i=t.length/3,s=new Uint32Array(i);for(let t=0;t<i;t++)s[t]=t;return s}const mi=new k(0,0,1),pi=new I,yi=new k,fi=new k,xi=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),gi=new Float32Array([0,0,1,0,1,1,0,1]),vi=new Uint32Array([0,1,2,0,2,3]);class Si{set time(t){this.emissionState.time=t}get time(){return this.emissionState.time}get layers(){return this.layerMaskProxy}get texture(){return this.rendererSettings.texture}set texture(t){this.rendererSettings.texture=t,this.neededToUpdateRender=!0}get material(){return this.materialRef}set material(t){this.materialRef=t,this.applyMaterialSettings(t)}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(t){this.rendererSettings.uTileCount=t,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(t){this.rendererSettings.vTileCount=t,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(t){this.rendererSettings.blendTiles=t,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(t){this.rendererSettings.softParticles=t,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(t){this.rendererSettings.softNearFade=t,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(t){this.rendererSettings.softFarFade=t,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(t){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=t,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.materialBlendMode}set blending(t){this.rendererSettings.materialBlendMode=t,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(t){if(this.rendererSettings.renderMode!==t){let e=!1;switch(this.rendererSettings.renderMode===exports.RenderMode.Trail&&(e=!0),this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new wt(0)),t){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new wt(30),followLocalOrigin:!1},e=!0;break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={},this.startRotation=new Pt(new k(0,1,0),new wt(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2};break;case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:this.rendererEmitterSettings={}}this.rendererSettings.renderMode=t,e&&(this.restart(),this.particles.length=0),this.neededToUpdateRender=!0}}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(t){this.rendererSettings.renderOrder=t,this.neededToUpdateRender=!0}constructor(t){if(this.emitterVelocity=new k,this.startDelayTimeLeft=0,this.tempEmitterPos=new k,this.temp=new k,this.normalMatrix=new rt,this.memory=[],this.listeners={},this.materialRef=null,this.qualityFactor=1,this.useFastTrailHistory=!0,this.firstTimeUpdate=!0,this.layerMaskProxy={mask:t.layerMask??268435455},Object.defineProperty(this.layerMaskProxy,"mask",{enumerable:!0,get:()=>this.rendererSettings.layerMask,set:t=>{this.rendererSettings.layerMask=t,this.neededToUpdateRender=!0}}),this.autoDestroy=t.autoDestroy??!1,this.duration=t.duration??1,this.startDelay=t.startDelay??new wt(0),this.looping=t.looping??!0,this.prewarm=t.prewarm??!1,this.startLife=t.startLife??new wt(5),this.startSpeed=t.startSpeed??new wt(0),this.startRotation=t.startRotation??new wt(0),this.startSize=t.startSize??new wt(1),this.startColor=t.startColor??new St(new st(1,1,1,1)),this.emissionOverTime=t.emissionOverTime??new wt(10),this.emissionOverDistance=t.emissionOverDistance??new wt(0),this.emissionBursts=t.emissionBursts??[],this.onlyUsedByOther=t.onlyUsedByOther??!1,this.emitterShape=t.shape??new qt,this.behaviors=t.behaviors??[],this.worldSpace=t.worldSpace??!1,this.rendererEmitterSettings=t.rendererEmitterSettings??{},t.renderMode===exports.RenderMode.StretchedBillBoard){const e=this.rendererEmitterSettings;void 0!==t.speedFactor&&(e.speedFactor=t.speedFactor),e.speedFactor=e.speedFactor??0,e.lengthFactor=e.lengthFactor??0}this.rendererSettings={instancingGeometry:t.instancingGeometry??xi,instancingIndices:t.instancingIndices??vi,instancingUVs:t.instancingUVs??gi,instancingNormals:t.instancingNormals,renderMode:t.renderMode??exports.RenderMode.BillBoard,renderOrder:t.renderOrder??0,uTileCount:t.uTileCount??1,vTileCount:t.vTileCount??1,blendTiles:t.blendTiles??!1,softParticles:t.softParticles??!1,softNearFade:t.softNearFade??0,softFarFade:t.softFarFade??0,materialBlendMode:t.blendMode??o.Constants.ALPHA_ADD,materialTransparent:t.transparent??!0,materialDepthTest:t.depthTest??!0,materialDepthWrite:t.depthWrite??!1,materialAlphaTest:t.alphaTest??0,texture:t.texture??null,layerMask:t.layerMask??268435455},this.rendererSettings.renderMode!==exports.RenderMode.Mesh||this.rendererSettings.instancingNormals||(this.rendererSettings.instancingNormals=Si.createFallbackNormals(this.rendererSettings.instancingGeometry)),this.materialRef=t.material??null,this.applyMaterialSettings(this.materialRef,{blendMode:t.blendMode,transparent:t.transparent,depthTest:t.depthTest,depthWrite:t.depthWrite,alphaTest:t.alphaTest,texture:t.texture,layerMask:t.layerMask}),this.neededToUpdateRender=!0,this.particles=[],this.startTileIndex=t.startTileIndex||new wt(0),this.emitter=new ui(this,t.scene),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.startDelay.startGen(this.memory),this.startDelayTimeLeft=this.startDelay.genValue(this.memory,0),this.refreshTrailHistoryMode(),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}applyMaterialSettings(t,e={}){if(!this.rendererSettings)return;const i=void 0!==e.texture?e.texture:t?.albedoTexture??t?.diffuseTexture??t?.emissiveTexture??t?.opacityTexture??t?.baseTexture??this.rendererSettings.texture??null,s=e.blendMode??("number"==typeof t?.alphaMode?t.alphaMode:this.rendererSettings.materialBlendMode),r=e.transparent??("function"==typeof t?.needAlphaBlending?t.needAlphaBlending():"number"==typeof t?.alpha?t.alpha<1:this.rendererSettings.materialTransparent),n=e.depthTest??("boolean"==typeof t?.disableDepthTest?!t.disableDepthTest:this.rendererSettings.materialDepthTest),o=e.depthWrite??("boolean"==typeof t?.disableDepthWrite?!t.disableDepthWrite:"boolean"==typeof t?.forceDepthWrite?t.forceDepthWrite:this.rendererSettings.materialDepthWrite),a=e.alphaTest??("number"==typeof t?.alphaCutOff?t.alphaCutOff:"number"==typeof t?.alphaCutOffValue?t.alphaCutOffValue:this.rendererSettings.materialAlphaTest);this.rendererSettings.texture=i,this.rendererSettings.materialBlendMode=s,this.rendererSettings.materialTransparent=r,this.rendererSettings.materialDepthTest=n,this.rendererSettings.materialDepthWrite=o,this.rendererSettings.materialAlphaTest=a,void 0!==e.layerMask&&(this.rendererSettings.layerMask=e.layerMask),this.neededToUpdateRender=!0}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}refreshTrailHistoryMode(){this.useFastTrailHistory=!this.behaviors.some(t=>"WidthOverLength"===t.type)}ensureTrailHistoryCapacity(t,e){const i=t;i._trailHistoryCapacity===e&&i._trailHistoryPositions||(i._trailHistoryCapacity=e,i._trailHistoryPositions=new Float32Array(3*e),i._trailHistorySizes=new Float32Array(e),i._trailHistoryColors=new Float32Array(4*e),i._trailHistoryHead=0,i._trailHistoryCount=0)}resetTrailHistory(t){const e=t;e._trailHistoryHead=0,e._trailHistoryCount=0}getTrailHistoryCount(t){const e=t._trailHistoryCount;return"number"==typeof e?e:t.previous.length}updateFastTrailHistory(t){const e=t,i=Math.max(1,Math.ceil(t.length));this.ensureTrailHistoryCapacity(t,i);let s=e._trailHistoryHead,r=e._trailHistoryCount;const n=e._trailHistoryPositions,o=e._trailHistorySizes,a=e._trailHistoryColors;if(t.age<=t.life){const e=3*s;n[e]=t.position.x,n[e+1]=t.position.y,n[e+2]=t.position.z,o[s]=t.size.x;const h=4*s;a[h]=t.color.x,a[h+1]=t.color.y,a[h+2]=t.color.z,a[h+3]=t.color.w,s=(s+1)%i,r<i&&r++}else r>0&&r--;e._trailHistoryHead=s,e._trailHistoryCount=r}setQualityFactor(t){this.qualityFactor=Math.max(.1,Math.min(1,t))}spawn(t,e,i){pi.setFromRotationMatrix(i);const s=yi,r=fi;i.decompose(s,pi,r);const n=this.behaviors,o=n.length,a=this.rendererSettings.renderMode,h=a===exports.RenderMode.Trail,l=e.time/this.duration,c=h?this.rendererEmitterSettings:void 0,u=Boolean(c?.followLocalOrigin);for(let s=0;s<t;s++){e.burstParticleIndex=s,this.particleNum++,this.particles.length<this.particleNum&&(h?this.particles.push(new de):this.particles.push(new ce));const t=this.particles[this.particleNum-1];if(t.reset(),t.speedModifier=1,this.startColor.startGen(t.memory),this.startColor.genColor(t.memory,t.startColor,this.emissionState.time),t.color.copy(t.startColor),this.startSpeed.startGen(t.memory),t.startSpeed=this.startSpeed.genValue(t.memory,l),this.startLife.startGen(t.memory),t.life=this.startLife.genValue(t.memory,l),t.age=0,this.startSize.startGen(t.memory),"vec3function"===this.startSize.type)this.startSize.genValue(t.memory,t.startSize,l);else{const e=this.startSize.genValue(t.memory,l);t.startSize.set(e,e,e)}if(this.startTileIndex.startGen(t.memory),t.uvTile=this.startTileIndex.genValue(t.memory),t.size.copy(t.startSize),this.rendererSettings.renderMode===exports.RenderMode.Mesh||this.rendererSettings.renderMode===exports.RenderMode.BillBoard||this.rendererSettings.renderMode===exports.RenderMode.VerticalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.HorizontalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.StretchedBillBoard){const e=t;this.startRotation.startGen(t.memory),a===exports.RenderMode.Mesh?(e.rotation instanceof I||(e.rotation=new I),"rotation"===this.startRotation.type?this.startRotation.genValue(t.memory,e.rotation,1,l):e.rotation.setFromAxisAngle(mi,this.startRotation.genValue(e.memory,l))):"rotation"===this.startRotation.type?e.rotation=0:e.rotation=this.startRotation.genValue(e.memory,l)}else if(h&&c){const e=t;c.startLength.startGen(e.memory),e.length=c.startLength.genValue(e.memory,l),this.useFastTrailHistory&&(this.ensureTrailHistoryCapacity(e,Math.max(1,Math.ceil(e.length))),this.resetTrailHistory(e))}if(this.emitterShape.initialize(t,e),h&&u){const e=t;e.localPosition||(e.localPosition=new k),e.localPosition.copy(e.position)}this.worldSpace?(t.position.applyMatrix4(i),t.startSize.multiply(r).abs(),t.size.copy(t.startSize),t.velocity.multiply(r).applyMatrix3(this.normalMatrix),t.rotation&&t.rotation instanceof I&&t.rotation.multiplyQuaternions(pi,t.rotation)):this.onlyUsedByOther&&(t.parentMatrix=i);for(let e=0;e<o;e++)n[e].initialize(t,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(t=>t.reset()),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1,this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.startDelay.startGen(this.memory),this.startDelayTimeLeft=this.startDelay.genValue(this.memory,0),this.previousEmitterPos=void 0,this.emitterVelocity.set(0,0,0)}update(t){if(this.paused)return;if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.computeWorldMatrix(!0)),this.emitEnded&&0===this.particleNum)return void(this.markForDestroy&&this.dispose());if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let t=0;t<60*this.duration;t++)this.update(1/60)}t>.1&&(t=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1);const e=this.emitter.matrixWorld.elements;if(this.tempEmitterPos.set(e[12],e[13],e[14]),void 0!==this.previousEmitterPos&&t>0&&this.emitterVelocity.copy(this.tempEmitterPos).sub(this.previousEmitterPos).divideScalar(t),(this.previousEmitterPos??(this.previousEmitterPos=new k)).copy(this.tempEmitterPos),this.startDelayTimeLeft>0&&(!this.prewarm||!this.looping)){if(this.startDelayTimeLeft-=t,this.startDelayTimeLeft>=0)return;t=Math.min(-this.startDelayTimeLeft,.1),this.startDelayTimeLeft=0}this.onlyUsedByOther||this.emit(t,this.emissionState,this.emitter.matrixWorld);const i=this.particles,s=this.behaviors.length,r=this.particleNum;this.emitterShape.update(this,t);for(let e=0;e<s;e++){const s=this.behaviors[e];s.frameUpdate(t);for(let e=0;e<r;e++){const r=i[e];r.died||s.update(r,t)}}const n=this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin,o=this.emitter.matrixWorld;for(let e=0;e<r;e++){const s=i[e];n&&s.localPosition?(s.position.copy(s.localPosition),s.parentMatrix?s.position.applyMatrix4(s.parentMatrix):s.position.applyMatrix4(o)):s.position.addScaledVector(s.velocity,t*s.speedModifier),s.age+=t}if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let t=0;t<r;t++){const e=i[t];this.useFastTrailHistory?this.updateFastTrailHistory(e):e.update()}let a=this.particleNum;for(let t=0;t<a;t++){const e=i[t];!e.died||e instanceof de&&0!==this.getTrailHistoryCount(e)||(i[t]=i[a-1],i[a-1]=e,a--,t--,this.fire({type:"particleDied",particleSystem:this,particle:e}))}this.particleNum=a}emit(t,e,i){e.time>this.duration&&(this.looping?(e.time-=this.duration,e.burstIndex=0,this.behaviors.forEach(t=>t.reset())):this.emitEnded||this.onlyUsedByOther||this.endEmit()),this.normalMatrix.getNormalMatrix(i);const s=this.emissionBursts,r=s.length,n=this.qualityFactor,o=Math.floor(e.waitEmiting);for(o>0&&(this.spawn(o,e,i),e.waitEmiting-=o);e.burstIndex<r&&s[e.burstIndex].time<=e.time;){const t=s[e.burstIndex];if(Math.random()<t.probability){const s=t.count.genValue(this.memory,this.time),r=n>=.999?s:Math.floor(s*n);e.isBursting=!0,e.burstParticleCount=r,this.spawn(r,e,i),e.isBursting=!1}e.burstIndex++}if(!this.emitEnded){const s=e.time/this.duration;e.waitEmiting+=t*this.emissionOverTime.genValue(this.memory,s)*n;const r=e.previousWorldPos;if(void 0!==r){this.temp.set(i.elements[12],i.elements[13],i.elements[14]),e.travelDistance+=r.distanceTo(this.temp);const t=this.emissionOverDistance.genValue(this.memory,s)*n;if(e.travelDistance*t>0){const i=Math.floor(e.travelDistance*t);e.travelDistance-=i/t,e.waitEmiting+=i}}}void 0===e.previousWorldPos&&(e.previousWorldPos=new k),e.previousWorldPos.set(i.elements[12],i.elements[13],i.elements[14]),e.time+=t}toJSON(t,e={}){const i=void 0===t||"string"==typeof t?{geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}:t,s=this.ensureGeometryMeta(i),r=this.ensureMaterialMeta(i),n=this.toRendererSettingsJSON();return{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,startDelay:this.startDelay.toJSON(),shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(t=>({time:t.time,count:t.count.toJSON(),probability:t.probability,interval:t.interval,cycle:t.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:s,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:n,material:r,layers:this.rendererSettings.layerMask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.rendererSettings.uTileCount,vTileCount:this.rendererSettings.vTileCount,blendTiles:this.rendererSettings.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,blending:this.rendererSettings.materialBlendMode,transparent:this.rendererSettings.materialTransparent,depthTest:this.rendererSettings.materialDepthTest,depthWrite:this.rendererSettings.materialDepthWrite,alphaTest:this.rendererSettings.materialAlphaTest,behaviors:this.behaviors.map(t=>t.toJSON()),worldSpace:this.worldSpace}}static fromJSON(t,e,i={},s){const r=jt(t.shape,e);let n;if(t.renderMode===exports.RenderMode.Trail){const e=t.rendererEmitterSettings;n={startLength:void 0!==e?.startLength?Tt(e.startLength):new wt(30),followLocalOrigin:e?.followLocalOrigin??!1}}else t.renderMode===exports.RenderMode.StretchedBillBoard?(n={...t.rendererEmitterSettings??{}},void 0!==t.speedFactor&&(n.speedFactor=t.speedFactor)):n={};const a=t.material?e.materials?.[t.material]:void 0,h=a?.texture??t.texture,l="string"==typeof h?e.textures?.[h]??null:h??null,c="string"==typeof t.instancingGeometry?e.geometries?.[t.instancingGeometry]:t.instancingGeometry,u=Si.resolveGeometryData(c),d=new Si({scene:s,autoDestroy:t.autoDestroy,looping:t.looping,prewarm:t.prewarm,duration:t.duration,startDelay:t.startDelay?Tt(t.startDelay):void 0,shape:r,startLife:Tt(t.startLife),startSpeed:Tt(t.startSpeed),startRotation:Ft(t.startRotation),startSize:Ft(t.startSize),startColor:Mt(t.startColor),emissionOverTime:Tt(t.emissionOverTime),emissionOverDistance:Tt(t.emissionOverDistance),emissionBursts:t.emissionBursts?.map(t=>({time:t.time,count:"number"==typeof t.count?new wt(t.count):Tt(t.count),probability:t.probability??1,interval:t.interval??.1,cycle:t.cycle??t.cycleCount??1})),onlyUsedByOther:t.onlyUsedByOther,instancingGeometry:u.positions,instancingIndices:u.indices,instancingUVs:u.uvs,instancingNormals:u.normals,renderMode:t.renderMode,rendererEmitterSettings:n,renderOrder:t.renderOrder,texture:l,material:a?.sourceMaterial??a,blendMode:a?.alphaMode??t.blending??o.Constants.ALPHA_ADD,transparent:a?.transparent??t.transparent??!0,depthTest:a?.depthTest??t.depthTest??!0,depthWrite:a?.depthWrite??t.depthWrite??!1,alphaTest:a?.alphaTest??t.alphaTest??0,startTileIndex:"number"==typeof t.startTileIndex?new wt(t.startTileIndex):Tt(t.startTileIndex),uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softFarFade:t.softFarFade,softNearFade:t.softNearFade,behaviors:[],worldSpace:t.worldSpace,layerMask:t.layers});return d.behaviors=(t.behaviors??[]).map(t=>{const e=Ge(t,d);return e&&"EmitSubParticleSystem"===e.type&&(i[t.subParticleSystem]=e),e}).filter(t=>null!==t),d}static nextSerializationId(t){return Si.serializationCounter+=1,`${t}_${Si.serializationCounter}`}static createFallbackNormals(t){const e=new Float32Array(t.length);for(let t=0;t<e.length;t+=3)e[t]=0,e[t+1]=0,e[t+2]=1;return e}toRendererSettingsJSON(){return this.renderMode===exports.RenderMode.Trail?{startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?{speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:{}}ensureGeometryMeta(t){const e=Si.nextSerializationId("quarks_geometry");return t.geometries[e]={uuid:e,type:"QuarksGeometry",positions:Array.from(this.rendererSettings.instancingGeometry),indices:Array.from(this.rendererSettings.instancingIndices),uvs:this.rendererSettings.instancingUVs?Array.from(this.rendererSettings.instancingUVs):void 0,normals:this.rendererSettings.instancingNormals?Array.from(this.rendererSettings.instancingNormals):void 0},e}ensureMaterialMeta(t){const e=this.rendererSettings.texture;let i;e&&(i=Si.nextSerializationId("quarks_texture"),t.textures[i]=e);const s=Si.nextSerializationId("quarks_material");return t.materials[s]={uuid:s,type:"QuarksMaterial",transparent:this.rendererSettings.materialTransparent,alphaMode:this.rendererSettings.materialBlendMode,depthTest:this.rendererSettings.materialDepthTest,depthWrite:this.rendererSettings.materialDepthWrite,alphaTest:this.rendererSettings.materialAlphaTest,texture:i,sourceMaterial:this.materialRef??void 0},s}static resolveGeometryData(t){if(t?.positions){const e=t.positions instanceof Float32Array?t.positions:new Float32Array(t.positions);return{positions:e,indices:di(e,t.indices instanceof Uint16Array||t.indices instanceof Uint32Array?t.indices:t.indices?new Uint32Array(t.indices):void 0),uvs:t.uvs?t.uvs instanceof Float32Array?t.uvs:new Float32Array(t.uvs):void 0,normals:t.normals?t.normals instanceof Float32Array?t.normals:new Float32Array(t.normals):void 0}}const e=t?.data??t;if(e?.attributes?.position?.array){const t=new Float32Array(e.attributes.position.array);let i;if(e.index?.array){i=new("Uint16Array"===e.index.type?Uint16Array:Uint32Array)(e.index.array)}return{positions:t,indices:di(t,i),uvs:e.attributes.uv?.array?new Float32Array(e.attributes.uv.array):void 0,normals:e.attributes.normal?.array?new Float32Array(e.attributes.normal.array):void 0}}return{positions:xi,indices:vi,uvs:gi}}addBehavior(t){this.behaviors.push(t),this.refreshTrailHistoryMode()}getRendererSettings(){return this.rendererSettings}addEventListener(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}removeAllEventListeners(t){this.listeners[t]&&(this.listeners[t]=[])}removeEventListener(t,e){if(this.listeners[t]){const i=this.listeners[t].indexOf(e);-1!==i&&this.listeners[t].splice(i,1)}}fire(t){this.listeners[t.type]&&this.listeners[t.type].forEach(e=>e(t))}clone(){const t=this.behaviors.map(t=>t.clone());let e;return e=this.renderMode===exports.RenderMode.Trail?{startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?{lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:{},new Si({autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,startDelay:this.startDelay.clone(),shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:this.emissionBursts.map(t=>({...t})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,instancingIndices:this.rendererSettings.instancingIndices,instancingUVs:this.rendererSettings.instancingUVs,instancingNormals:this.rendererSettings.instancingNormals,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:e,material:this.materialRef,texture:this.rendererSettings.texture,startTileIndex:this.startTileIndex,uTileCount:this.rendererSettings.uTileCount,vTileCount:this.rendererSettings.vTileCount,blendTiles:this.rendererSettings.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:t,worldSpace:this.worldSpace,blendMode:this.rendererSettings.materialBlendMode,transparent:this.rendererSettings.materialTransparent,depthTest:this.rendererSettings.materialDepthTest,depthWrite:this.rendererSettings.materialDepthWrite,alphaTest:this.rendererSettings.materialAlphaTest,layerMask:this.rendererSettings.layerMask,scene:this.emitter.getScene()})}}Si.serializationCounter=0;class Mi{static runOnAllParticleEmitters(t,e){Mi.traverseNode(t,t=>{t instanceof ui&&e(t)})}static addToBatchRenderer(t,e){Mi.runOnAllParticleEmitters(t,t=>{e.addSystem(t.system)})}static play(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.play()})}static stop(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.stop()})}static pause(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.pause()})}static restart(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.restart()})}static setAutoDestroy(t,e){Mi.runOnAllParticleEmitters(t,t=>{t.system.autoDestroy=e})}static endEmit(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.endEmit()})}static traverseNode(t,e){e(t);const i=t.getChildren();for(const t of i)Mi.traverseNode(t,e)}}class wi extends e.TransformNode{constructor(t="QuarksPrefab",e){super(t,e),this.type="QuarksPrefab",this.animationData=[],this.isPlaying=!1,this.currentTime=-1e-5,this.timeScale=1,this.duration=0,this._lastUpdateTimeMs=Date.now(),this._tempAnimationJSON=[]}registerBatchedRenderer(t){this._batchedRenderer=t}addParticleSystemAnimation(t,e=0,i=0,s=!1){const r={startTime:e,duration:i>0?i:t.system.duration,type:"ps",loop:s,target:t};return this.animationData.push(r),this.pause(),this.updateDuration(),r}addThreeAnimation(t,e,i=0,s=e?.duration??0,r=!1,n){const o={startTime:i,duration:s>0?s:e?.duration??0,type:"three",loop:r,target:t,clip:e,clipUUID:n??e?.uuid};return this.animationData.push(o),this.updateDuration(),o}removeAnimation(t){this.animationData.splice(t,1),this.updateDuration()}play(){this.isPlaying||(this.isPlaying=!0,this._lastUpdateTimeMs=Date.now())}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationData.forEach(t=>{"ps"===t.type&&t.target instanceof ui?t.target.system.pause():t.clip?.pause?.()}))}stop(){this.pause(),this.currentTime=-1e-5,this.animationData.forEach(t=>{"ps"===t.type&&t.target instanceof ui?t.target.system.stop():t.clip?.stop?.()})}update(t){if(!this.isPlaying)return;const e=Date.now(),i=t??Math.max((e-this._lastUpdateTimeMs)/1e3,0);this._lastUpdateTimeMs=e;const s=this.currentTime;this.currentTime+=i*this.timeScale,this.currentTime>this.duration?this.stop():this.animationData.forEach(t=>{const e=t.startTime,i=t.startTime+t.duration,r=this.currentTime>=e&&this.currentTime<=i,n=s>=e&&s<=i;if(!r||n){if(!r&&n){if(t.loop&&"ps"===t.type&&t.target instanceof ui)return void t.target.system.restart();"ps"===t.type&&t.target instanceof ui?t.target.system.endEmit():t.loop?t.clip?.play?.():t.clip?.stop?.()}}else"ps"===t.type&&t.target instanceof ui?(t.target.system.restart(),this._batchedRenderer&&this._batchedRenderer.addSystem(t.target.system)):t.clip?.play?.()})}setTime(t){const e=this.currentTime;this.currentTime=t,this.animationData.forEach(i=>{const s=i.startTime,r=i.startTime+i.duration,n=this.currentTime>=s&&this.currentTime<r,o=e>=s&&e<r;!n||o?n||!o?n&&"three"===i.type&&i.clip?.setTime?.(Math.max(t-s,0)):"ps"===i.type&&i.target instanceof ui?i.target.system.endEmit():i.clip?.stop?.():"ps"===i.type&&i.target instanceof ui?i.target.system.restart():i.clip?.play?.()})}getDuration(){return this.duration}resolveReferences(t){const i={},s=t=>{t._quarksUUID&&(i[t._quarksUUID]=t),i[t.uniqueId.toString()]=t;const r=t.getChildren();for(const t of r)t instanceof e.TransformNode&&s(t)};s(t),this._tempAnimationJSON.forEach(t=>{const e=i[t.targetUUID];if("ps"===t.type&&e instanceof ui)this.addParticleSystemAnimation(e,t.startTime,t.duration,t.loop);else if("three"===t.type&&e){const i=this.resolveTimelineClip(e,t.clipUUID);this.addThreeAnimation(e,i,t.startTime,t.duration,t.loop,t.clipUUID)}}),this.updateDuration(),this._tempAnimationJSON=[]}toJSON(){return{type:this.type,name:this.name,animationData:this.animationData.map(t=>({startTime:t.startTime,duration:t.duration,type:t.type,targetUUID:t.target._quarksUUID??t.target.uniqueId.toString(),clipUUID:"three"===t.type?t.clipUUID??t.clip?.uuid:void 0,loop:t.loop}))}}static fromJSON(t,e){const i=new wi(t.name||"QuarksPrefab",e);return Array.isArray(t.animationData)&&(i._tempAnimationJSON=t.animationData.filter(t=>"ps"===t?.type||"three"===t?.type)),i}resolveTimelineClip(t,e){const i=[t.animations,t.animationGroups,t.metadata?.animations,t.metadata?.animationGroups];for(const t of i){if(!Array.isArray(t))continue;if(!e)return t[0];const i=t.find(t=>t?.uuid===e);if(i)return i}}updateDuration(){let t=0;this.animationData.forEach(e=>{const i=e.startTime+e.duration;i>t&&(t=i)}),this.duration=t}}class bi extends c.StandardMaterial{constructor(t,e,i={}){super(t,e),this.isParticleMeshStandardMaterial=!0,Object.assign(this,i)}}class _i extends u.PBRMaterial{constructor(t,e,i={}){super(t,e),this.isParticleMeshPhysicsMaterial=!0,Object.assign(this,i)}}Ze(),Xe(je),exports.ApplyCollision=Je,exports.ApplyForce=pe,exports.ApplySequences=Ee,exports.AxisAngleGenerator=Pt,exports.BatchedParticleRenderer=ci,exports.BatchedRenderer=li,exports.BehaviorFromJSON=Ge,exports.BehaviorTypes=qe,exports.Bezier=ht,exports.ChangeEmitDirection=fe,exports.CircleEmitter=Et,exports.ColorBySpeed=Ie,exports.ColorGeneratorFromJSON=Mt,exports.ColorOverLife=Ht,exports.ColorRange=pt,exports.ConeEmitter=At,exports.ConstantColor=St,exports.ConstantValue=wt,exports.DEG2RAD=p,exports.DonutEmitter=Ut,exports.EmitSubParticleSystem=ge,exports.EmitterFromJSON=jt,exports.EmitterShapes=Wt,exports.Euler=et,exports.EulerGenerator=Bt,exports.ForceOverLife=Kt,exports.FrameOverLife=oe,exports.GeneratorFromJSON=Ft,exports.Gradient=xt,exports.GravityForce=ye,exports.GridEmitter=Qt,exports.HemisphereEmitter=Gt,exports.InheritVelocity=se,exports.IntervalValue=bt,exports.LimitSpeedOverLife=Le,exports.MathUtils=J,exports.Matrix3=rt,exports.Matrix4=Q,exports.MeshSurfaceEmitter=We,exports.MeshSurfaceEmitterPlugin=je,exports.NodeParticle=class{constructor(){this.position=new k,this.velocity=new k,this.age=0,this.life=1,this.size=new k,this.rotation=0,this.color=new st(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}},exports.Noise=Ve,exports.OrbitOverLife=ae,exports.ParticleEmitter=ui,exports.ParticleMeshPhysicsMaterial=_i,exports.ParticleMeshStandardMaterial=bi,exports.ParticleSystem=Si,exports.PiecewiseBezier=zt,exports.PiecewiseFunction=_t,exports.Plugins=Qe,exports.PointEmitter=Lt,exports.QuarksLoader=class{constructor(t,e={}){this.scene=t,this.options=e}async load(t){const e=this.options.baseUrl||t.substring(0,t.lastIndexOf("/")+1),i=await fetch(t),s=await i.json();return this.parse(s,e)}parse(t,e=""){const i={textures:{},geometries:{},materials:{}};t.geometries&&this.parseGeometries(t.geometries,i),t.images&&this.parseImages(t.images,e,i),t.textures&&this.parseTextures(t.textures,i),t.materials&&this.parseMaterials(t.materials,i);const s=this.parseObject(t.object,i);return this.linkReferences(s),s}parseGeometries(t,e){for(const i of t)if("PlaneGeometry"===i.type){const t=(i.width||1)/2,s=(i.height||1)/2;e.geometries[i.uuid]={positions:new Float32Array([-t,-s,0,t,-s,0,t,s,0,-t,s,0]),indices:new Uint32Array([0,1,2,0,2,3]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),normals:new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1])}}else if("SphereGeometry"===i.type)e.geometries[i.uuid]=this.parseSphereGeometry(i);else if("BufferGeometry"===i.type&&i.data){const t=this.parseBufferGeometry(i.data);e.geometries[i.uuid]=t}else"QuarksGeometry"===i.type&&(e.geometries[i.uuid]={positions:new Float32Array(i.positions??[]),indices:i.indices?new Uint32Array(i.indices):new Uint32Array(0),uvs:i.uvs?new Float32Array(i.uvs):void 0,normals:i.normals?new Float32Array(i.normals):void 0})}parseSphereGeometry(t){const e=t.radius??.5,i=Math.max(3,Math.floor(t.widthSegments??16)),s=Math.max(2,Math.floor(t.heightSegments??8)),r=t.phiStart??0,n=t.phiLength??2*Math.PI,o=t.thetaStart??0,a=t.thetaLength??Math.PI,h=[],l=[],c=[],u=[],d=[];let m=0;for(let t=0;t<=s;t++){const u=[],p=t/s,y=o+p*a;for(let t=0;t<=i;t++){const s=t/i,o=r+s*n,a=-e*Math.cos(o)*Math.sin(y),d=e*Math.cos(y),f=e*Math.sin(o)*Math.sin(y);h.push(a,d,f);const x=Math.hypot(a,d,f)||1;l.push(a/x,d/x,f/x),c.push(s,1-p),u.push(m++)}d.push(u)}const p=o<=0,y=o+a>=Math.PI;for(let t=0;t<s;t++)for(let e=0;e<i;e++){const i=d[t][e+1],r=d[t][e],n=d[t+1][e],o=d[t+1][e+1];0===t&&p||u.push(i,r,o),t===s-1&&y||u.push(r,n,o)}const f=h.length/3>65535?new Uint32Array(u):new Uint16Array(u);return{positions:new Float32Array(h),indices:f,uvs:new Float32Array(c),normals:new Float32Array(l)}}parseBufferGeometry(t){let e,i,s=new Float32Array(0),r=new Uint32Array(0);if(t.interleavedBuffers&&t.arrayBuffers){const r={};for(const[e,i]of Object.entries(t.interleavedBuffers)){const s=t.arrayBuffers[i.buffer];if(s){const t=new Float32Array(Array.isArray(s)?this.int32ArrayToFloat32(s):s);r[e]={data:t,stride:i.stride}}}if(t.attributes){if(t.attributes.position?.isInterleavedBufferAttribute){const e=t.attributes.position,i=r[e.data];i&&(s=this.extractInterleavedAttribute(i.data,i.stride,e.offset,e.itemSize))}if(t.attributes.uv?.isInterleavedBufferAttribute){const i=t.attributes.uv,s=r[i.data];s&&(e=this.extractInterleavedAttribute(s.data,s.stride,i.offset,i.itemSize))}if(t.attributes.normal?.isInterleavedBufferAttribute){const e=t.attributes.normal,s=r[e.data];s&&(i=this.extractInterleavedAttribute(s.data,s.stride,e.offset,e.itemSize))}}}else t.attributes&&(t.attributes.position?.array&&(s=new Float32Array(t.attributes.position.array)),t.attributes.uv?.array&&(e=new Float32Array(t.attributes.uv.array)),t.attributes.normal?.array&&(i=new Float32Array(t.attributes.normal.array)));return t.index&&(r="Uint16Array"===t.index.type?new Uint16Array(t.index.array):new Uint32Array(t.index.array)),r=di(s,r),{positions:s,indices:r,uvs:e,normals:i}}extractInterleavedAttribute(t,e,i,s){const r=Math.floor(t.length/e),n=new Float32Array(r*s);for(let o=0;o<r;o++)for(let r=0;r<s;r++)n[o*s+r]=t[o*e+i+r];return n}int32ArrayToFloat32(t){const e=new ArrayBuffer(4*t.length),i=new Int32Array(e);for(let e=0;e<t.length;e++)i[e]=t[e];return new Float32Array(e)}parseImages(t,e,i){this._images={};for(const i of t)this._images[i.uuid]=i.url?e+i.url:null}parseTextures(t,e){const i=this._images||{};for(const s of t){const t=i[s.image];if(t){const i=new l.Texture(t,this.scene);Array.isArray(s.wrap)&&(i.wrapU=this.mapWrapMode(s.wrap[0]),i.wrapV=this.mapWrapMode(s.wrap[1]??s.wrap[0])),Array.isArray(s.repeat)&&(i.uScale=s.repeat[0]??1,i.vScale=s.repeat[1]??1),Array.isArray(s.offset)&&(i.uOffset=s.offset[0]??0,i.vOffset=s.offset[1]??0),"number"==typeof s.rotation&&(i.wAng=s.rotation),e.textures[s.uuid]=i}else e.textures[s.uuid]=null}}mapWrapMode(t){switch(t){case 1001:return l.Texture.CLAMP_ADDRESSMODE;case 1002:return l.Texture.MIRROR_ADDRESSMODE;default:return l.Texture.WRAP_ADDRESSMODE}}parseMaterials(t,e){for(const i of t){const t={uuid:i.uuid,transparent:i.transparent??!0,blending:i.blending??1,side:i.side??2,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!1,alphaTest:i.alphaTest??0,texture:null},s=i.map??i.texture;if(s&&(t.texture=e.textures[s]||null),"number"==typeof i.alphaMode)t.alphaMode=i.alphaMode;else{const e={1:o.Constants.ALPHA_COMBINE,2:o.Constants.ALPHA_ADD,3:o.Constants.ALPHA_SUBTRACT,4:o.Constants.ALPHA_MULTIPLY};t.alphaMode=e[i.blending]||o.Constants.ALPHA_COMBINE}e.materials[i.uuid]=t}}getGeometry(t,e){if(e)return t.geometries[e]}getMaterial(t,e){if(!e)return;const i=Array.isArray(e)?e[0]:e;return t.materials[i]}createPlaceholderNode(t,i){const s=new e.TransformNode(i||t||"node",this.scene);return s.quarksOriginalType=t,s}createMeshNode(t,e){const s=new i.Mesh(t.name||t.type||"mesh",this.scene),n=this.getGeometry(e,t.geometry);if(n&&n.positions.length>0&&n.indices.length>0){const t=new r.VertexData;t.positions=n.positions,t.indices=n.indices,n.uvs&&n.uvs.length>0&&(t.uvs=n.uvs),n.normals&&n.normals.length>0&&(t.normals=n.normals),t.applyToMesh(s,!0)}const a=this.getMaterial(e,t.material);if(a){const t=new c.StandardMaterial(`quarks_loader_material_${a.uuid}`,this.scene);t.alphaMode=a.alphaMode??o.Constants.ALPHA_COMBINE,t.backFaceCulling=2!==a.side,t.alphaCutOff=a.alphaTest??0,t.disableDepthWrite=!a.depthWrite,a.texture&&(t.diffuseTexture=a.texture,t.opacityTexture=a.texture),s.material=t}return s}parseObject(t,i){let s;switch(t.type){case"QuarksPrefab":s=wi.fromJSON(t,this.scene);break;case"ParticleEmitter":if(t.ps){s=this.parseParticleSystem(t.ps,i).emitter;break}s=this.createPlaceholderNode(t.type,t.name);break;case"Mesh":case"SkinnedMesh":case"InstancedMesh":case"BatchedMesh":s=this.createMeshNode(t,i);break;case"Scene":case"Group":case"Object3D":case"PerspectiveCamera":case"OrthographicCamera":case"AmbientLight":case"DirectionalLight":case"PointLight":case"RectAreaLight":case"SpotLight":case"HemisphereLight":case"LightProbe":case"LOD":case"Line":case"LineSegments":case"LineLoop":case"PointCloud":case"Points":case"Sprite":case"Bone":s=this.createPlaceholderNode(t.type,t.name);break;default:s=new e.TransformNode(t.name||t.type||"node",this.scene)}if(t.uuid&&(s._quarksUUID=t.uuid),t.name&&(s.name=t.name),t.matrix){const e=a.Matrix.FromArray(t.matrix),i=new a.Vector3(1,1,1),r=a.Quaternion.Identity(),n=new a.Vector3(0,0,0);e.decompose(i,r,n),s.position.copyFrom(n),s.scaling.copyFrom(i),s.rotationQuaternion=r}else t.position&&s.position.set(t.position[0],t.position[1],t.position[2]),t.scale&&s.scaling.set(t.scale[0],t.scale[1],t.scale[2]),t.quaternion?s.rotationQuaternion=new a.Quaternion(t.quaternion[0],t.quaternion[1],t.quaternion[2],t.quaternion[3]):t.rotation&&s.rotation.set(t.rotation[0],t.rotation[1],t.rotation[2]);if(void 0!==t.visible&&s.setEnabled(t.visible),t.children)for(const e of t.children){this.parseObject(e,i).parent=s}return s}parseParticleSystem(t,e){const i=Si.fromJSON(t,e,{},this.scene);return i._meshSurfaceReferenceUUID="mesh_surface"===t?.shape?.type?t?.shape?.mesh:void 0,i}linkReferences(t){const s={},r=t=>{t._quarksUUID&&(s[t._quarksUUID]=t);for(const i of t.getChildren())i instanceof e.TransformNode&&r(i)};r(t);const n=r=>{if(r instanceof wi&&r.resolveReferences(t),r instanceof ui){const t=r.system,e=t._meshSurfaceReferenceUUID;if(e&&"mesh_surface"===t.emitterShape.type){const r=s[e];r instanceof i.Mesh&&(t.emitterShape.mesh=r)}for(let e=0;e<t.behaviors.length;e++)if(t.behaviors[e]instanceof ge){const i=t.behaviors[e],r=i.subParticleSystem;if("string"==typeof r&&s[r]){const t=s[r];i.subParticleSystem=t,t instanceof ui&&(t.system.onlyUsedByOther=!0)}}}for(const t of r.getChildren())t instanceof e.TransformNode&&n(t)};n(t)}},exports.QuarksPrefab=wi,exports.QuarksUtil=Mi,exports.Quaternion=I,exports.RAD2DEG=y,exports.RandomColor=mt,exports.RandomColorBetweenGradient=vt,exports.RandomQuatGenerator=Ot,exports.RecordState=ue,exports.RectangleEmitter=Xt,exports.Rotation3DOverLife=Zt,exports.RotationBySpeed=Ue,exports.RotationGeneratorFromJSON=Nt,exports.RotationOverLife=Yt,exports.SequencerFromJSON=Ae,exports.SizeBySpeed=ke,exports.SizeOverLife=re,exports.SpeedOverLife=ne,exports.SphereEmitter=qt,exports.SpriteBatch=ai,exports.SpriteParticle=ce,exports.TextureSequencer=Fe,exports.TrailBatch=hi,exports.TrailParticle=de,exports.TurbulenceField=Pe,exports.VFXBatch=oi,exports.ValueGeneratorFromJSON=Tt,exports.Vector2=it,exports.Vector3=k,exports.Vector3Function=Ct,exports.Vector3GeneratorFromJSON=Vt,exports.Vector4=st,exports.VelocityOverLife=ie,exports.WebGLCoordinateSystem=q,exports.WebGPUCoordinateSystem=G,exports.WidthOverLength=me,exports.ceilPowerOfTwo=F,exports.clamp=x,exports.damp=w,exports.degToRad=N,exports.denormalize=D,exports.euclideanModulo=g,exports.floorPowerOfTwo=A,exports.generateUUID=f,exports.getPhysicsResolver=Re,exports.getRegisteredShaderChunks=function(){return He},exports.getShaderChunk=function(t){return He[t]},exports.getValueFromEmitterMode=at,exports.inverseLerp=S,exports.isPowerOfTwo=V,exports.lerp=M,exports.loadPlugin=Xe,exports.localParticlePhysicsVertShader=ei,exports.localParticleVertShader="\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute vec4 rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 qVec = q.xyz;\n float qW = q.w;\n vec3 t = 2.0 * cross(qVec, v);\n return v + qW * t + cross(qVec, t);\n}\n\nvoid main() {\n vec3 rotatedPosition = applyQuaternion(position * size, rotation);\n vec3 worldPos = rotatedPosition + offset;\n\n gl_Position = worldViewProjection * vec4(worldPos, 1.0);\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n",exports.mapLinear=v,exports.normalize=R,exports.particleFragShader=ti,exports.particlePhysicsFragShader=ii,exports.particleVertShader=$e,exports.pingpong=b,exports.radToDeg=C,exports.randFloat=O,exports.randFloatSpread=P,exports.randInt=T,exports.registerShaderChunks=Ze,exports.seededRandom=B,exports.setPhysicsResolver=function(t){De=t},exports.setQuaternionFromProperEuler=E,exports.smootherstep=z,exports.smoothstep=_,exports.stretchedBillboardVertShader=si,exports.trailFragShader=ni,exports.trailVertShader=ri,exports.unloadPlugin=function(t){const e=Qe.find(e=>e.id===t);if(e){for(const t of e.emitterShapes)Wt[t.type]&&delete Wt[t.type];for(const t of e.behaviors)qe[t.type]&&delete qe[t.type]}};
1
+ "use strict";var t=require("@babylonjs/core/Buffers/buffer"),e=require("@babylonjs/core/Meshes/transformNode"),i=require("@babylonjs/core/Meshes/mesh"),s=require("@babylonjs/core/Materials/shaderMaterial"),r=require("@babylonjs/core/Meshes/mesh.vertexData"),n=require("@babylonjs/core/Materials/effect"),o=require("@babylonjs/core/Engines/constants"),a=require("@babylonjs/core/Maths/math.vector"),h=require("@babylonjs/core/Culling/boundingInfo"),l=require("@babylonjs/core/Materials/Textures/texture"),c=require("@babylonjs/core/Materials/standardMaterial"),u=require("@babylonjs/core/Materials/PBR/pbrMaterial");const d=["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 m=1234567;const p=Math.PI/180,y=180/Math.PI;function f(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return(d[255&t]+d[t>>8&255]+d[t>>16&255]+d[t>>24&255]+"-"+d[255&e]+d[e>>8&255]+"-"+d[e>>16&15|64]+d[e>>24&255]+"-"+d[63&i|128]+d[i>>8&255]+"-"+d[i>>16&255]+d[i>>24&255]+d[255&s]+d[s>>8&255]+d[s>>16&255]+d[s>>24&255]).toLowerCase()}function x(t,e,i){return Math.max(e,Math.min(i,t))}function g(t,e){return(t%e+e)%e}function v(t,e,i,s,r){return s+(t-e)*(r-s)/(i-e)}function S(t,e,i){return t!==e?(i-t)/(e-t):0}function M(t,e,i){return(1-i)*t+i*e}function w(t,e,i,s){return M(t,e,1-Math.exp(-i*s))}function b(t,e=1){return e-Math.abs(g(t,2*e)-e)}function _(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*(3-2*t)}function z(t,e,i){return t<=e?0:t>=i?1:(t=(t-e)/(i-e))*t*t*(t*(6*t-15)+10)}function T(t,e){return t+Math.floor(Math.random()*(e-t+1))}function O(t,e){return t+Math.random()*(e-t)}function B(t){return t*(.5-Math.random())}function P(t){void 0!==t&&(m=t);let e=m+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}function N(t){return t*p}function C(t){return t*y}function V(t){return!(t&t-1)&&0!==t}function F(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function A(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function E(t,e,i,s,r){const n=Math.cos,o=Math.sin,a=n(i/2),h=o(i/2),l=n((e+s)/2),c=o((e+s)/2),u=n((e-s)/2),d=o((e-s)/2),m=n((s-e)/2),p=o((s-e)/2);switch(r){case"XYX":t.set(a*c,h*u,h*d,a*l);break;case"YZY":t.set(h*d,a*c,h*u,a*l);break;case"ZXZ":t.set(h*u,h*d,a*c,a*l);break;case"XZX":t.set(a*c,h*p,h*m,a*l);break;case"YXY":t.set(h*m,a*c,h*p,a*l);break;case"ZYZ":t.set(h*p,h*m,a*c,a*l);break;default:console.warn("../math.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function D(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.")}}function R(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.")}}const J={DEG2RAD:p,RAD2DEG:y,generateUUID:f,clamp:x,euclideanModulo:g,mapLinear:v,inverseLerp:S,lerp:M,damp:w,pingpong:b,smoothstep:_,smootherstep:z,randInt:T,randFloat:O,randFloatSpread:B,seededRandom:P,degToRad:N,radToDeg:C,isPowerOfTwo:V,ceilPowerOfTwo:F,floorPowerOfTwo:A,setQuaternionFromProperEuler:E,normalize:R,denormalize:D};class I{constructor(t=0,e=0,i=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=s}static slerpFlat(t,e,i,s,r,n,o){let a=i[s+0],h=i[s+1],l=i[s+2],c=i[s+3];const u=r[n+0],d=r[n+1],m=r[n+2],p=r[n+3];if(0===o)return t[e+0]=a,t[e+1]=h,t[e+2]=l,void(t[e+3]=c);if(1===o)return t[e+0]=u,t[e+1]=d,t[e+2]=m,void(t[e+3]=p);if(c!==p||a!==u||h!==d||l!==m){let t=1-o;const e=a*u+h*d+l*m+c*p,i=e>=0?1:-1,s=1-e*e;if(s>Number.EPSILON){const r=Math.sqrt(s),n=Math.atan2(r,e*i);t=Math.sin(t*n)/r,o=Math.sin(o*n)/r}const r=o*i;if(a=a*t+u*r,h=h*t+d*r,l=l*t+m*r,c=c*t+p*r,t===1-o){const t=1/Math.sqrt(a*a+h*h+l*l+c*c);a*=t,h*=t,l*=t,c*=t}}t[e]=a,t[e+1]=h,t[e+2]=l,t[e+3]=c}static multiplyQuaternionsFlat(t,e,i,s,r,n){const o=i[s],a=i[s+1],h=i[s+2],l=i[s+3],c=r[n],u=r[n+1],d=r[n+2],m=r[n+3];return t[e]=o*m+l*c+a*d-h*u,t[e+1]=a*m+l*u+h*c-o*d,t[e+2]=h*m+l*d+o*u-a*c,t[e+3]=l*m-o*c-a*u-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,s){return this._x=t,this._y=e,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new I(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,s=t._y,r=t._z,n=t._order,o=Math.cos,a=Math.sin,h=o(i/2),l=o(s/2),c=o(r/2),u=a(i/2),d=a(s/2),m=a(r/2);switch(n){case"XYZ":this._x=u*l*c+h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c-u*d*m;break;case"YXZ":this._x=u*l*c+h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c+u*d*m;break;case"ZXY":this._x=u*l*c-h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c-u*d*m;break;case"ZYX":this._x=u*l*c-h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c+u*d*m;break;case"YZX":this._x=u*l*c+h*d*m,this._y=h*d*c+u*l*m,this._z=h*l*m-u*d*c,this._w=h*l*c-u*d*m;break;case"XZY":this._x=u*l*c-h*d*m,this._y=h*d*c-u*l*m,this._z=h*l*m+u*d*c,this._w=h*l*c+u*d*m;break;default:console.warn("../math.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===e&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,s=Math.sin(i);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],s=e[4],r=e[8],n=e[1],o=e[5],a=e[9],h=e[2],l=e[6],c=e[10],u=i+o+c;if(u>0){const t=.5/Math.sqrt(u+1);this._w=.25/t,this._x=(l-a)*t,this._y=(r-h)*t,this._z=(n-s)*t}else if(i>o&&i>c){const t=2*Math.sqrt(1+i-o-c);this._w=(l-a)/t,this._x=.25*t,this._y=(s+n)/t,this._z=(r+h)/t}else if(o>c){const t=2*Math.sqrt(1+o-i-c);this._w=(r-h)/t,this._x=(s+n)/t,this._y=.25*t,this._z=(a+l)/t}else{const t=2*Math.sqrt(1+c-i-o);this._w=(n-s)/t,this._x=(r+h)/t,this._y=(a+l)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(x(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(0===i)return this;const s=Math.min(1,e/i);return this.slerp(t,s),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,s=t._y,r=t._z,n=t._w,o=e._x,a=e._y,h=e._z,l=e._w;return this._x=i*l+n*o+s*h-r*a,this._y=s*l+n*a+r*o-i*h,this._z=r*l+n*h+i*a-s*o,this._w=n*l-i*o-s*a-r*h,this._onChangeCallback(),this}slerp(t,e){if(0===e)return this;if(1===e)return this.copy(t);const i=this._x,s=this._y,r=this._z,n=this._w;let o=n*t._w+i*t._x+s*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=n,this._x=i,this._y=s,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const t=1-e;return this._w=t*n+e*this._w,this._x=t*i+e*this._x,this._y=t*s+e*this._y,this._z=t*r+e*this._z,this.normalize(),this}const h=Math.sqrt(a),l=Math.atan2(h,o),c=Math.sin((1-e)*l)/h,u=Math.sin(e*l)/h;return this._w=n*c+this._w*u,this._x=i*c+this._x*u,this._y=s*c+this._y*u,this._z=r*c+this._z*u,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(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(t),s*Math.cos(t),r*Math.sin(e),r*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 k{constructor(t=0,e=0,i=0){this.isVector3=!0,k.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 k(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(L.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(L.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6]*s,this.y=r[1]*e+r[4]*i+r[7]*s,this.z=r[2]*e+r[5]*i+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,s=this.z,r=t.elements,n=1/(r[3]*e+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*i+r[8]*s+r[12])*n,this.y=(r[1]*e+r[5]*i+r[9]*s+r[13])*n,this.z=(r[2]*e+r[6]*i+r[10]*s+r[14])*n,this}applyQuaternion(t){const e=this.x,i=this.y,s=this.z,r=t.x,n=t.y,o=t.z,a=t.w,h=2*(n*s-o*i),l=2*(o*e-r*s),c=2*(r*i-n*e);return this.x=e+a*h+n*c-o*l,this.y=i+a*l+o*h-r*c,this.z=s+a*c+r*l-n*h,this}transformDirection(t){const e=this.x,i=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*s,this.y=r[1]*e+r[5]*i+r[9]*s,this.z=r[2]*e+r[6]*i+r[10]*s,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,s=t.y,r=t.z,n=e.x,o=e.y,a=e.z;return this.x=s*a-r*o,this.y=r*n-i*a,this.z=i*o-s*n,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 U.copy(this).projectOnVector(t),this.sub(U)}reflect(t){return this.sub(U.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(x(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,s=this.z-t.z;return e*e+i*i+s*s}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 s=Math.sin(e)*t;return this.x=s*Math.sin(i),this.y=Math.cos(e)*t,this.z=s*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(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=s,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 U=new k,L=new I,q=2e3,G=2001;class Q{constructor(t,e,i,s,r,n,o,a,h,l,c,u,d,m,p,y){this.isMatrix4=!0,Q.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,s,r,n,o,a,h,l,c,u,d,m,p,y)}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,s,r,n,o,a,h,l,c,u,d,m,p,y){const f=this.elements;return f[0]=t,f[4]=e,f[8]=i,f[12]=s,f[1]=r,f[5]=n,f[9]=o,f[13]=a,f[2]=h,f[6]=l,f[10]=c,f[14]=u,f[3]=d,f[7]=m,f[11]=p,f[15]=y,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 Q).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,s=1/X.setFromMatrixColumn(t,0).length(),r=1/X.setFromMatrixColumn(t,1).length(),n=1/X.setFromMatrixColumn(t,2).length();return e[0]=i[0]*s,e[1]=i[1]*s,e[2]=i[2]*s,e[3]=0,e[4]=i[4]*r,e[5]=i[5]*r,e[6]=i[6]*r,e[7]=0,e[8]=i[8]*n,e[9]=i[9]*n,e[10]=i[10]*n,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,s=t.y,r=t.z,n=Math.cos(i),o=Math.sin(i),a=Math.cos(s),h=Math.sin(s),l=Math.cos(r),c=Math.sin(r);if("XYZ"===t.order){const t=n*l,i=n*c,s=o*l,r=o*c;e[0]=a*l,e[4]=-a*c,e[8]=h,e[1]=i+s*h,e[5]=t-r*h,e[9]=-o*a,e[2]=r-t*h,e[6]=s+i*h,e[10]=n*a}else if("YXZ"===t.order){const t=a*l,i=a*c,s=h*l,r=h*c;e[0]=t+r*o,e[4]=s*o-i,e[8]=n*h,e[1]=n*c,e[5]=n*l,e[9]=-o,e[2]=i*o-s,e[6]=r+t*o,e[10]=n*a}else if("ZXY"===t.order){const t=a*l,i=a*c,s=h*l,r=h*c;e[0]=t-r*o,e[4]=-n*c,e[8]=s+i*o,e[1]=i+s*o,e[5]=n*l,e[9]=r-t*o,e[2]=-n*h,e[6]=o,e[10]=n*a}else if("ZYX"===t.order){const t=n*l,i=n*c,s=o*l,r=o*c;e[0]=a*l,e[4]=s*h-i,e[8]=t*h+r,e[1]=a*c,e[5]=r*h+t,e[9]=i*h-s,e[2]=-h,e[6]=o*a,e[10]=n*a}else if("YZX"===t.order){const t=n*a,i=n*h,s=o*a,r=o*h;e[0]=a*l,e[4]=r-t*c,e[8]=s*c+i,e[1]=c,e[5]=n*l,e[9]=-o*l,e[2]=-h*l,e[6]=i*c+s,e[10]=t-r*c}else if("XZY"===t.order){const t=n*a,i=n*h,s=o*a,r=o*h;e[0]=a*l,e[4]=-c,e[8]=h*l,e[1]=t*c+r,e[5]=n*l,e[9]=i*c-s,e[2]=s*c-i,e[6]=o*l,e[10]=r*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(j,t,H)}lookAt(t,e,i){const s=this.elements;return K.subVectors(t,e),0===K.lengthSq()&&(K.z=1),K.normalize(),Y.crossVectors(i,K),0===Y.lengthSq()&&(1===Math.abs(i.z)?K.x+=1e-4:K.z+=1e-4,K.normalize(),Y.crossVectors(i,K)),Y.normalize(),Z.crossVectors(K,Y),s[0]=Y.x,s[4]=Z.x,s[8]=K.x,s[1]=Y.y,s[5]=Z.y,s[9]=K.y,s[2]=Y.z,s[6]=Z.z,s[10]=K.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,n=i[0],o=i[4],a=i[8],h=i[12],l=i[1],c=i[5],u=i[9],d=i[13],m=i[2],p=i[6],y=i[10],f=i[14],x=i[3],g=i[7],v=i[11],S=i[15],M=s[0],w=s[4],b=s[8],_=s[12],z=s[1],T=s[5],O=s[9],B=s[13],P=s[2],N=s[6],C=s[10],V=s[14],F=s[3],A=s[7],E=s[11],D=s[15];return r[0]=n*M+o*z+a*P+h*F,r[4]=n*w+o*T+a*N+h*A,r[8]=n*b+o*O+a*C+h*E,r[12]=n*_+o*B+a*V+h*D,r[1]=l*M+c*z+u*P+d*F,r[5]=l*w+c*T+u*N+d*A,r[9]=l*b+c*O+u*C+d*E,r[13]=l*_+c*B+u*V+d*D,r[2]=m*M+p*z+y*P+f*F,r[6]=m*w+p*T+y*N+f*A,r[10]=m*b+p*O+y*C+f*E,r[14]=m*_+p*B+y*V+f*D,r[3]=x*M+g*z+v*P+S*F,r[7]=x*w+g*T+v*N+S*A,r[11]=x*b+g*O+v*C+S*E,r[15]=x*_+g*B+v*V+S*D,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],s=t[8],r=t[12],n=t[1],o=t[5],a=t[9],h=t[13],l=t[2],c=t[6],u=t[10],d=t[14];return t[3]*(+r*a*c-s*h*c-r*o*u+i*h*u+s*o*d-i*a*d)+t[7]*(+e*a*d-e*h*u+r*n*u-s*n*d+s*h*l-r*a*l)+t[11]*(+e*h*c-e*o*d-r*n*c+i*n*d+r*o*l-i*h*l)+t[15]*(-s*o*l-e*a*c+e*o*u+s*n*c-i*n*u+i*a*l)}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 s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],l=t[8],c=t[9],u=t[10],d=t[11],m=t[12],p=t[13],y=t[14],f=t[15],x=c*y*h-p*u*h+p*a*d-o*y*d-c*a*f+o*u*f,g=m*u*h-l*y*h-m*a*d+n*y*d+l*a*f-n*u*f,v=l*p*h-m*c*h+m*o*d-n*p*d-l*o*f+n*c*f,S=m*c*a-l*p*a-m*o*u+n*p*u+l*o*y-n*c*y,M=e*x+i*g+s*v+r*S;if(0===M)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const w=1/M;return t[0]=x*w,t[1]=(p*u*r-c*y*r-p*s*d+i*y*d+c*s*f-i*u*f)*w,t[2]=(o*y*r-p*a*r+p*s*h-i*y*h-o*s*f+i*a*f)*w,t[3]=(c*a*r-o*u*r-c*s*h+i*u*h+o*s*d-i*a*d)*w,t[4]=g*w,t[5]=(l*y*r-m*u*r+m*s*d-e*y*d-l*s*f+e*u*f)*w,t[6]=(m*a*r-n*y*r-m*s*h+e*y*h+n*s*f-e*a*f)*w,t[7]=(n*u*r-l*a*r+l*s*h-e*u*h-n*s*d+e*a*d)*w,t[8]=v*w,t[9]=(m*c*r-l*p*r-m*i*d+e*p*d+l*i*f-e*c*f)*w,t[10]=(n*p*r-m*o*r+m*i*h-e*p*h-n*i*f+e*o*f)*w,t[11]=(l*o*r-n*c*r-l*i*h+e*c*h+n*i*d-e*o*d)*w,t[12]=S*w,t[13]=(l*p*s-m*c*s+m*i*u-e*p*u-l*i*y+e*c*y)*w,t[14]=(m*o*s-n*p*s-m*i*a+e*p*a+n*i*y-e*o*y)*w,t[15]=(n*c*s-l*o*s+l*i*a-e*c*a-n*i*u+e*o*u)*w,this}scale(t){const e=this.elements,i=t.x,s=t.y,r=t.z;return e[0]*=i,e[4]*=s,e[8]*=r,e[1]*=i,e[5]*=s,e[9]*=r,e[2]*=i,e[6]*=s,e[10]*=r,e[3]*=i,e[7]*=s,e[11]*=r,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],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,s))}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),s=Math.sin(e),r=1-i,n=t.x,o=t.y,a=t.z,h=r*n,l=r*o;return this.set(h*n+i,h*o-s*a,h*a+s*o,0,h*o+s*a,l*o+i,l*a-s*n,0,h*a-s*o,l*a+s*n,r*a*a+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,s,r,n){return this.set(1,i,r,0,t,1,n,0,e,s,1,0,0,0,0,1),this}compose(t,e,i){const s=this.elements,r=e._x,n=e._y,o=e._z,a=e._w,h=r+r,l=n+n,c=o+o,u=r*h,d=r*l,m=r*c,p=n*l,y=n*c,f=o*c,x=a*h,g=a*l,v=a*c,S=i.x,M=i.y,w=i.z;return s[0]=(1-(p+f))*S,s[1]=(d+v)*S,s[2]=(m-g)*S,s[3]=0,s[4]=(d-v)*M,s[5]=(1-(u+f))*M,s[6]=(y+x)*M,s[7]=0,s[8]=(m+g)*w,s[9]=(y-x)*w,s[10]=(1-(u+p))*w,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,i){const s=this.elements;let r=X.set(s[0],s[1],s[2]).length();const n=X.set(s[4],s[5],s[6]).length(),o=X.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),t.x=s[12],t.y=s[13],t.z=s[14],W.copy(this);const a=1/r,h=1/n,l=1/o;return W.elements[0]*=a,W.elements[1]*=a,W.elements[2]*=a,W.elements[4]*=h,W.elements[5]*=h,W.elements[6]*=h,W.elements[8]*=l,W.elements[9]*=l,W.elements[10]*=l,e.setFromRotationMatrix(W),i.x=r,i.y=n,i.z=o,this}makePerspective(t,e,i,s,r,n,o=2e3){const a=this.elements,h=2*r/(e-t),l=2*r/(i-s),c=(e+t)/(e-t),u=(i+s)/(i-s);let d,m;if(o===q)d=-(n+r)/(n-r),m=-2*n*r/(n-r);else{if(o!==G)throw new Error("Matrix4.makePerspective(): Invalid coordinate system: "+o);d=-n/(n-r),m=-n*r/(n-r)}return a[0]=h,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=m,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(t,e,i,s,r,n,o=2e3){const a=this.elements,h=1/(e-t),l=1/(i-s),c=1/(n-r),u=(e+t)*h,d=(i+s)*l;let m,p;if(o===q)m=(n+r)*c,p=-2*c;else{if(o!==G)throw new Error("../math.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);m=r*c,p=-1*c}return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=p,a[14]=-m,a[3]=0,a[7]=0,a[11]=0,a[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 X=new k,W=new Q,j=new k(0,0,0),H=new k(1,1,1),Y=new k,Z=new k,K=new k,$=new Q,tt=new I;class et{constructor(t=0,e=0,i=0,s=et.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=s}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,s=this._order){return this._x=t,this._y=e,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new et(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 s=t.elements,r=s[0],n=s[4],o=s[8],a=s[1],h=s[5],l=s[9],c=s[2],u=s[6],d=s[10];switch(e){case"XYZ":this._y=Math.asin(x(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(u,h),this._z=0);break;case"YXZ":this._x=Math.asin(-x(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-c,r),this._z=0);break;case"ZXY":this._x=Math.asin(x(u,-1,1)),Math.abs(u)<.9999999?(this._y=Math.atan2(-c,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-x(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(u,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin(x(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-c,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-x(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(u,h),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,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 $.makeRotationFromQuaternion(t),this.setFromRotationMatrix($,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return tt.setFromEuler(this),this.setFromQuaternion(tt,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}}et.DEFAULT_ORDER="XYZ";class it{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 it(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,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6],this.y=s[1]*e+s[4]*i+s[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(x(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),s=Math.sin(e),r=this.x-t.x,n=this.y-t.y;return this.x=r*i-n*s+t.x,this.y=r*s+n*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}it.isVector2=!0;class st{constructor(t=0,e=0,i=0,s=1){st.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=s}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,s){return this.x=t,this.y=e,this.z=i,this.w=s,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 st(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,s=this.z,r=this.w,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*s+n[12]*r,this.y=n[1]*e+n[5]*i+n[9]*s+n[13]*r,this.z=n[2]*e+n[6]*i+n[10]*s+n[14]*r,this.w=n[3]*e+n[7]*i+n[11]*s+n[15]*r,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,s,r;const n=.01,o=.1,a=t.elements,h=a[0],l=a[4],c=a[8],u=a[1],d=a[5],m=a[9],p=a[2],y=a[6],f=a[10];if(Math.abs(l-u)<n&&Math.abs(c-p)<n&&Math.abs(m-y)<n){if(Math.abs(l+u)<o&&Math.abs(c+p)<o&&Math.abs(m+y)<o&&Math.abs(h+d+f-3)<o)return this.set(1,0,0,0),this;e=Math.PI;const t=(h+1)/2,a=(d+1)/2,x=(f+1)/2,g=(l+u)/4,v=(c+p)/4,S=(m+y)/4;return t>a&&t>x?t<n?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(t),s=g/i,r=v/i):a>x?a<n?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(a),i=g/s,r=S/s):x<n?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(x),i=v/r,s=S/r),this.set(i,s,r,e),this}let x=Math.sqrt((y-m)*(y-m)+(c-p)*(c-p)+(u-l)*(u-l));return Math.abs(x)<.001&&(x=1),this.x=(y-m)/x,this.y=(c-p)/x,this.z=(u-l)/x,this.w=Math.acos((h+d+f-1)/2),this}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.w=Math.min(this.w,t.w),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.w=Math.max(this.w,t.w),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.w=Math.max(t.w,Math.min(e.w,this.w)),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.w=Math.max(t,Math.min(e,this.w)),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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(t.w-this.w)*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.w=t.w+(e.w-t.w)*i,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class rt{constructor(t,e,i,s,r,n,o,a,h){rt.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,e,i,s,r,n,o,a,h)}set(t,e,i,s,r,n,o,a,h){const l=this.elements;return l[0]=t,l[1]=s,l[2]=o,l[3]=e,l[4]=r,l[5]=a,l[6]=i,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}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],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,s=e.elements,r=this.elements,n=i[0],o=i[3],a=i[6],h=i[1],l=i[4],c=i[7],u=i[2],d=i[5],m=i[8],p=s[0],y=s[3],f=s[6],x=s[1],g=s[4],v=s[7],S=s[2],M=s[5],w=s[8];return r[0]=n*p+o*x+a*S,r[3]=n*y+o*g+a*M,r[6]=n*f+o*v+a*w,r[1]=h*p+l*x+c*S,r[4]=h*y+l*g+c*M,r[7]=h*f+l*v+c*w,r[2]=u*p+d*x+m*S,r[5]=u*y+d*g+m*M,r[8]=u*f+d*v+m*w,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],l=t[8];return e*n*l-e*o*h-i*r*l+i*o*a+s*r*h-s*n*a}invert(){const t=this.elements,e=t[0],i=t[1],s=t[2],r=t[3],n=t[4],o=t[5],a=t[6],h=t[7],l=t[8],c=l*n-o*h,u=o*a-l*r,d=h*r-n*a,m=e*c+i*u+s*d;if(0===m)return this.set(0,0,0,0,0,0,0,0,0);const p=1/m;return t[0]=c*p,t[1]=(s*h-l*i)*p,t[2]=(o*i-s*n)*p,t[3]=u*p,t[4]=(l*e-s*a)*p,t[5]=(s*r-o*e)*p,t[6]=d*p,t[7]=(i*a-h*e)*p,t[8]=(n*e-i*r)*p,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,s,r,n,o){const a=Math.cos(r),h=Math.sin(r);return this.set(i*a,i*h,-i*(a*n+h*o)+n+t,-s*h,s*a,-s*(-h*n+a*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(nt.makeScale(t,e)),this}rotate(t){return this.premultiply(nt.makeRotation(-t)),this}translate(t,e){return this.premultiply(nt.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let t=0;t<9;t++)if(e[t]!==i[t])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;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}clone(){return(new rt).fromArray(this.elements)}}const nt=new rt;var ot;function at(t,e,i,s){let r;switch(exports.EmitterMode.Random===t?e=Math.random():exports.EmitterMode.Burst===t&&s.isBursting&&(e=s.burstParticleIndex/s.burstParticleCount),r=i>0?Math.floor(e/i)*i:e,t){case exports.EmitterMode.Loop:r%=1;break;case exports.EmitterMode.PingPong:r=Math.abs(r%2-1)}return r}exports.EmitterMode=void 0,(ot=exports.EmitterMode||(exports.EmitterMode={}))[ot.Random=0]="Random",ot[ot.Loop=1]="Loop",ot[ot.PingPong=2]="PingPong",ot[ot.Burst=3]="Burst";class ht{constructor(t,e,i,s){this.p=[t,e,i,s]}genValue(t){const e=t*t,i=t*t*t,s=1-t,r=s*s,n=r*s;return this.p[0]*n+this.p[1]*r*t*3+this.p[2]*s*e*3+this.p[3]*i}derivativeCoefficients(t){const e=[];for(let i=t,s=i.length-1;s>0;s--){const t=[];for(let e=0;e<s;e++){const r=s*(i[e+1]-i[e]);t.push(r)}e.push(t),i=t}return e}getSlope(t){const e=this.derivativeCoefficients(this.p)[0],i=1-t,s=i*t*2,r=t*t;return i*i*e[0]+s*e[1]+r*e[2]}controlCurve(t,e){this.p[1]=t/3+this.p[0],this.p[2]=this.p[3]-e/3}hull(t){let e,i=this.p,s=[],r=0,n=0,o=0;const a=[];for(a[r++]=i[0],a[r++]=i[1],a[r++]=i[2],a[r++]=i[3];i.length>1;){for(s=[],n=0,o=i.length-1;n<o;n++)e=t*i[n]+(1-t)*i[n+1],a[r++]=e,s.push(e);i=s}return a}split(t){const e=this.hull(t);return{left:new ht(e[0],e[4],e[7],e[9]),right:new ht(e[9],e[8],e[6],e[3]),span:e}}clone(){return new ht(this.p[0],this.p[1],this.p[2],this.p[3])}toJSON(){return{p0:this.p[0],p1:this.p[1],p2:this.p[2],p3:this.p[3]}}static fromJSON(t){return new ht(t.p0,t.p1,t.p2,t.p3)}}const lt=t=>({r:t.x,g:t.y,b:t.z,a:t.w}),ct=t=>new st(t.r,t.g,t.b,t.a),ut=(t,e)=>{switch(e){case"Vector3":return new k(t.x,t.y,t.z);case"Vector4":return new st(t.x,t.y,t.z,t.w);case"Color":return new k(t.r,t.g,t.b);default:return t}},dt=(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 mt{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:lt(this.a),b:lt(this.b)}}static fromJSON(t){return new mt(ct(t.a),ct(t.b))}clone(){return new mt(this.a.clone(),this.b.clone())}}class pt{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:lt(this.a),b:lt(this.b)}}static fromJSON(t){return new pt(ct(t.a),ct(t.b))}clone(){return new pt(this.a.clone(),this.b.clone())}}class yt{constructor(t,e){this.subType=e,this.type="function",this.keys=t}findKey(t){let e=0,i=0,s=this.keys.length-1;for(;i+1<s;)if(e=Math.floor((i+s)/2),t<this.getStartX(e))s=e-1;else{if(!(t>this.getEndX(e)))return e;i=e+1}for(let e=i;e<=s;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[t+1][1]:1}genValue(t,e){const i=this.findKey(e);return"Number"===this.subType?-1===i?this.keys[0][0]:i+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:dt(t,this.subType),pos:e}))}}static fromJSON(t){return new yt(t.keys.map(e=>[ut(e.value,t.subType),e.pos]),t.subType)}clone(){return"Number"===this.subType?new yt(this.keys.map(([t,e])=>[t,e]),this.subType):new yt(this.keys.map(([t,e])=>[t.clone(),e]),this.subType)}}const ft=new k;class xt{constructor(t=[[new k(0,0,0),0],[new k(1,1,1),0]],e=[[1,0],[1,1]]){this.type="function",this.color=new yt(t,"Color"),this.alpha=new yt(e,"Number")}genColor(t,e,i){return this.color.genValue(ft,i),e.set(ft.x,ft.y,ft.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=>[pt.fromJSON(t.function).a,t.start]);return t.functions.length>0&&e.push([pt.fromJSON(t.functions[t.functions.length-1].function).b,1]),new xt(e.map(t=>[new k(t[0].x,t[0].y,t[0].z),t[1]]),e.map(t=>[t[0].w,t[1]]))}{const e=new xt;return e.alpha=yt.fromJSON(t.alpha),e.color=yt.fromJSON(t.color),e}}clone(){const t=new xt;return t.alpha=this.alpha.clone(),t.color=this.color.clone(),t}startGen(t){}}const gt=new st;class vt{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,gt,i),t&&void 0!==t[this.indexCount]?e.lerp(gt,t[this.indexCount]):e.lerp(gt,Math.random()),e}toJSON(){return{type:"RandomColorBetweenGradient",gradient1:this.gradient1.toJSON(),gradient2:this.gradient2.toJSON()}}static fromJSON(t){return new vt(xt.fromJSON(t.gradient1),xt.fromJSON(t.gradient2))}clone(){return new vt(this.gradient1.clone(),this.gradient2.clone())}}class St{constructor(t){this.color=t,this.type="value"}startGen(t){}genColor(t,e){return e.copy(this.color)}toJSON(){return{type:"ConstantColor",color:lt(this.color)}}static fromJSON(t){return new St(ct(t.color))}clone(){return new St(this.color.clone())}}function Mt(t){switch(t.type){case"ConstantColor":return St.fromJSON(t);case"ColorRange":return pt.fromJSON(t);case"RandomColor":return mt.fromJSON(t);case"Gradient":return xt.fromJSON(t);case"RandomColorBetweenGradient":return vt.fromJSON(t);default:return new St(new st(1,1,1,1))}}class wt{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 wt(t.value)}clone(){return new wt(this.value)}}class bt{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),J.lerp(this.a,this.b,t[this.indexCount])}toJSON(){return{type:"IntervalValue",a:this.a,b:this.b}}static fromJSON(t){return new bt(t.a,t.b)}clone(){return new bt(this.a,this.b)}}class _t{constructor(){this.functions=new Array}findFunction(t){let e=0,i=0,s=this.functions.length-1;for(;i+1<s;)if(e=Math.floor((i+s)/2),t<this.getStartX(e))s=e-1;else{if(!(t>this.getEndX(e)))return e;i=e+1}for(let e=i;e<=s;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<this.functions.length?this.functions[t+1][1]:1}setEndX(t,e){t+1<this.functions.length&&(this.functions[t+1][1]=e)}insertFunction(t,e){const i=this.findFunction(t);this.functions.splice(i+1,0,[e,t])}removeFunction(t){return this.functions.splice(t,1)[0][0]}getFunction(t){return this.functions[t][0]}setFunction(t,e){this.functions[t][0]=e}get numOfFunctions(){return this.functions.length}}class zt extends _t{constructor(t=[[new ht(0,1/3,1/3*2,1),0]]){super(),this.type="function",this.functions=t}genValue(t,e=0){const i=this.findFunction(e);return-1===i?0:this.functions[i][0].genValue((e-this.getStartX(i))/(this.getEndX(i)-this.getStartX(i)))}toSVG(t,e){if(e<1)return"";let i=["M",0,this.functions[0][0].p[0]].join(" ");for(let s=1/e;s<=1;s+=1/e)i=[i,"L",s*t,this.genValue(void 0,s)].join(" ");return i}toJSON(){return{type:"PiecewiseBezier",functions:this.functions.map(([t,e])=>({function:t.toJSON(),start:e}))}}static fromJSON(t){return new zt(t.functions.map(t=>[ht.fromJSON(t.function),t.start]))}clone(){return new zt(this.functions.map(([t,e])=>[t.clone(),e]))}startGen(t){}}function Tt(t){switch(t.type){case"ConstantValue":return wt.fromJSON(t);case"IntervalValue":return bt.fromJSON(t);case"PiecewiseBezier":return zt.fromJSON(t);default:return new wt(0)}}class Ot{constructor(){this.indexCount=0,this.type="rotation"}startGen(t){let e,i,s,r,n,o;this.indexCount=t.length,t.push(new I);do{e=2*Math.random()-1,i=2*Math.random()-1,s=e*e+i*i}while(s>1);do{r=2*Math.random()-1,n=2*Math.random()-1,o=r*r+n*n}while(o>1);const a=Math.sqrt((1-s)/o);t[this.indexCount].set(e,i,a*r,a*n)}genValue(t,e,i,s){return-1===this.indexCount&&this.startGen(t),e.copy(t[this.indexCount]),e}toJSON(){return{type:"RandomQuat"}}static fromJSON(t){return new Ot}clone(){return new Ot}}class Bt{constructor(t,e){this.axis=t,this.angle=e,this.type="rotation"}startGen(t){this.angle.startGen(t)}genValue(t,e,i,s){return e.setFromAxisAngle(this.axis,this.angle.genValue(t,s)*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 Bt(new k(t.axis.x,t.axis.y,t.axis.z),Tt(t.angle))}clone(){return new Bt(this.axis.clone(),this.angle.clone())}}class Pt{constructor(t,e,i,s){this.angleX=t,this.angleY=e,this.angleZ=i,this.type="rotation",this.eular=new et(0,0,0,s)}startGen(t){this.angleX.startGen(t),this.angleY.startGen(t),this.angleZ.startGen(t)}genValue(t,e,i,s){return this.eular.set(this.angleX.genValue(t,s)*i,this.angleY.genValue(t,s)*i,this.angleZ.genValue(t,s)*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 Pt(Tt(t.angleX),Tt(t.angleY),Tt(t.angleZ),t.eulerOrder)}clone(){return new Pt(this.angleX,this.angleY,this.angleZ,this.eular.order)}}function Nt(t){switch(t.type){case"AxisAngle":return Bt.fromJSON(t);case"Euler":return Pt.fromJSON(t);case"RandomQuat":return Ot.fromJSON(t);default:return new Ot}}class Ct{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 Ct(Tt(t.x),Tt(t.y),Tt(t.z))}clone(){return new Ct(this.x,this.y,this.z)}}function Vt(t){return"Vector3Function"===t.type?Ct.fromJSON(t):new Ct(new wt(0),new wt(0),new wt(0))}function Ft(t){switch(t.type){case"ConstantValue":case"IntervalValue":case"PiecewiseBezier":return Tt(t);case"AxisAngle":case"RandomQuat":case"Euler":return Nt(t);case"Vector3Function":return Vt(t);default:return new wt(0)}}class At{constructor(t={}){this.type="cone",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.angle=t.angle??Math.PI/6,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[]}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=J.lerp(1-this.thickness,1,Math.random()),r=i*this.arc,n=Math.sqrt(s),o=Math.sin(r),a=Math.cos(r);t.position.x=n*a,t.position.y=n*o,t.position.z=0;const h=this.angle*n;t.velocity.set(0,0,Math.cos(h)).addScaledVector(t.position,Math.sin(h)).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 At({radius:t.radius,arc:t.arc,thickness:t.thickness,angle:t.angle,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new At({radius:this.radius,arc:this.arc,thickness:this.thickness,angle:this.angle,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Et{constructor(t={}){this.type="circle",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[]}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=J.lerp(1-this.thickness,1,Math.random()),r=i*this.arc;t.position.x=Math.cos(r),t.position.y=Math.sin(r),t.position.z=0,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*s)}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 Et({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Et({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}function Dt(t,e){return Math.floor(Math.random()*(e-t))+t}const Rt=new k(0,1,0),Jt=new k(0,0,0),It=new k(1,1,1),kt=new k(0,0,1);class Ut{constructor(t={}){this.type="donut",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.donutRadius=t.donutRadius??.2*this.radius,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=Math.random(),r=J.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,o=s*Math.PI*2,a=Math.sin(n),h=Math.cos(n);if(t.position.x=this.radius*h,t.position.y=this.radius*a,t.position.z=0,t.velocity.z=this.donutRadius*r*Math.sin(o),t.velocity.x=this.donutRadius*r*Math.cos(o)*h,t.velocity.y=this.donutRadius*r*Math.cos(o)*a,t.position.add(t.velocity),t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.velocity,Rt),t.rotation.setFromRotationMatrix(this._m1))}}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 Ut({radius:t.radius,arc:t.arc,thickness:t.thickness,donutRadius:t.donutRadius,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Ut({radius:this.radius,arc:this.arc,thickness:this.thickness,donutRadius:this.donutRadius,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Lt{constructor(){this.type="point",this._m1=new Q}update(t,e){}initialize(t){const e=Math.random(),i=Math.random(),s=e*Math.PI*2,r=Math.acos(2*i-1),n=Math.cbrt(Math.random()),o=Math.sin(s),a=Math.cos(s),h=Math.sin(r),l=Math.cos(r);if(t.velocity.x=n*h*a,t.velocity.y=n*h*o,t.velocity.z=n*l,t.velocity.multiplyScalar(t.startSpeed),t.position.setScalar(0),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.velocity,Rt),t.rotation.setFromRotationMatrix(this._m1))}}toJSON(){return{type:"point"}}static fromJSON(t){return new Lt}clone(){return new Lt}}class qt{constructor(t={}){this.type="sphere",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=Math.random(),r=J.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,o=Math.acos(2*s-1),a=Math.sin(n),h=Math.cos(n),l=Math.sin(o),c=Math.cos(o);if(t.position.x=l*h,t.position.y=l*a,t.position.z=c,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*r),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.position,Rt),t.rotation.setFromRotationMatrix(this._m1))}}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 qt({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new qt({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Gt{constructor(t={}){this.type="hemisphere",this.currentValue=0,this.radius=t.radius??10,this.arc=t.arc??2*Math.PI,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){exports.EmitterMode.Random!=this.mode&&(this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e)}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e),s=Math.random(),r=J.lerp(1-this.thickness,1,Math.random()),n=i*this.arc,o=Math.acos(s),a=Math.sin(n),h=Math.cos(n),l=Math.sin(o),c=Math.cos(o);if(t.position.x=l*h,t.position.y=l*a,t.position.z=c,t.velocity.copy(t.position).multiplyScalar(t.startSpeed),t.position.multiplyScalar(this.radius*r),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.position,Rt),t.rotation.setFromRotationMatrix(this._m1))}}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 Gt({radius:t.radius,arc:t.arc,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Gt({radius:this.radius,arc:this.arc,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}class Qt{constructor(t={}){this.type="grid",this.width=t.width??1,this.height=t.height??1,this.column=t.column??10,this.row=t.row??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 Qt(t)}clone(){return new Qt({width:this.width,height:this.height,column:this.column,row:this.row})}update(t,e){}}class Xt{constructor(t={}){this.type="rectangle",this.currentValue=0,this.width=t.width??10,this.height=t.height??10,this.thickness=t.thickness??1,this.mode=t.mode??exports.EmitterMode.Random,this.spread=t.spread??0,this.speed=t.speed??new wt(1),this.memory=[],this._m1=new Q}update(t,e){this.currentValue+=this.speed.genValue(this.memory,t.emissionState.time/t.duration)*e}initialize(t,e){const i=at(this.mode,this.currentValue,this.spread,e)*(2*(this.width+this.height));let s,r;i<this.width?(s=i-this.width/2,r=-this.height/2):i<this.width+this.height?(s=this.width/2,r=i-this.width-this.height/2):i<2*this.width+this.height?(s=this.width/2-(i-this.width-this.height),r=this.height/2):(s=-this.width/2,r=this.height/2-(i-2*this.width-this.height));const n=Math.random(),o=1-this.thickness*n;if(t.position.x=s*o,t.position.y=r*o,t.position.z=0,t.velocity.x=s,t.velocity.y=r,t.velocity.z=0,t.velocity.normalize().multiplyScalar(t.startSpeed),t.rotation instanceof I){const e=t.rotation;0===e.x&&0===e.y&&0===e.z&&1===e.w&&(this._m1.lookAt(Jt,t.velocity,Rt),t.rotation.setFromRotationMatrix(this._m1))}}toJSON(){return{type:"rectangle",width:this.width,height:this.height,thickness:this.thickness,mode:this.mode,spread:this.spread,speed:this.speed.toJSON()}}static fromJSON(t){return new Xt({width:t.width,height:t.height,thickness:t.thickness,mode:t.mode,speed:t.speed?Tt(t.speed):void 0,spread:t.spread})}clone(){return new Xt({width:this.width,height:this.height,thickness:this.thickness,mode:this.mode,speed:this.speed.clone(),spread:this.spread})}}const Wt={circle:{type:"circle",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Et,loadJSON:Et.fromJSON},cone:{type:"cone",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:At,loadJSON:At.fromJSON},donut:{type:"donut",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["donutRadius",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Ut,loadJSON:Ut.fromJSON},point:{type:"point",params:[],constructor:Lt,loadJSON:Lt.fromJSON},sphere:{type:"sphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:qt,loadJSON:qt.fromJSON},hemisphere:{type:"hemisphere",params:[["radius",["number"]],["arc",["radian"]],["thickness",["number"]],["angle",["radian"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Gt,loadJSON:Gt.fromJSON},grid:{type:"grid",params:[["width",["number"]],["height",["number"]],["rows",["number"]],["column",["number"]]],constructor:Qt,loadJSON:Qt.fromJSON},rectangle:{type:"rectangle",params:[["width",["number"]],["height",["number"]],["thickness",["number"]],["mode",["emitterMode"]],["spread",["number"]],["speed",["valueFunc","value"]]],constructor:Xt,loadJSON:Xt.fromJSON}};function jt(t,e){return Wt[t.type].loadJSON(t,e)}class Ht{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 Ht(Mt(t.color))}clone(){return new Ht(this.color.clone())}reset(){}}class Yt{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 Yt(Tt(t.angularVelocity))}frameUpdate(t){}clone(){return new Yt(this.angularVelocity.clone())}reset(){}}class Zt{constructor(t){this.angularVelocity=t,this.type="Rotation3DOverLife",this.tempQuat=new I,this.tempQuat2=new I}initialize(t){t.rotation instanceof I&&(t.angularVelocity=new I,this.angularVelocity.startGen(t.memory))}update(t,e){t.rotation instanceof I&&(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 Zt(Nt(t.angularVelocity))}frameUpdate(t){}clone(){return new Zt(this.angularVelocity.clone())}reset(){}}class Kt{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 k,this._tempScale=new k,this._tempQ=new I}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 Kt(Tt(t.x),Tt(t.y),Tt(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 Kt(this.x.clone(),this.y.clone(),this.z.clone())}reset(){}}const $t=new k(1,0,0),te=new k(0,1,0),ee=new k(0,0,1);class ie{constructor(t=new wt(0),e=new wt(0),i=new wt(0),s=new wt(0),r=new wt(0),n=new wt(0),o="local"){this.linearX=t,this.linearY=e,this.linearZ=i,this.orbitalX=s,this.orbitalY=r,this.orbitalZ=n,this.space=o,this.type="VelocityOverLife",this._temp=new k,this._tempEmitterPos=new k,this._tempQ=new I,this._tempQInv=new I,this._tempScale=new k(1,1,1),this._tempScaleInv=new k(1,1,1),this._tempRot=new I,this._tempAxis=new k}initialize(t,e){this.ps=e,this.linearX.startGen(t.memory),this.linearY.startGen(t.memory),this.linearZ.startGen(t.memory),this.orbitalX.startGen(t.memory),this.orbitalY.startGen(t.memory),this.orbitalZ.startGen(t.memory)}frameUpdate(t){this.ps&&(this.ps.emitter.matrixWorld.decompose(this._tempEmitterPos,this._tempQ,this._tempScale),this._tempQInv.copy(this._tempQ).invert(),this._tempScaleInv.set(1/this._tempScale.x,1/this._tempScale.y,1/this._tempScale.z))}update(t,e){const i=t.age/t.life;this._temp.set(this.linearX.genValue(t.memory,i),this.linearY.genValue(t.memory,i),this.linearZ.genValue(t.memory,i)),this.ps.worldSpace&&"local"===this.space?this._temp.multiply(this._tempScale).applyQuaternion(this._tempQ):this.ps.worldSpace||"world"!==this.space||this._temp.multiply(this._tempScaleInv).applyQuaternion(this._tempQInv),t.position.addScaledVector(this._temp,e);const s=this.orbitalX.genValue(t.memory,i)*e,r=this.orbitalY.genValue(t.memory,i)*e,n=this.orbitalZ.genValue(t.memory,i)*e;if(0!==s||0!==r||0!==n){const e=this.ps.worldSpace;e&&t.position.sub(this._tempEmitterPos),this.orbit(t.position,$t,s,e),this.orbit(t.position,te,r,e),this.orbit(t.position,ee,n,e),e&&t.position.add(this._tempEmitterPos)}}orbit(t,e,i,s){0!==i&&(this._tempAxis.copy(e),s&&this._tempAxis.applyQuaternion(this._tempQ),this._tempRot.setFromAxisAngle(this._tempAxis,i),t.applyQuaternion(this._tempRot))}toJSON(){return{type:this.type,linearX:this.linearX.toJSON(),linearY:this.linearY.toJSON(),linearZ:this.linearZ.toJSON(),orbitalX:this.orbitalX.toJSON(),orbitalY:this.orbitalY.toJSON(),orbitalZ:this.orbitalZ.toJSON(),space:this.space}}static fromJSON(t){const e=t=>t?Tt(t):new wt(0);return new ie(e(t.linearX),e(t.linearY),e(t.linearZ),e(t.orbitalX),e(t.orbitalY),e(t.orbitalZ),"world"===t.space?"world":"local")}clone(){return new ie(this.linearX.clone(),this.linearY.clone(),this.linearZ.clone(),this.orbitalX.clone(),this.orbitalY.clone(),this.orbitalZ.clone(),this.space)}reset(){}}class se{constructor(t=new wt(1),e="initial"){this.multiplier=t,this.mode=e,this.type="InheritVelocity",this._temp=new k,this._tempPos=new k,this._tempQInv=new I,this._tempScaleInv=new k(1,1,1)}initialize(t,e){this.ps=e,this.multiplier.startGen(t.memory),"initial"===this.mode&&e.emitterVelocity&&(this._temp.copy(e.emitterVelocity),e.worldSpace||(this.decomposeInverse(e),this._temp.multiply(this._tempScaleInv).applyQuaternion(this._tempQInv)),t.velocity.addScaledVector(this._temp,this.multiplier.genValue(t.memory,0)))}frameUpdate(t){this.ps&&!this.ps.worldSpace&&this.decomposeInverse(this.ps)}update(t,e){"current"===this.mode&&this.ps.emitterVelocity&&(this._temp.copy(this.ps.emitterVelocity),this.ps.worldSpace||this._temp.multiply(this._tempScaleInv).applyQuaternion(this._tempQInv),t.position.addScaledVector(this._temp,this.multiplier.genValue(t.memory,t.age/t.life)*e))}decomposeInverse(t){t.emitter.matrixWorld.decompose(this._tempPos,this._tempQInv,this._tempScaleInv),this._tempQInv.invert(),this._tempScaleInv.set(1/this._tempScaleInv.x,1/this._tempScaleInv.y,1/this._tempScaleInv.z)}toJSON(){return{type:this.type,multiplier:this.multiplier.toJSON(),mode:this.mode}}static fromJSON(t){return new se(t.multiplier?Tt(t.multiplier):new wt(1),"current"===t.mode?"current":"initial")}clone(){return new se(this.multiplier.clone(),this.mode)}reset(){}}class re{initialize(t){this.size.startGen(t.memory)}constructor(t){this.size=t,this.type="SizeOverLife"}update(t){this.size instanceof Ct?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 re(Ft(t.size))}frameUpdate(t){}clone(){return new re(this.size.clone())}reset(){}}class ne{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 ne(Tt(t.speed))}frameUpdate(t){}clone(){return new ne(this.speed.clone())}reset(){}}class oe{constructor(t){this.frame=t,this.type="FrameOverLife"}initialize(t){this.frame.startGen(t.memory)}update(t,e){this.frame instanceof zt&&(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 oe(Tt(t.frame))}clone(){return new oe(this.frame.clone())}reset(){}}class ae{constructor(t,e=new k(0,1,0)){this.orbitSpeed=t,this.axis=e,this.type="OrbitOverLife",this.temp=new k,this.rotation=new I}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 ae(Tt(t.orbitSpeed),t.axis?new k(t.axis[0],t.axis[1],t.axis[2]):void 0)}clone(){return new ae(this.orbitSpeed.clone())}reset(){}}class he{constructor(t){this.data=t,this.next=null,this.prev=null}hasPrev(){return null!==this.prev}hasNext(){return null!==this.next}}class le{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 he(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 he(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 he(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 ce{constructor(){this.startSpeed=0,this.startColor=new st,this.startSize=new k(1,1,1),this.position=new k,this.velocity=new k,this.age=0,this.life=1,this.size=new k(1,1,1),this.speedModifier=1,this.rotation=0,this.color=new st,this.uvTile=0,this.memory=[]}get died(){return this.age>=this.life}reset(){this.memory.length=0}}class ue{constructor(t,e,i){this.position=t,this.size=e,this.color=i}}class de{constructor(){this.startSpeed=0,this.startColor=new st,this.startSize=new k(1,1,1),this.position=new k,this.velocity=new k,this.age=0,this.life=1,this.size=new k(1,1,1),this.length=100,this.speedModifier=1,this.color=new st,this.previous=new le,this.uvTile=0,this.memory=[]}update(){for(this.age<=this.life?this.previous.push(new ue(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 me{initialize(t){this.width.startGen(t.memory)}constructor(t){this.width=t,this.type="WidthOverLength"}update(t){if(t instanceof de){const e=t.previous.values();for(let i=0;i<t.previous.length;i++){e.next().value.size=this.width.genValue(t.memory,(t.previous.length-i)/t.length)}}}frameUpdate(t){}toJSON(){return{type:this.type,width:this.width.toJSON()}}static fromJSON(t){return new me(Tt(t.width))}clone(){return new me(this.width.clone())}reset(){}}class pe{constructor(t,e){this.direction=t,this.magnitude=e,this.type="ApplyForce",this.memory={data:[],dataCount:0},this.magnitudeValue=this.magnitude.genValue(this.memory)}initialize(t){}update(t,e){t.velocity.addScaledVector(this.direction,this.magnitudeValue*e)}frameUpdate(t){this.magnitudeValue=this.magnitude.genValue(this.memory)}toJSON(){return{type:this.type,direction:[this.direction.x,this.direction.y,this.direction.z],magnitude:this.magnitude.toJSON()}}static fromJSON(t){return new pe(new k(t.direction[0],t.direction[1],t.direction[2]),Tt(t.magnitude??t.force))}clone(){return new pe(this.direction.clone(),this.magnitude.clone())}reset(){}}class ye{constructor(t,e){this.center=t,this.magnitude=e,this.type="GravityForce",this.temp=new k}initialize(t){}update(t,e){this.temp.copy(this.center).sub(t.position).normalize(),t.velocity.addScaledVector(this.temp,this.magnitude/t.position.distanceToSquared(this.center)*e)}frameUpdate(t){}toJSON(){return{type:this.type,center:[this.center.x,this.center.y,this.center.z],magnitude:this.magnitude}}static fromJSON(t){return new ye(new k(t.center[0],t.center[1],t.center[2]),t.magnitude)}clone(){return new ye(this.center.clone(),this.magnitude)}reset(){}}class fe{constructor(t){this.angle=t,this.type="ChangeEmitDirection",this._temp=new k,this._q=new I,this.memory={data:[],dataCount:0}}initialize(t){const e=t.velocity.length();0!=e&&(t.velocity.normalize(),0===t.velocity.x&&0===t.velocity.y?this._temp.set(0,t.velocity.z,0):this._temp.set(-t.velocity.y,t.velocity.x,0),this.angle.startGen(this.memory),this._q.setFromAxisAngle(this._temp.normalize(),this.angle.genValue(this.memory)),this._temp.copy(t.velocity),t.velocity.applyQuaternion(this._q),this._q.setFromAxisAngle(this._temp,Math.random()*Math.PI*2),t.velocity.applyQuaternion(this._q),t.velocity.setLength(e))}update(t,e){}frameUpdate(t){}toJSON(){return{type:this.type,angle:this.angle.toJSON()}}static fromJSON(t){return new fe(Tt(t.angle))}clone(){return new fe(this.angle)}reset(){}}var xe;exports.SubParticleEmitMode=void 0,(xe=exports.SubParticleEmitMode||(exports.SubParticleEmitMode={}))[xe.Death=0]="Death",xe[xe.Birth=1]="Birth",xe[xe.Frame=2]="Frame";class ge{constructor(t,e,i,s=exports.SubParticleEmitMode.Frame,r=1){this.particleSystem=t,this.useVelocityAsBasis=e,this.subParticleSystem=i,this.mode=s,this.emitProbability=r,this.type="EmitSubParticleSystem",this.q_=new I,this.v_=new k,this.v2_=new k,this.subEmissions=new Array,this.subParticleSystem&&this.subParticleSystem.system&&(this.subParticleSystem.system.onlyUsedByOther=!0)}initialize(t){}update(t,e){(this.mode===exports.SubParticleEmitMode.Frame||this.mode===exports.SubParticleEmitMode.Birth&&0===t.age||this.mode===exports.SubParticleEmitMode.Death&&t.age+e>=t.life)&&this.emit(t,e)}emit(t,e){if(!this.subParticleSystem)return;if(Math.random()>this.emitProbability)return;const i=new Q;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.subEmissions.length;e++)if(this.subEmissions[e].time>=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<i.particle.life?this.setMatrixFromParticle(i.matrix,i.particle):i.particle=void 0,this.subParticleSystem.system.emit(t,i,i.matrix)}}toJSON(){return{type:this.type,subParticleSystem:this.subParticleSystem?this.subParticleSystem.uuid:"",useVelocityAsBasis:this.useVelocityAsBasis,mode:this.mode,emitProbability:this.emitProbability}}static fromJSON(t,e){return new ge(e,t.useVelocityAsBasis,t.subParticleSystem,t.mode,t.emitProbability)}clone(){return new ge(this.particleSystem,this.useVelocityAsBasis,this.subParticleSystem,this.mode,this.emitProbability)}reset(){}setMatrixFromParticle(t,e){let i;if(void 0===e.rotation||this.useVelocityAsBasis)if(0!==e.velocity.x||0!==e.velocity.y||1!==e.velocity.z&&0!==e.velocity.z){this.v_.copy(kt).cross(e.velocity),this.v2_.copy(e.velocity).cross(this.v_);const i=this.v_.length(),s=this.v2_.length();t.set(this.v_.x/i,this.v2_.x/s,e.velocity.x,e.position.x,this.v_.y/i,this.v2_.y/s,e.velocity.y,e.position.y,this.v_.z/i,this.v2_.z/s,e.velocity.z,e.position.z,0,0,0,1)}else t.set(1,0,0,e.position.x,0,1,0,e.position.y,0,0,1,e.position.z,0,0,0,1);else e.rotation instanceof I?i=e.rotation:(this.q_.setFromAxisAngle(kt,e.rotation),i=this.q_),t.compose(e.position,i,It);this.particleSystem.worldSpace||t.multiplyMatrices(this.particleSystem.emitter.matrixWorld,t)}}const ve=.5*(Math.sqrt(3)-1),Se=(3-Math.sqrt(3))/6,Me=1/3,we=1/6,be=(Math.sqrt(5)-1)/4,_e=(5-Math.sqrt(5))/20,ze=new Float32Array([1,1,0,-1,1,0,1,-1,0,-1,-1,0,1,0,1,-1,0,1,1,0,-1,-1,0,-1,0,1,1,0,-1,1,0,1,-1,0,-1,-1]),Te=new Float32Array([0,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,1,0,1,1,1,0,1,-1,1,0,-1,1,1,0,-1,-1,-1,0,1,1,-1,0,1,-1,-1,0,-1,1,-1,0,-1,-1,1,1,0,1,1,1,0,-1,1,-1,0,1,1,-1,0,-1,-1,1,0,1,-1,1,0,-1,-1,-1,0,1,-1,-1,0,-1,1,1,1,0,1,1,-1,0,1,-1,1,0,1,-1,-1,0,-1,1,1,0,-1,1,-1,0,-1,-1,1,0,-1,-1,-1,0]);class Oe{constructor(t=Math.random){const e="function"==typeof t?t:function(t){let e=0,i=0,s=0,r=1;const n=function(){let t=4022871197;return function(e){e=e.toString();for(let i=0;i<e.length;i++){t+=e.charCodeAt(i);let s=.02519603282416938*t;t=s>>>0,s-=t,s*=t,t=s>>>0,s-=t,t+=4294967296*s}return 2.3283064365386963e-10*(t>>>0)}}();e=n(" "),i=n(" "),s=n(" "),e-=n(t),e<0&&(e+=1);i-=n(t),i<0&&(i+=1);s-=n(t),s<0&&(s+=1);return function(){const t=2091639*e+2.3283064365386963e-10*r;return e=i,i=s,s=t-(r=0|t)}}(t);this.p=function(t){const e=new Uint8Array(256);for(let t=0;t<256;t++)e[t]=t;for(let i=0;i<255;i++){const s=i+~~(t()*(256-i)),r=e[i];e[i]=e[s],e[s]=r}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,s=this.perm;let r=0,n=0,o=0;const a=(t+e)*ve,h=Math.floor(t+a),l=Math.floor(e+a),c=(h+l)*Se,u=t-(h-c),d=e-(l-c);let m,p;u>d?(m=1,p=0):(m=0,p=1);const y=u-m+Se,f=d-p+Se,x=u-1+2*Se,g=d-1+2*Se,v=255&h,S=255&l;let M=.5-u*u-d*d;if(M>=0){const t=3*i[v+s[S]];M*=M,r=M*M*(ze[t]*u+ze[t+1]*d)}let w=.5-y*y-f*f;if(w>=0){const t=3*i[v+m+s[S+p]];w*=w,n=w*w*(ze[t]*y+ze[t+1]*f)}let b=.5-x*x-g*g;if(b>=0){const t=3*i[v+1+s[S+1]];b*=b,o=b*b*(ze[t]*x+ze[t+1]*g)}return 70*(r+n+o)}noise3D(t,e,i){const s=this.permMod12,r=this.perm;let n,o,a,h;const l=(t+e+i)*Me,c=Math.floor(t+l),u=Math.floor(e+l),d=Math.floor(i+l),m=(c+u+d)*we,p=t-(c-m),y=e-(u-m),f=i-(d-m);let x,g,v,S,M,w;p>=y?y>=f?(x=1,g=0,v=0,S=1,M=1,w=0):p>=f?(x=1,g=0,v=0,S=1,M=0,w=1):(x=0,g=0,v=1,S=1,M=0,w=1):y<f?(x=0,g=0,v=1,S=0,M=1,w=1):p<f?(x=0,g=1,v=0,S=0,M=1,w=1):(x=0,g=1,v=0,S=1,M=1,w=0);const b=p-x+we,_=y-g+we,z=f-v+we,T=p-S+2*we,O=y-M+2*we,B=f-w+2*we,P=p-1+.5,N=y-1+.5,C=f-1+.5,V=255&c,F=255&u,A=255&d;let E=.6-p*p-y*y-f*f;if(E<0)n=0;else{const t=3*s[V+r[F+r[A]]];E*=E,n=E*E*(ze[t]*p+ze[t+1]*y+ze[t+2]*f)}let D=.6-b*b-_*_-z*z;if(D<0)o=0;else{const t=3*s[V+x+r[F+g+r[A+v]]];D*=D,o=D*D*(ze[t]*b+ze[t+1]*_+ze[t+2]*z)}let R=.6-T*T-O*O-B*B;if(R<0)a=0;else{const t=3*s[V+S+r[F+M+r[A+w]]];R*=R,a=R*R*(ze[t]*T+ze[t+1]*O+ze[t+2]*B)}let J=.6-P*P-N*N-C*C;if(J<0)h=0;else{const t=3*s[V+1+r[F+1+r[A+1]]];J*=J,h=J*J*(ze[t]*P+ze[t+1]*N+ze[t+2]*C)}return 32*(n+o+a+h)}noise4D(t,e,i,s){const r=this.perm;let n,o,a,h,l;const c=(t+e+i+s)*be,u=Math.floor(t+c),d=Math.floor(e+c),m=Math.floor(i+c),p=Math.floor(s+c),y=(u+d+m+p)*_e,f=t-(u-y),x=e-(d-y),g=i-(m-y),v=s-(p-y);let S=0,M=0,w=0,b=0;f>x?S++:M++,f>g?S++:w++,f>v?S++:b++,x>g?M++:w++,x>v?M++:b++,g>v?w++:b++;const _=S>=3?1:0,z=M>=3?1:0,T=w>=3?1:0,O=b>=3?1:0,B=S>=2?1:0,P=M>=2?1:0,N=w>=2?1:0,C=b>=2?1:0,V=S>=1?1:0,F=M>=1?1:0,A=w>=1?1:0,E=b>=1?1:0,D=f-_+_e,R=x-z+_e,J=g-T+_e,I=v-O+_e,k=f-B+2*_e,U=x-P+2*_e,L=g-N+2*_e,q=v-C+2*_e,G=f-V+3*_e,Q=x-F+3*_e,X=g-A+3*_e,W=v-E+3*_e,j=f-1+4*_e,H=x-1+4*_e,Y=g-1+4*_e,Z=v-1+4*_e,K=255&u,$=255&d,tt=255&m,et=255&p;let it=.6-f*f-x*x-g*g-v*v;if(it<0)n=0;else{const t=r[K+r[$+r[tt+r[et]]]]%32*4;it*=it,n=it*it*(Te[t]*f+Te[t+1]*x+Te[t+2]*g+Te[t+3]*v)}let st=.6-D*D-R*R-J*J-I*I;if(st<0)o=0;else{const t=r[K+_+r[$+z+r[tt+T+r[et+O]]]]%32*4;st*=st,o=st*st*(Te[t]*D+Te[t+1]*R+Te[t+2]*J+Te[t+3]*I)}let rt=.6-k*k-U*U-L*L-q*q;if(rt<0)a=0;else{const t=r[K+B+r[$+P+r[tt+N+r[et+C]]]]%32*4;rt*=rt,a=rt*rt*(Te[t]*k+Te[t+1]*U+Te[t+2]*L+Te[t+3]*q)}let nt=.6-G*G-Q*Q-X*X-W*W;if(nt<0)h=0;else{const t=r[K+V+r[$+F+r[tt+A+r[et+E]]]]%32*4;nt*=nt,h=nt*nt*(Te[t]*G+Te[t+1]*Q+Te[t+2]*X+Te[t+3]*W)}let ot=.6-j*j-H*H-Y*Y-Z*Z;if(ot<0)l=0;else{const t=r[K+1+r[$+1+r[tt+1+r[et+1]]]]%32*4;ot*=ot,l=ot*ot*(Te[t]*j+Te[t+1]*H+Te[t+2]*Y+Te[t+3]*Z)}return 27*(n+o+a+h+l)}}class Be{constructor(t,e,i,s){this.scale=t,this.octaves=e,this.velocityMultiplier=i,this.timeScale=s,this.type="TurbulenceField",this.generator=new Oe,this.timeOffset=new k,this.temp=new k,this.temp2=new k,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,s=t.position.y/this.scale.y,r=t.position.z/this.scale.z;this.temp.set(0,0,0);let n=1;for(let t=0;t<this.octaves;t++)this.temp2.set(this.generator.noise4D(i*n,s*n,r*n,this.timeOffset.x*n)/n,this.generator.noise4D(i*n,s*n,r*n,this.timeOffset.y*n)/n,this.generator.noise4D(i*n,s*n,r*n,this.timeOffset.z*n)/n),this.temp.add(this.temp2),n*=2;this.temp.multiply(this.velocityMultiplier),t.velocity.addScaledVector(this.temp,e)}toJSON(){return{type:this.type,scale:[this.scale.x,this.scale.y,this.scale.z],octaves:this.octaves,velocityMultiplier:[this.velocityMultiplier.x,this.velocityMultiplier.y,this.velocityMultiplier.z],timeScale:[this.timeScale.x,this.timeScale.y,this.timeScale.z]}}frameUpdate(t){this.timeOffset.x+=t*this.timeScale.x,this.timeOffset.y+=t*this.timeScale.y,this.timeOffset.z+=t*this.timeScale.z}static fromJSON(t){return new Be(new k(t.scale[0],t.scale[1],t.scale[2]),t.octaves,new k(t.velocityMultiplier[0],t.velocityMultiplier[1],t.velocityMultiplier[2]),new k(t.timeScale[0],t.timeScale[1],t.timeScale[2]))}clone(){return new Be(this.scale.clone(),this.octaves,this.velocityMultiplier.clone(),this.timeScale.clone())}reset(){}}const Pe=[],Ne=new k,Ce=new I;class Ve{constructor(t,e,i=new wt(1),s=new wt(0)){if(this.frequency=t,this.power=e,this.positionAmount=i,this.rotationAmount=s,this.type="Noise",this.duration=0,0===Pe.length)for(let t=0;t<100;t++)Pe.push(new Oe)}initialize(t){t.lastPosNoise=new k,"number"==typeof t.rotation?t.lastRotNoise=0:t.lastRotNoise=new I,t.generatorIndex=[Dt(0,100),Dt(0,100),Dt(0,100),Dt(0,100)],this.positionAmount.startGen(t.memory),this.rotationAmount.startGen(t.memory),this.frequency.startGen(t.memory),this.power.startGen(t.memory)}update(t,e){let i=this.frequency.genValue(t.memory,t.age/t.life),s=this.power.genValue(t.memory,t.age/t.life),r=this.positionAmount.genValue(t.memory,t.age/t.life),n=this.rotationAmount.genValue(t.memory,t.age/t.life);r>0&&void 0!==t.lastPosNoise&&(t.position.sub(t.lastPosNoise),Ne.set(Pe[t.generatorIndex[0]].noise2D(0,t.age*i)*s*r,Pe[t.generatorIndex[1]].noise2D(0,t.age*i)*s*r,Pe[t.generatorIndex[2]].noise2D(0,t.age*i)*s*r),t.position.add(Ne),t.lastPosNoise.copy(Ne)),n>0&&void 0!==t.lastRotNoise&&("number"==typeof t.rotation?(t.rotation-=t.lastRotNoise,t.rotation+=Pe[t.generatorIndex[3]].noise2D(0,t.age*i)*Math.PI*s*n):(t.lastRotNoise.invert(),t.rotation.multiply(t.lastRotNoise),Ce.set(Pe[t.generatorIndex[0]].noise2D(0,t.age*i)*s*n,Pe[t.generatorIndex[1]].noise2D(0,t.age*i)*s*n,Pe[t.generatorIndex[2]].noise2D(0,t.age*i)*s*n,Pe[t.generatorIndex[3]].noise2D(0,t.age*i)*s*n).normalize(),t.rotation.multiply(Ce),t.lastRotNoise.copy(Ce)))}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 Ve(Tt(t.frequency),Tt(t.power),Tt(t.positionAmount),Tt(t.rotationAmount))}clone(){return new Ve(this.frequency.clone(),this.power.clone(),this.positionAmount.clone(),this.rotationAmount.clone())}reset(){}}class Fe{constructor(t=0,e=0,i=new k){this.scaleX=t,this.scaleY=e,this.position=i,this.locations=[]}transform(t,e){t.x=this.locations[e%this.locations.length].x*this.scaleX+this.position.x,t.y=this.locations[e%this.locations.length].y*this.scaleY+this.position.y,t.z=this.position.z}static fromJSON(t){const e=new Fe(t.scaleX,t.scaleY,new k(t.position[0],t.position[1],t.position[2]));return e.locations=t.locations.map(t=>new it(t.x,t.y)),e}clone(){const t=new Fe(this.scaleX,this.scaleY,this.position.clone());return t.locations=this.locations.map(t=>t.clone()),t}toJSON(){return{scaleX:this.scaleX,scaleY:this.scaleY,position:this.position,locations:this.locations.map(t=>({x:t.x,y:t.y}))}}fromImage(t,e){const i=document.createElement("canvas");i.width=t.width,i.height=t.height;const s=i.getContext("2d");if(!s)return;s.drawImage(t,0,0);const r=s.getImageData(0,0,i.width,i.height,{colorSpace:"srgb"});i.remove(),this.locations.length=0;for(let t=0;t<r.height;t++)for(let i=0;i<r.width;i++)r.data[4*(t*r.width+i)+3]>e&&this.locations.push(new it(i,r.height-t))}}function Ae(t){return"TextureSequencer"===t.type?Fe.fromJSON(t):new Fe}class Ee{constructor(t){this.type="ApplySequences",this.sequencers=[],this.time=0,this.index=0,this.pCount=0,this.tempV=new k,this.delay=t}initialize(t){t.id=this.pCount,t.dst=new k,t.begin=new k,t.inMotion=!1,this.pCount++}reset(){this.time=0,this.index=0,this.pCount=0}update(t,e){const i=this.sequencers[this.index],s=t.id*this.delay;this.time>=i[0].a+s&&this.time<=i[0].b+s?(t.inMotion||(t.inMotion=!0,t.begin.copy(t.position),i[1].transform(t.dst,t.id)),t.position.lerpVectors(t.begin,t.dst,Ee.BEZIER.genValue((this.time-i[0].a-s)/(i[0].b-i[0].a)))):this.time>i[0].b+s&&(t.inMotion=!1)}frameUpdate(t){for(;this.index+1<this.sequencers.length&&this.time>=this.sequencers[this.index+1][0].a;)this.index++;this.time+=t}appendSequencer(t,e){this.sequencers.push([t,e])}toJSON(){return{type:this.type,delay:this.delay,sequencers:this.sequencers.map(([t,e])=>({range:t.toJSON(),sequencer:e.toJSON()}))}}static fromJSON(t){const e=new Ee(t.delay);return t.sequencers.forEach(t=>{e.sequencers.push([Tt(t.range),Ae(t.sequencer)])}),e}clone(){const t=new Ee(this.delay);return t.sequencers=this.sequencers.map(t=>[t[0].clone(),t[1].clone()]),t}}let De;function Re(){return De}Ee.BEZIER=new ht(0,0,1,1);class Je{constructor(t,e){this.resolver=t,this.bounce=e,this.type="ApplyCollision",this.tempV=new k}initialize(t){}update(t,e){this.resolver&&this.resolver.resolve(t.position,this.tempV)&&t.velocity.reflect(this.tempV).multiplyScalar(this.bounce)}frameUpdate(t){}toJSON(){return{type:this.type,bounce:this.bounce}}static fromJSON(t){return new Je(Re(),t.bounce)}clone(){return new Je(this.resolver,this.bounce)}reset(){}}class Ie{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 Ie(Mt(t.color),bt.fromJSON(t.speedRange))}clone(){return new Ie(this.color.clone(),this.speedRange.clone())}reset(){}}class ke{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 Ct?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 ke(Ft(t.size),bt.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new ke(this.size.clone(),this.speedRange.clone())}reset(){}}class Ue{constructor(t,e){this.angularVelocity=t,this.speedRange=e,this.type="RotationBySpeed",this.tempQuat=new I}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 Ue(Tt(t.angularVelocity),bt.fromJSON(t.speedRange))}frameUpdate(t){}clone(){return new Ue(this.angularVelocity.clone(),this.speedRange.clone())}reset(){}}class Le{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(),s=this.speed.genValue(t.memory,t.age/t.life);if(i>s){const r=(i-s)/i;t.velocity.multiplyScalar(1-r*this.dampen*e*20)}}toJSON(){return{type:this.type,speed:this.speed.toJSON(),dampen:this.dampen}}static fromJSON(t){return new Le(Tt(t.speed),t.dampen)}frameUpdate(t){}clone(){return new Le(this.speed.clone(),this.dampen)}reset(){}}const qe={ApplyForce:{type:"ApplyForce",constructor:pe,params:[["direction",["vec3"]],["magnitude",["value"]]],loadJSON:pe.fromJSON},Noise:{type:"Noise",constructor:Ve,params:[["frequency",["value"]],["power",["value"]],["positionAmount",["value"]],["rotationAmount",["value"]]],loadJSON:Ve.fromJSON},TurbulenceField:{type:"TurbulenceField",constructor:Be,params:[["scale",["vec3"]],["octaves",["number"]],["velocityMultiplier",["vec3"]],["timeScale",["vec3"]]],loadJSON:Be.fromJSON},GravityForce:{type:"GravityForce",constructor:ye,params:[["center",["vec3"]],["magnitude",["number"]]],loadJSON:ye.fromJSON},ColorOverLife:{type:"ColorOverLife",constructor:Ht,params:[["color",["colorFunc"]]],loadJSON:Ht.fromJSON},RotationOverLife:{type:"RotationOverLife",constructor:Yt,params:[["angularVelocity",["value","valueFunc"]]],loadJSON:Yt.fromJSON},Rotation3DOverLife:{type:"Rotation3DOverLife",constructor:Zt,params:[["angularVelocity",["rotationFunc"]]],loadJSON:Zt.fromJSON},SizeOverLife:{type:"SizeOverLife",constructor:re,params:[["size",["value","valueFunc","vec3Func"]]],loadJSON:re.fromJSON},ColorBySpeed:{type:"ColorBySpeed",constructor:Ie,params:[["color",["colorFunc"]],["speedRange",["range"]]],loadJSON:Ie.fromJSON},RotationBySpeed:{type:"RotationBySpeed",constructor:Ue,params:[["angularVelocity",["value","valueFunc"]],["speedRange",["range"]]],loadJSON:Ue.fromJSON},SizeBySpeed:{type:"SizeBySpeed",constructor:ke,params:[["size",["value","valueFunc","vec3Func"]],["speedRange",["range"]]],loadJSON:ke.fromJSON},SpeedOverLife:{type:"SpeedOverLife",constructor:ne,params:[["speed",["value","valueFunc"]]],loadJSON:ne.fromJSON},FrameOverLife:{type:"FrameOverLife",constructor:oe,params:[["frame",["value","valueFunc"]]],loadJSON:oe.fromJSON},ForceOverLife:{type:"ForceOverLife",constructor:Kt,params:[["x",["value","valueFunc"]],["y",["value","valueFunc"]],["z",["value","valueFunc"]]],loadJSON:Kt.fromJSON},VelocityOverLife:{type:"VelocityOverLife",constructor:ie,params:[["linearX",["value","valueFunc"]],["linearY",["value","valueFunc"]],["linearZ",["value","valueFunc"]],["orbitalX",["value","valueFunc"]],["orbitalY",["value","valueFunc"]],["orbitalZ",["value","valueFunc"]],["space",["string"]]],loadJSON:ie.fromJSON},InheritVelocity:{type:"InheritVelocity",constructor:se,params:[["multiplier",["value","valueFunc"]],["mode",["string"]]],loadJSON:se.fromJSON},OrbitOverLife:{type:"OrbitOverLife",constructor:ae,params:[["orbitSpeed",["value","valueFunc"]],["axis",["vec3"]]],loadJSON:ae.fromJSON},WidthOverLength:{type:"WidthOverLength",constructor:me,params:[["width",["value","valueFunc"]]],loadJSON:me.fromJSON},ChangeEmitDirection:{type:"ChangeEmitDirection",constructor:fe,params:[["angle",["value"]]],loadJSON:fe.fromJSON},EmitSubParticleSystem:{type:"EmitSubParticleSystem",constructor:ge,params:[["particleSystem",["self"]],["useVelocityAsBasis",["boolean"]],["subParticleSystem",["particleSystem"]],["mode",["number"]],["emitProbability",["number"]]],loadJSON:ge.fromJSON},LimitSpeedOverLife:{type:"LimitSpeedOverLife",constructor:Le,params:[["speed",["value","valueFunc"]],["dampen",["number"]]],loadJSON:Le.fromJSON},ApplyCollision:{type:"ApplyCollision",constructor:Je,params:[["bounce",["number"]]],loadJSON:Je.fromJSON}};function Ge(t,e){return qe[t.type]?qe[t.type].loadJSON(t,e):null}const Qe=[];function Xe(t){if(!Qe.find(e=>e.id===t.id)){t.initialize();for(const e of t.emitterShapes)Wt[e.type]||(Wt[e.type]=e);for(const e of t.behaviors)qe[e.type]||(qe[e.type]=e)}}class We{get mesh(){return this._mesh}set mesh(e){if(this._mesh=e,!e)return;const i=e.getVerticesData(t.VertexBuffer.PositionKind),s=e.getIndices();if(!i||!s)return;this._positions=new Float32Array(i),this._indices=new Int32Array(s),this._triangleIndexToArea.length=0;let r=0;const n=s.length/3;this._triangleIndexToArea.push(0);const o=new k,a=new k,h=new k;for(let t=0;t<n;t++){const e=s[3*t],n=s[3*t+1],l=s[3*t+2];o.set(i[3*e],i[3*e+1],i[3*e+2]),a.set(i[3*n],i[3*n+1],i[3*n+2]),h.set(i[3*l],i[3*l+1],i[3*l+2]),a.sub(o),h.sub(o);const c=new k;c.crossVectors(a,h),r+=.5*c.length(),this._triangleIndexToArea.push(r)}}constructor(t,e){this.type="mesh_surface",this._triangleIndexToArea=[],this._meshReferenceId=e,t&&(this.mesh=t)}initialize(t){if(!this._positions||!this._indices)return t.position.set(0,0,0),void t.velocity.set(0,0,1).multiplyScalar(t.startSpeed);const e=this._triangleIndexToArea.length-1;let i=0,s=e;const r=Math.random()*this._triangleIndexToArea[e];for(;i+1<s;){const t=Math.floor((i+s)/2);r<this._triangleIndexToArea[t]?s=t:i=t}let n=Math.random(),o=Math.random();n+o>1&&(n=1-n,o=1-o);const a=this._indices[3*i],h=this._indices[3*i+1],l=this._indices[3*i+2],c=this._positions[3*a],u=this._positions[3*a+1],d=this._positions[3*a+2],m=this._positions[3*h]-c,p=this._positions[3*h+1]-u,y=this._positions[3*h+2]-d,f=this._positions[3*l]-c,x=this._positions[3*l+1]-u,g=this._positions[3*l+2]-d;t.position.set(c+m*n+f*o,u+p*n+x*o,d+y*n+g*o);const v=p*g-y*x,S=y*f-m*g,M=m*x-p*f,w=Math.sqrt(v*v+S*S+M*M)||1;t.velocity.set(v/w,S/w,M/w).multiplyScalar(t.startSpeed)}toJSON(){return{type:"mesh_surface",mesh:this._mesh?this._mesh.uniqueId?.toString():this._meshReferenceId??""}}static fromJSON(t){return new We(void 0,t?.mesh)}clone(){return new We(this._mesh,this._meshReferenceId)}update(t,e){}}const je={id:"babylon.quarks",initialize:()=>{},emitterShapes:[{type:"mesh_surface",params:[["mesh",["mesh"]]],constructor:We,loadJSON:t=>We.fromJSON(t)}],behaviors:[]};const He={};let Ye=!1;function Ze(){Ye||(He.tile_pars_vertex="\n#ifdef UV_TILE\n attribute float uvTile;\n uniform vec2 tileCount;\n\n mat3 makeTileTransform(float tileIndex) {\n float col = mod(tileIndex, tileCount.x);\n float row = (tileCount.y - floor(tileIndex / tileCount.x) - 1.0);\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 }\n#else\n mat3 makeTileTransform(float tileIndex) {\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)\n varying vec2 vUv;\n #ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n #endif\n#endif\n",He.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)\n vUv = (tileTransform * vec3(uv, 1.0)).xy;\n #if defined(TILE_BLEND) && defined(UV_TILE)\n vUvNext = (nextTileTransform * vec3(uv, 1.0)).xy;\n #endif\n#endif\n",He.tile_pars_fragment="\n#if defined(USE_UV)\n varying vec2 vUv;\n #ifdef TILE_BLEND\n varying vec2 vUvNext;\n varying float vUvBlend;\n #endif\n#endif\n",He.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",He.soft_pars_vertex="\n#ifdef SOFT_PARTICLES\n varying vec4 projPosition;\n varying float linearDepth;\n#endif\n",He.soft_vertex="\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n",He.soft_pars_fragment="\n#ifdef SOFT_PARTICLES\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 return (zFar * zNear) / (zFar - d * (zFar - zNear));\n }\n#endif\n",He.soft_fragment="\n#ifdef SOFT_PARTICLES\n\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float viewDepth = linearize_depth(readDepth);\n float softParticlesFade = saturate(SOFT_INV_FADE_DISTANCE * ((viewDepth - SOFT_NEAR_FADE) - linearDepth));\n\n gl_FragColor *= softParticlesFade;\n#endif\n",Ye=!0)}var Ke,$e="\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float c = cos(rotation);\n float s = sin(rotation);\n\n vec2 alignedPosition = position.xy * size.xy;\n vec2 rotatedPosition;\n rotatedPosition.x = c * alignedPosition.x - s * alignedPosition.y;\n rotatedPosition.y = s * alignedPosition.x + c * alignedPosition.y;\n\n#ifdef HORIZONTAL\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.x += rotatedPosition.x;\n mvPosition.z -= rotatedPosition.y;\n mvPosition = view * mvPosition;\n#elif defined(VERTICAL)\n vec4 mvPosition = world * vec4(offset, 1.0);\n mvPosition.y += rotatedPosition.y;\n mvPosition = view * mvPosition;\n mvPosition.x += rotatedPosition.x;\n#else\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n mvPosition.xy += rotatedPosition;\n#endif\n\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n",ti="\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_COLOR_AS_ALPHA\n baseColor.a *= (baseColor.r + baseColor.g + baseColor.b) / 3.0;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n gl_FragColor = baseColor;\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n",ei="\nattribute vec3 position;\nattribute vec2 uv;\nattribute vec3 normal;\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute vec4 rotation;\nattribute float uvTile;\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\nvarying vec3 vWorldPos;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 qVec = q.xyz;\n float qW = q.w;\n vec3 t = 2.0 * cross(qVec, v);\n return v + qW * t + cross(qVec, t);\n}\n\nvoid main() {\n vec3 scaledPosition = position * size;\n vec3 rotatedPosition = applyQuaternion(scaledPosition, rotation);\n vec3 rotatedNormal = normalize(applyQuaternion(normal, rotation));\n vec3 localPos = rotatedPosition + offset;\n\n vec4 worldPos = world * vec4(localPos, 1.0);\n vec4 viewPos = view * worldPos;\n gl_Position = projection * viewPos;\n\n vWorldPos = worldPos.xyz;\n vNormal = normalize((world * vec4(rotatedNormal, 0.0)).xyz);\n\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -viewPos.z;\n#endif\n\n#ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n#else\n vUV = uv;\n#endif\n\n vColor = color;\n}\n",ii="\nvarying vec2 vUV;\nvarying vec4 vColor;\nvarying vec3 vNormal;\n\nuniform vec3 lightDirection;\nuniform vec3 lightColor;\nuniform vec3 ambientColor;\n\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\n#ifdef SOFT_PARTICLES\nuniform sampler2D depthTexture;\nuniform vec2 softParams;\nuniform vec4 projParams;\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\n#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n #ifdef TILE_BLEND\n vec4 texColor2 = texture2D(map, vUV2);\n texColor = mix(texColor, texColor2, vTileBlend);\n #endif\n baseColor *= texColor;\n#endif\n\n#ifdef USE_ALPHATEST\n if (baseColor.a < alphaTest) discard;\n#else\n if (baseColor.a < 0.01) discard;\n#endif\n\n vec3 N = normalize(vNormal);\n vec3 L = normalize(-lightDirection);\n float NdotL = max(dot(N, L), 0.0);\n vec3 litColor = ambientColor + lightColor * NdotL;\n\n gl_FragColor = vec4(baseColor.rgb * litColor, baseColor.a);\n\n#ifdef SOFT_PARTICLES\n vec2 p2 = projPosition.xy / projPosition.w;\n p2 = 0.5 * p2 + 0.5;\n float readDepth = texture2D(depthTexture, p2.xy).r;\n float zNear = projParams.x;\n float zFar = projParams.y;\n float viewDepth = (zFar * zNear) / (zFar - readDepth * (zFar - zNear));\n float fade = clamp(softParams.y * ((viewDepth - softParams.x) - linearDepth), 0.0, 1.0);\n gl_FragColor *= fade;\n#endif\n}\n",si="\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute float rotation;\nattribute float uvTile;\nattribute vec4 velocity;\n\n// Uniforms\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 projection;\nuniform float speedFactor;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef TILE_BLEND\nvarying vec2 vUV2;\nvarying float vTileBlend;\n#endif\n#ifdef SOFT_PARTICLES\nvarying vec4 projPosition;\nvarying float linearDepth;\n#endif\n\nvoid main() {\n float lengthFactor = velocity.w;\n float avgSize = (size.x + size.y) * 0.5;\n vec4 mvPosition = view * world * vec4(offset, 1.0);\n vec3 viewVelocity = mat3(view * world) * velocity.xyz;\n float vlength = length(viewVelocity);\n // Stretch direction is the velocity direction; only a genuinely motionless particle has none.\n // Deriving it via normalize keeps the stretch aligned even when the speed contribution is ~0\n // (e.g. speedFactor 0), instead of collapsing the whole burst onto a fixed screen axis.\n vec3 vdir = vlength > 0.000001 ? viewVelocity / vlength : vec3(0.0, 0.0, 1.0);\n mvPosition.xyz += position.y * normalize(cross(mvPosition.xyz, vdir)) * avgSize;\n // Equivalent to viewVelocity * (1.0 + lengthFactor / vlength) for moving particles, but the\n // size-based term (vdir * lengthFactor) survives when the velocity contribution vanishes.\n mvPosition.xyz -= (position.x + 0.5) * (viewVelocity + vdir * lengthFactor) * avgSize;\n gl_Position = projection * mvPosition;\n#ifdef SOFT_PARTICLES\n projPosition = gl_Position;\n linearDepth = -mvPosition.z;\n#endif\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #ifdef TILE_BLEND\n float nextTile = ceil(uvTile);\n float nextU = mod(nextTile, tc.x) / tc.x;\n float nextV = 1.0 - floor(nextTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV2 = uv / tc + vec2(nextU, nextV);\n vTileBlend = fract(uvTile);\n #endif\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n",ri="\nattribute vec3 position;\nattribute vec3 previous;\nattribute vec3 next;\nattribute float side;\nattribute float width;\nattribute vec2 uv;\nattribute vec4 color;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform float lineWidth;\nuniform vec2 resolution;\nuniform float sizeAttenuation;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 fix(vec4 i, float aspect) {\n vec2 res = i.xy / i.w;\n res.x *= aspect;\n return res;\n}\n\nvoid main() {\n float aspect = resolution.x / resolution.y;\n vec4 finalPosition = projection * view * vec4(position, 1.0);\n vec4 prevPos = projection * view * vec4(previous, 1.0);\n vec4 nextPos = projection * view * vec4(next, 1.0);\n\n vec2 currentP = fix(finalPosition, aspect);\n vec2 prevP = fix(prevPos, aspect);\n vec2 nextP = fix(nextPos, aspect);\n\n float w = lineWidth * width;\n vec2 dir;\n if (distance(nextP, currentP) < 0.0001) {\n dir = normalize(currentP - prevP);\n } else if (distance(prevP, currentP) < 0.0001) {\n dir = normalize(nextP - currentP);\n } else {\n vec2 dir1 = normalize(currentP - prevP);\n vec2 dir2 = normalize(nextP - currentP);\n dir = normalize(dir1 + dir2);\n }\n vec4 normal = vec4(-dir.y, dir.x, 0.0, 1.0);\n normal.xy *= 0.5 * w;\n normal *= projection;\n if (sizeAttenuation == 0.0) {\n normal.xy *= finalPosition.w;\n normal.xy /= (vec4(resolution, 0.0, 1.0) * projection).xy;\n }\n finalPosition.xy += normal.xy * side;\n gl_Position = finalPosition;\n vUV = uv;\n vColor = color;\n}\n",ni="\nvarying vec2 vUV;\nvarying vec4 vColor;\n\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n\nvoid main() {\n vec4 baseColor = vColor;\n\n#ifdef USE_MAP\n vec4 texColor = texture2D(map, vUV);\n baseColor *= texColor;\n#endif\n\n if (baseColor.a < 0.01) discard;\n\n gl_FragColor = baseColor;\n}\n";exports.RenderMode=void 0,(Ke=exports.RenderMode||(exports.RenderMode={}))[Ke.BillBoard=0]="BillBoard",Ke[Ke.StretchedBillBoard=1]="StretchedBillBoard",Ke[Ke.Mesh=2]="Mesh",Ke[Ke.Trail=3]="Trail",Ke[Ke.HorizontalBillBoard=4]="HorizontalBillBoard",Ke[Ke.VerticalBillBoard=5]="VerticalBillBoard";class oi{constructor(t,e){this.scene=e,this.maxParticles=1e3,this.systems=new Set,this.settings={instancingGeometry:t.instancingGeometry,instancingIndices:t.instancingIndices,instancingUVs:t.instancingUVs,instancingNormals:t.instancingNormals,renderMode:t.renderMode,renderOrder:t.renderOrder,uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softNearFade:t.softNearFade,softFarFade:t.softFarFade,materialBlendMode:t.materialBlendMode,materialTransparent:t.materialTransparent,materialDepthTest:t.materialDepthTest,materialDepthWrite:t.materialDepthWrite,materialAlphaTest:t.materialAlphaTest,texture:t.texture,layerMask:t.layerMask},this.mesh=new i.Mesh("vfxBatch",e),this.mesh.alwaysSelectAsActiveMesh=!0}addSystem(t){this.systems.add(t)}removeSystem(t){this.systems.delete(t)}getVisibleSystems(){const t=[];for(const e of this.systems)e.emitter.visible&&t.push(e);return t}applyDepthTexture(t){const e=this.mesh.material;e&&e instanceof s.ShaderMaterial&&e.setTexture("depthTexture",t)}dispose(){this.mesh.dispose()}}class ai extends oi{constructor(t,e){super(t,e),this.vector_=new k,this.vector2_=new k,this.vector3_=new k,this.quaternion_=new I,this.quaternion2_=new I,this.quaternion3_=new I,this.rotationMat_=new rt,this.rotationMat2_=new rt,this.lastStretchedSpeedFactor=Number.NaN,this.maxParticles=1e3,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.mesh.dispose(),this.mesh=new i.Mesh("spriteBatch",this.scene),this.mesh.alwaysSelectAsActiveMesh=!0;const t=new r.VertexData;t.positions=this.settings.instancingGeometry,t.indices=this.settings.instancingIndices,this.settings.instancingUVs&&(t.uvs=this.settings.instancingUVs),this.settings.instancingNormals&&(t.normals=this.settings.instancingNormals),t.applyToMesh(this.mesh,!1),this.buildExpandableBuffers()}buildExpandableBuffers(){const e=this.scene.getEngine();this.offsetBuffer=new Float32Array(3*this.maxParticles),this.offsetVB=new t.VertexBuffer(e,this.offsetBuffer,"offset",!0,!1,3,!0),this.mesh.setVerticesBuffer(this.offsetVB),this.colorBuffer=new Float32Array(4*this.maxParticles),this.colorVB=new t.VertexBuffer(e,this.colorBuffer,"color",!0,!1,4,!0),this.mesh.setVerticesBuffer(this.colorVB),this.sizeBuffer=new Float32Array(3*this.maxParticles),this.sizeVB=new t.VertexBuffer(e,this.sizeBuffer,"size",!0,!1,3,!0),this.mesh.setVerticesBuffer(this.sizeVB),this.uvTileBuffer=new Float32Array(this.maxParticles),this.uvTileVB=new t.VertexBuffer(e,this.uvTileBuffer,"uvTile",!0,!1,1,!0),this.mesh.setVerticesBuffer(this.uvTileVB),this.settings.renderMode===exports.RenderMode.Mesh?(this.rotationBuffer=new Float32Array(4*this.maxParticles),this.rotationVB=new t.VertexBuffer(e,this.rotationBuffer,"rotation",!0,!1,4,!0)):(this.rotationBuffer=new Float32Array(this.maxParticles),this.rotationVB=new t.VertexBuffer(e,this.rotationBuffer,"rotation",!0,!1,1,!0)),this.mesh.setVerticesBuffer(this.rotationVB),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&(this.velocityBuffer=new Float32Array(4*this.maxParticles),this.velocityVB=new t.VertexBuffer(e,this.velocityBuffer,"velocity",!0,!1,4,!0),this.mesh.setVerticesBuffer(this.velocityVB)),this.mesh.forcedInstanceCount=0,this.mesh.doNotSyncBoundingInfo=!0}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.buildExpandableBuffers()}rebuildMaterial(){const t=`quarksParticle_${this.settings.renderMode}_${Date.now()}`;let e,i;this.lastStretchedSpeedFactor=Number.NaN;const r=[];this.settings.renderMode===exports.RenderMode.Mesh?(e=ei,i=ii):this.settings.renderMode===exports.RenderMode.StretchedBillBoard?(e=si,i=ti):(e=$e,i=ti),this.settings.texture&&r.push("USE_MAP"),(this.settings.uTileCount>1||this.settings.vTileCount>1)&&r.push("UV_TILE"),this.settings.blendTiles&&r.push("TILE_BLEND"),this.settings.softParticles&&r.push("SOFT_PARTICLES"),this.settings.materialAlphaTest>0&&r.push("USE_ALPHATEST"),this.settings.renderMode===exports.RenderMode.VerticalBillBoard&&r.push("VERTICAL"),this.settings.renderMode===exports.RenderMode.HorizontalBillBoard&&r.push("HORIZONTAL"),n.Effect.ShadersStore[t+"VertexShader"]=e,n.Effect.ShadersStore[t+"FragmentShader"]=i;const h=["position","uv","offset","color","size","rotation","uvTile"];this.settings.renderMode===exports.RenderMode.Mesh&&h.push("normal"),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&h.push("velocity");const l=["world","view","projection","worldView","worldViewProjection"],c=[];(this.settings.uTileCount>1||this.settings.vTileCount>1)&&(l.push("tileCountX"),l.push("tileCountY")),this.settings.texture&&c.push("map"),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&l.push("speedFactor"),this.settings.softParticles&&(l.push("softParams"),l.push("projParams"),c.push("depthTexture")),this.settings.materialAlphaTest>0&&l.push("alphaTest"),this.settings.renderMode===exports.RenderMode.Mesh&&(l.push("lightDirection"),l.push("lightColor"),l.push("ambientColor"));const u=new s.ShaderMaterial(t,this.scene,{vertex:t,fragment:t},{attributes:h,uniforms:l,samplers:c,defines:r,needAlphaBlending:this.settings.materialTransparent});this.settings.texture&&u.setTexture("map",this.settings.texture),(this.settings.uTileCount>1||this.settings.vTileCount>1)&&(u.setFloat("tileCountX",this.settings.uTileCount),u.setFloat("tileCountY",this.settings.vTileCount)),this.settings.renderMode===exports.RenderMode.StretchedBillBoard&&u.setFloat("speedFactor",this.settings.softNearFade>0?this.settings.softNearFade:1),this.settings.softParticles&&(u.setVector2("softParams",new a.Vector2(this.settings.softNearFade,1/Math.max(this.settings.softFarFade-this.settings.softNearFade,1e-4))),u.onBindObservable.add(()=>{const t=this.scene.activeCamera;t&&u.setVector4("projParams",new a.Vector4(t.minZ,t.maxZ,0,0))})),this.settings.materialAlphaTest>0&&u.setFloat("alphaTest",this.settings.materialAlphaTest),this.settings.renderMode===exports.RenderMode.Mesh&&(u.setVector3("lightDirection",new a.Vector3(.4,-1,.6)),u.setVector3("lightColor",new a.Vector3(1,1,1)),u.setVector3("ambientColor",new a.Vector3(.35,.35,.35))),u.backFaceCulling=!1,this.settings.materialTransparent?u.alphaMode=this.settings.materialBlendMode:u.alphaMode=o.Constants.ALPHA_DISABLE,u.needDepthPrePass=this.settings.materialDepthWrite,u.forceDepthWrite=this.settings.materialDepthWrite,u.disableDepthWrite=!this.settings.materialDepthWrite,this.mesh.material=u}update(){let t=0,e=0;const i=this.settings.renderMode,r=i===exports.RenderMode.Mesh,n=i===exports.RenderMode.StretchedBillBoard,o=this.getVisibleSystems();for(const t of o)e+=t.particleNum;e>this.maxParticles&&this.expandBuffers(e);for(const e of o){const i=e.particles,s=e.particleNum,o=this.quaternion2_,a=this.vector2_,h=this.vector3_,l=e.worldSpace;e.emitter.matrixWorld.decompose(a,o,h),this.rotationMat_.setFromMatrix4(e.emitter.matrixWorld);const c=Math.abs(h.x),u=Math.abs(h.y),d=Math.abs(h.z);for(let a=0;a<s;a++,t++){const s=i[a];if(r){let e;if(l)e=s.rotation;else{let t;t=s.parentMatrix?this.quaternion3_.setFromRotationMatrix(s.parentMatrix):o,e=this.quaternion_,e.copy(t).multiply(s.rotation)}const i=4*t;this.rotationBuffer[i]=e.x,this.rotationBuffer[i+1]=e.y,this.rotationBuffer[i+2]=e.z,this.rotationBuffer[i+3]=e.w}else this.rotationBuffer[t]=s.rotation;let h;l?h=s.position:(h=this.vector_,s.parentMatrix?h.copy(s.position).applyMatrix4(s.parentMatrix):h.copy(s.position).applyMatrix4(e.emitter.matrixWorld));const m=3*t;this.offsetBuffer[m]=h.x,this.offsetBuffer[m+1]=h.y,this.offsetBuffer[m+2]=h.z;const p=4*t;this.colorBuffer[p]=s.color.x,this.colorBuffer[p+1]=s.color.y,this.colorBuffer[p+2]=s.color.z,this.colorBuffer[p+3]=s.color.w;const y=3*t;if(l||s.parentMatrix?(this.sizeBuffer[y]=s.size.x,this.sizeBuffer[y+1]=s.size.y,this.sizeBuffer[y+2]=s.size.z):(this.sizeBuffer[y]=s.size.x*c,this.sizeBuffer[y+1]=s.size.y*u,this.sizeBuffer[y+2]=s.size.z*d),this.uvTileBuffer[t]=s.uvTile,n&&this.velocityBuffer){let i=e.rendererEmitterSettings.speedFactor;0===i&&(i=.001);const r=e.rendererEmitterSettings.lengthFactor;let n;l?n=s.velocity:(n=this.vector_,s.parentMatrix?(this.rotationMat2_.setFromMatrix4(s.parentMatrix),n.copy(s.velocity).applyMatrix3(this.rotationMat2_)):n.copy(s.velocity).applyMatrix3(this.rotationMat_));const o=4*t;this.velocityBuffer[o]=n.x*i,this.velocityBuffer[o+1]=n.y*i,this.velocityBuffer[o+2]=n.z*i,this.velocityBuffer[o+3]=r}}}if(n&&this.mesh.material instanceof s.ShaderMaterial&&o.length>0){const t=o[0].rendererEmitterSettings.speedFactor??1,e=0===t?.001:t;e!==this.lastStretchedSpeedFactor&&(this.mesh.material.setFloat("speedFactor",e),this.lastStretchedSpeedFactor=e)}this.mesh.forcedInstanceCount=t,0!==t?(this.offsetVB.update(this.offsetBuffer),this.sizeVB.update(this.sizeBuffer),this.colorVB.update(this.colorBuffer),this.uvTileVB.update(this.uvTileBuffer),this.rotationVB.update(this.rotationBuffer),n&&this.velocityVB&&this.velocityBuffer&&this.velocityVB.update(this.velocityBuffer)):this.uploadClearedInstance(r,n)}uploadClearedInstance(t,e){this.colorBuffer[3]=0,this.sizeBuffer[0]=0,this.sizeBuffer[1]=0,this.sizeBuffer[2]=0,this.colorVB.update(this.colorBuffer.subarray(0,4)),this.sizeVB.update(this.sizeBuffer.subarray(0,3)),this.offsetVB.update(this.offsetBuffer.subarray(0,3)),this.uvTileVB.update(this.uvTileBuffer.subarray(0,1)),t?this.rotationVB.update(this.rotationBuffer.subarray(0,4)):this.rotationVB.update(this.rotationBuffer.subarray(0,1)),e&&this.velocityVB&&this.velocityBuffer&&this.velocityVB.update(this.velocityBuffer.subarray(0,4))}dispose(){this.mesh.material&&this.mesh.material.dispose(),super.dispose()}}class hi extends oi{getTrailHistoryCount(t){const e=t._trailHistoryCount;return"number"==typeof e?e:t.previous.length}constructor(t,e){super(t,e),this.vector_=new k,this.vector2_=new k,this.vector3_=new k,this.quaternion_=new I,this.maxParticles=1e4,this.setupBuffers(),this.rebuildMaterial()}setupBuffers(){this.mesh.dispose(),this.mesh=new i.Mesh("trailBatch",this.scene),this.mesh.alwaysSelectAsActiveMesh=!0,this.buildGeometryBuffers()}buildGeometryBuffers(){this.positionBuffer=new Float32Array(6*this.maxParticles),this.previousBuffer=new Float32Array(6*this.maxParticles),this.nextBuffer=new Float32Array(6*this.maxParticles),this.uvBuffer=new Float32Array(4*this.maxParticles),this.sideBuffer=new Float32Array(2*this.maxParticles),this.widthBuffer=new Float32Array(2*this.maxParticles),this.colorBuffer=new Float32Array(8*this.maxParticles),this.indexBuffer=new Uint32Array(6*this.maxParticles),this.positionBuffer[0]=0,this.positionBuffer[1]=0,this.positionBuffer[2]=0,this.positionBuffer[3]=1,this.positionBuffer[4]=0,this.positionBuffer[5]=0,this.positionBuffer[6]=0,this.positionBuffer[7]=1,this.positionBuffer[8]=0,this.positionBuffer[9]=1,this.positionBuffer[10]=1,this.positionBuffer[11]=0,this.indexBuffer[0]=0,this.indexBuffer[1]=1,this.indexBuffer[2]=2,this.indexBuffer[3]=1,this.indexBuffer[4]=3,this.indexBuffer[5]=2,this.mesh.setVerticesData(t.VertexBuffer.PositionKind,this.positionBuffer,!0),this.mesh.setVerticesData(t.VertexBuffer.UVKind,this.uvBuffer,!0),this.mesh.setVerticesData(t.VertexBuffer.ColorKind,this.colorBuffer,!0,4),this.mesh.setIndices(this.indexBuffer.subarray(0,6),null,!0);const e=this.scene.getEngine();this.previousVB=new t.VertexBuffer(e,this.previousBuffer,"previous",!0,!1,3,!1),this.nextVB=new t.VertexBuffer(e,this.nextBuffer,"next",!0,!1,3,!1),this.sideVB=new t.VertexBuffer(e,this.sideBuffer,"side",!0,!1,1,!1),this.widthVB=new t.VertexBuffer(e,this.widthBuffer,"width",!0,!1,1,!1),this.mesh.setVerticesBuffer(this.previousVB),this.mesh.setVerticesBuffer(this.nextVB),this.mesh.setVerticesBuffer(this.sideVB),this.mesh.setVerticesBuffer(this.widthVB),this.mesh.doNotSyncBoundingInfo=!0;const i=new a.Vector3(-1e4,-1e4,-1e4),s=new a.Vector3(1e4,1e4,1e4);if(this.mesh.setBoundingInfo(new h.BoundingInfo(i,s)),this.mesh.subMeshes)for(const t of this.mesh.subMeshes)t._boundingInfo=this.mesh.getBoundingInfo()}expandBuffers(t){for(;t>=this.maxParticles;)this.maxParticles*=2;this.buildGeometryBuffers()}rebuildMaterial(){const t=`quarksTrail_${Date.now()}`,e=[];this.settings.texture&&e.push("USE_MAP"),n.Effect.ShadersStore[t+"VertexShader"]=ri,n.Effect.ShadersStore[t+"FragmentShader"]=ni;const i=[];this.settings.texture&&i.push("map");const r=new s.ShaderMaterial(t,this.scene,{vertex:t,fragment:t},{attributes:["position","previous","next","side","width","uv","color"],uniforms:["world","view","projection","worldViewProjection","lineWidth","resolution","sizeAttenuation"],samplers:i,defines:e,needAlphaBlending:this.settings.materialTransparent});this.settings.texture&&r.setTexture("map",this.settings.texture);const h=this.scene.getEngine();r.setFloat("lineWidth",1),r.setVector2("resolution",new a.Vector2(h.getRenderWidth(),h.getRenderHeight())),r.setFloat("sizeAttenuation",1),r.onBindObservable.add(()=>{const t=this.scene.getEngine();r.setVector2("resolution",new a.Vector2(t.getRenderWidth(),t.getRenderHeight()))}),r.backFaceCulling=!1,this.settings.materialTransparent?r.alphaMode=this.settings.materialBlendMode:r.alphaMode=o.Constants.ALPHA_DISABLE,r.needDepthPrePass=this.settings.materialDepthWrite,r.forceDepthWrite=this.settings.materialDepthWrite,r.disableDepthWrite=!this.settings.materialDepthWrite,this.mesh.material=r}update(){let e=0,i=0,s=0;const r=this.getVisibleSystems();for(const t of r)for(let e=0;e<t.particleNum;e++)s+=2*this.getTrailHistoryCount(t.particles[e]);s>this.maxParticles&&this.expandBuffers(s);for(const t of r){t.emitter.computeWorldMatrix&&t.emitter.computeWorldMatrix(!0);const s=this.quaternion_,r=this.vector2_,n=this.vector3_;t.emitter.matrixWorld.decompose(r,s,n);const o=t.particles,a=t.particleNum,h=this.settings.uTileCount,l=this.settings.vTileCount,c=1/h,u=1/l,d=t.worldSpace,m=(Math.abs(n.x)+Math.abs(n.y)+Math.abs(n.z))/3;for(let s=0;s<a;s++){const r=o[s],n=r,a=n._trailHistoryCount,h=n._trailHistoryCapacity,p=n._trailHistoryHead,y=n._trailHistoryPositions,f=n._trailHistorySizes,x=n._trailHistoryColors,g="number"==typeof a&&a>0&&"number"==typeof h&&"number"==typeof p&&y instanceof Float32Array&&f instanceof Float32Array&&x instanceof Float32Array,v=g?h:0,S=g?p:0,M=y,w=f,b=x,_=r.previous,z=g?a:_.length;if(0===z)continue;const T=r.uvTile%l,O=Math.floor(r.uvTile/l+.001),B=r.parentMatrix??t.emitter.matrixWorld;let P=_.head,N=P,C=N?.next??N;const V=g?(S-z+v)%v:0;for(let t=0;t<z;t++,e+=2){let s,n,o,a,h,p,y,f,x,S,_,F,A,E;if(g){const e=(V+t)%v,i=3*e,r=3*(0===t?e:(V+t-1)%v),l=3*(t+1<z?(V+t+1)%v:e);s=M[i],n=M[i+1],o=M[i+2],x=M[r],S=M[r+1],_=M[r+2],F=M[l],A=M[l+1],E=M[l+2],a=w[e];const c=4*e;h=b[c],p=b[c+1],y=b[c+2],f=b[c+3]}else{const t=P.data,e=N.data,i=C.data;s=e.position.x,n=e.position.y,o=e.position.z,x=t.position.x,S=t.position.y,_=t.position.z,F=i.position.x,A=i.position.y,E=i.position.z,a=e.size,h=e.color.x,p=e.color.y,y=e.color.z,f=e.color.w}d||(this.vector_.set(s,n,o).applyMatrix4(B),s=this.vector_.x,n=this.vector_.y,o=this.vector_.z,this.vector_.set(x,S,_).applyMatrix4(B),x=this.vector_.x,S=this.vector_.y,_=this.vector_.z,this.vector_.set(F,A,E).applyMatrix4(B),F=this.vector_.x,A=this.vector_.y,E=this.vector_.z);const D=3*e;this.positionBuffer[D]=s,this.positionBuffer[D+1]=n,this.positionBuffer[D+2]=o,this.positionBuffer[D+3]=s,this.positionBuffer[D+4]=n,this.positionBuffer[D+5]=o,this.previousBuffer[D]=x,this.previousBuffer[D+1]=S,this.previousBuffer[D+2]=_,this.previousBuffer[D+3]=x,this.previousBuffer[D+4]=S,this.previousBuffer[D+5]=_,this.nextBuffer[D]=F,this.nextBuffer[D+1]=A,this.nextBuffer[D+2]=E,this.nextBuffer[D+3]=F,this.nextBuffer[D+4]=A,this.nextBuffer[D+5]=E,this.sideBuffer[e]=1,this.sideBuffer[e+1]=-1,d||r.parentMatrix?(this.widthBuffer[e]=a,this.widthBuffer[e+1]=a):(this.widthBuffer[e]=a*m,this.widthBuffer[e+1]=a*m);const R=2*e;this.uvBuffer[R]=(t/z+T)*c,this.uvBuffer[R+1]=(l-O-1)*u,this.uvBuffer[R+2]=(t/z+T)*c,this.uvBuffer[R+3]=(l-O)*u;const J=4*e;this.colorBuffer[J]=h,this.colorBuffer[J+1]=p,this.colorBuffer[J+2]=y,this.colorBuffer[J+3]=f,this.colorBuffer[J+4]=h,this.colorBuffer[J+5]=p,this.colorBuffer[J+6]=y,this.colorBuffer[J+7]=f,t+1<z&&(this.indexBuffer[3*i]=e,this.indexBuffer[3*i+1]=e+1,this.indexBuffer[3*i+2]=e+2,i++,this.indexBuffer[3*i]=e+2,this.indexBuffer[3*i+1]=e+1,this.indexBuffer[3*i+2]=e+3,i++),g||(P=N,N=C,C=C?.next??C)}}}if(e>0&&i>0){this.mesh.updateVerticesData(t.VertexBuffer.PositionKind,this.positionBuffer),this.mesh.updateVerticesData(t.VertexBuffer.UVKind,this.uvBuffer),this.mesh.updateIndices(this.indexBuffer.subarray(0,3*i)),this.previousVB.update(this.previousBuffer),this.nextVB.update(this.nextBuffer),this.sideVB.update(this.sideBuffer),this.widthVB.update(this.widthBuffer);const s=this.mesh.getVertexBuffer(t.VertexBuffer.ColorKind);if(s&&s.update(this.colorBuffer),this.mesh.subMeshes&&this.mesh.subMeshes.length>0){const t=this.mesh.getBoundingInfo();for(const e of this.mesh.subMeshes)e._boundingInfo=t;this.mesh.subMeshes[0].indexCount=3*i,this.mesh.subMeshes[0].verticesCount=e}}else this.mesh.subMeshes&&this.mesh.subMeshes.length>0&&(this.mesh.subMeshes[0].indexCount=0,this.mesh.subMeshes[0].verticesCount=0)}dispose(){this.mesh.material&&this.mesh.material.dispose(),super.dispose()}}class li extends e.TransformNode{constructor(t,e){super(t,e),this.batches=[],this.systemToBatchIndex=new Map,this.depthTexture=null,this.adaptivePerformanceState={enabled:!1,targetFrameMs:16.7,minQuality:.35,maxQuality:1,decreaseStep:.08,increaseStep:.02,currentQuality:1,lastFrameCpuMs:0},this.lastAppliedQuality=Number.NaN}static clamp(t,e,i){return Math.max(e,Math.min(i,t))}static equals(t,e){return t.materialBlendMode===e.materialBlendMode&&t.materialTransparent===e.materialTransparent&&t.materialDepthTest===e.materialDepthTest&&t.materialDepthWrite===e.materialDepthWrite&&t.materialAlphaTest===e.materialAlphaTest&&t.texture===e.texture&&t.renderMode===e.renderMode&&t.blendTiles===e.blendTiles&&t.softParticles===e.softParticles&&t.softFarFade===e.softFarFade&&t.softNearFade===e.softNearFade&&t.uTileCount===e.uTileCount&&t.vTileCount===e.vTileCount&&t.instancingGeometry===e.instancingGeometry&&t.renderOrder===e.renderOrder&&t.layerMask===e.layerMask}addSystem(t){const e=t;e._renderer=this,this.adaptivePerformanceState.enabled&&e.setQualityFactor(this.adaptivePerformanceState.currentQuality);const i=e.getRendererSettings();for(let e=0;e<this.batches.length;e++)if(li.equals(this.batches[e].settings,i))return this.batches[e].addSystem(t),void this.systemToBatchIndex.set(t,e);let s;const r=this.getScene();switch(i.renderMode){case exports.RenderMode.Trail:s=new hi(i,r);break;case exports.RenderMode.Mesh:case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:case exports.RenderMode.StretchedBillBoard:s=new ai(i,r);break;default:throw new Error(`Unsupported render mode: ${i.renderMode}`)}s.mesh.parent=this,this.depthTexture&&s.applyDepthTexture(this.depthTexture),s.addSystem(t),this.batches.push(s),this.systemToBatchIndex.set(t,this.batches.length-1)}deleteSystem(t){const e=this.systemToBatchIndex.get(t);void 0!==e&&(this.batches[e].removeSystem(t),this.systemToBatchIndex.delete(t))}updateSystem(t){this.deleteSystem(t),this.addSystem(t)}setDepthTexture(t){this.depthTexture=t;for(const e of this.batches)e.applyDepthTexture(t)}configureAdaptivePerformance(t={}){const e=this.adaptivePerformanceState,i=li.clamp(t.minQuality??e.minQuality,.05,1),s=li.clamp(t.maxQuality??e.maxQuality,i,1);e.targetFrameMs=Math.max(t.targetFrameMs??e.targetFrameMs,.1),e.minQuality=i,e.maxQuality=s,e.decreaseStep=Math.max(t.decreaseStep??e.decreaseStep,.001),e.increaseStep=Math.max(t.increaseStep??e.increaseStep,.001),e.currentQuality=li.clamp(e.currentQuality,e.minQuality,e.maxQuality),e.enabled=!0,this.lastAppliedQuality=Number.NaN}disableAdaptivePerformance(t=!0){this.adaptivePerformanceState.enabled=!1,t&&(this.adaptivePerformanceState.currentQuality=this.adaptivePerformanceState.maxQuality,this.applyAdaptiveQuality())}getAdaptivePerformanceState(){return{...this.adaptivePerformanceState}}applyAdaptiveQuality(){const t=this.adaptivePerformanceState.currentQuality;if(t!==this.lastAppliedQuality){for(const e of this.systemToBatchIndex.keys())e.setQualityFactor(t);this.lastAppliedQuality=t}}update(t){const e=this.adaptivePerformanceState,i=e.enabled?performance.now():0;e.enabled&&this.applyAdaptiveQuality();for(const e of this.systemToBatchIndex.keys())e.update(t);this.refreshBatches(),e.enabled&&(e.lastFrameCpuMs=performance.now()-i,e.lastFrameCpuMs>e.targetFrameMs?e.currentQuality=li.clamp(e.currentQuality-e.decreaseStep,e.minQuality,e.maxQuality):e.currentQuality=li.clamp(e.currentQuality+e.increaseStep,e.minQuality,e.maxQuality))}refreshBatches(){for(let t=0;t<this.batches.length;t++)this.batches[t].update()}getBatchRenderStats(){return this.batches.map((t,e)=>{let i=0;const s=[];for(const e of t.systems){const t=e;i+=t.particleNum,s.push(t.emitter.name)}return{batchIndex:e,renderMode:t.settings.renderMode,instanceCount:t.mesh.forcedInstanceCount??0,particleCount:i,systemNames:s}})}dispose(){for(const t of this.batches)t.dispose();this.batches=[],this.systemToBatchIndex.clear(),super.dispose()}}const ci=li;class ui extends e.TransformNode{get matrixWorld(){const t=this.getWorldMatrix(),e=this._matrixWorld.elements;return e[0]=t.m[0],e[1]=t.m[1],e[2]=t.m[2],e[3]=t.m[3],e[4]=t.m[4],e[5]=t.m[5],e[6]=t.m[6],e[7]=t.m[7],e[8]=t.m[8],e[9]=t.m[9],e[10]=t.m[10],e[11]=t.m[11],e[12]=t.m[12],e[13]=t.m[13],e[14]=t.m[14],e[15]=t.m[15],this._matrixWorld}get visible(){return this.isEnabled()}set visible(t){this.setEnabled(t)}get uuid(){return this.uniqueId.toString()}constructor(t,e){super("particleEmitter",e||void 0),this._matrixWorld=new Q,this.system=t}dispose(){super.dispose()}extractFromCache(t){const e=[];for(const i in t){const s=t[i];s&&"object"==typeof s&&delete s.metadata,e.push(s)}return e}clone(t){const e=this.system.clone().emitter;return e.name=t??this.name,e.position.copyFrom(this.position),e.rotation.copyFrom(this.rotation),e.scaling.copyFrom(this.scaling),this.rotationQuaternion&&(e.rotationQuaternion=this.rotationQuaternion.clone()),e.setEnabled(this.isEnabled()),e}toJSON(t,e={}){return{uuid:this._quarksUUID??this.uniqueId.toString(),type:"ParticleEmitter",name:this.name,position:[this.position.x,this.position.y,this.position.z],rotation:[this.rotation.x,this.rotation.y,this.rotation.z],quaternion:this.rotationQuaternion?[this.rotationQuaternion.x,this.rotationQuaternion.y,this.rotationQuaternion.z,this.rotationQuaternion.w]:void 0,scale:[this.scaling.x,this.scaling.y,this.scaling.z],visible:this.isEnabled(),ps:this.system.toJSON(t,e)}}}function di(t,e){if(e&&e.length>0)return e;const i=t.length/3,s=new Uint32Array(i);for(let t=0;t<i;t++)s[t]=t;return s}const mi=new k(0,0,1),pi=new I,yi=new k,fi=new k,xi=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),gi=new Float32Array([0,0,1,0,1,1,0,1]),vi=new Uint32Array([0,1,2,0,2,3]);class Si{set time(t){this.emissionState.time=t}get time(){return this.emissionState.time}get isEmitEnded(){return this.emitEnded}hasPendingEmission(){if(this.looping)return!0;if(this.emitEnded)return!1;if(this.onlyUsedByOther)return!1;const t=this.emissionState;if(t.waitEmiting>0)return!0;if(t.burstIndex<this.emissionBursts.length)return!0;if(t.time>=this.duration)return!1;const e=t.time/this.duration;return this.emissionOverTime.genValue(this.memory,e)>0||this.emissionOverDistance.genValue(this.memory,e)>0}isFinished(){return!this.looping&&(!(this.particleNum>0)&&(!!this.onlyUsedByOther||!this.hasPendingEmission()))}get layers(){return this.layerMaskProxy}get texture(){return this.rendererSettings.texture}set texture(t){this.rendererSettings.texture=t,this.neededToUpdateRender=!0}get material(){return this.materialRef}set material(t){this.materialRef=t,this.applyMaterialSettings(t)}get uTileCount(){return this.rendererSettings.uTileCount}set uTileCount(t){this.rendererSettings.uTileCount=t,this.neededToUpdateRender=!0}get vTileCount(){return this.rendererSettings.vTileCount}set vTileCount(t){this.rendererSettings.vTileCount=t,this.neededToUpdateRender=!0}get blendTiles(){return this.rendererSettings.blendTiles}set blendTiles(t){this.rendererSettings.blendTiles=t,this.neededToUpdateRender=!0}get softParticles(){return this.rendererSettings.softParticles}set softParticles(t){this.rendererSettings.softParticles=t,this.neededToUpdateRender=!0}get softNearFade(){return this.rendererSettings.softNearFade}set softNearFade(t){this.rendererSettings.softNearFade=t,this.neededToUpdateRender=!0}get softFarFade(){return this.rendererSettings.softFarFade}set softFarFade(t){this.rendererSettings.softFarFade=t,this.neededToUpdateRender=!0}get instancingGeometry(){return this.rendererSettings.instancingGeometry}set instancingGeometry(t){this.restart(),this.particles.length=0,this.rendererSettings.instancingGeometry=t,this.neededToUpdateRender=!0}get blending(){return this.rendererSettings.materialBlendMode}set blending(t){this.rendererSettings.materialBlendMode=t,this.neededToUpdateRender=!0}get renderMode(){return this.rendererSettings.renderMode}set renderMode(t){if(this.rendererSettings.renderMode!==t){let e=!1;switch(this.rendererSettings.renderMode===exports.RenderMode.Trail&&(e=!0),this.rendererSettings.renderMode===exports.RenderMode.Mesh&&(this.startRotation=new wt(0)),t){case exports.RenderMode.Trail:this.rendererEmitterSettings={startLength:new wt(30),followLocalOrigin:!1},e=!0;break;case exports.RenderMode.Mesh:this.rendererEmitterSettings={},this.startRotation=new Bt(new k(0,1,0),new wt(0));break;case exports.RenderMode.StretchedBillBoard:this.rendererEmitterSettings={speedFactor:0,lengthFactor:2};break;case exports.RenderMode.BillBoard:case exports.RenderMode.VerticalBillBoard:case exports.RenderMode.HorizontalBillBoard:this.rendererEmitterSettings={}}this.rendererSettings.renderMode=t,e&&(this.restart(),this.particles.length=0),this.neededToUpdateRender=!0}}get renderOrder(){return this.rendererSettings.renderOrder}set renderOrder(t){this.rendererSettings.renderOrder=t,this.neededToUpdateRender=!0}constructor(t){if(this.emitterVelocity=new k,this.finishedEventFired=!1,this.startDelayTimeLeft=0,this.tempEmitterPos=new k,this.temp=new k,this.normalMatrix=new rt,this.memory=[],this.listeners={},this.materialRef=null,this.qualityFactor=1,this.useFastTrailHistory=!0,this.firstTimeUpdate=!0,this.layerMaskProxy={mask:t.layerMask??268435455},Object.defineProperty(this.layerMaskProxy,"mask",{enumerable:!0,get:()=>this.rendererSettings.layerMask,set:t=>{this.rendererSettings.layerMask=t,this.neededToUpdateRender=!0}}),this.autoDestroy=t.autoDestroy??!1,this.duration=t.duration??1,this.startDelay=t.startDelay??new wt(0),this.looping=t.looping??!0,this.prewarm=t.prewarm??!1,this.startLife=t.startLife??new wt(5),this.startSpeed=t.startSpeed??new wt(0),this.startRotation=t.startRotation??new wt(0),this.startSize=t.startSize??new wt(1),this.startColor=t.startColor??new St(new st(1,1,1,1)),this.emissionOverTime=t.emissionOverTime??new wt(10),this.emissionOverDistance=t.emissionOverDistance??new wt(0),this.emissionBursts=t.emissionBursts??[],this.onlyUsedByOther=t.onlyUsedByOther??!1,this.emitterShape=t.shape??new qt,this.behaviors=t.behaviors??[],this.worldSpace=t.worldSpace??!1,this.rendererEmitterSettings=t.rendererEmitterSettings??{},t.renderMode===exports.RenderMode.StretchedBillBoard){const e=this.rendererEmitterSettings;void 0!==t.speedFactor&&(e.speedFactor=t.speedFactor),e.speedFactor=e.speedFactor??0,e.lengthFactor=e.lengthFactor??0}this.rendererSettings={instancingGeometry:t.instancingGeometry??xi,instancingIndices:t.instancingIndices??vi,instancingUVs:t.instancingUVs??gi,instancingNormals:t.instancingNormals,renderMode:t.renderMode??exports.RenderMode.BillBoard,renderOrder:t.renderOrder??0,uTileCount:t.uTileCount??1,vTileCount:t.vTileCount??1,blendTiles:t.blendTiles??!1,softParticles:t.softParticles??!1,softNearFade:t.softNearFade??0,softFarFade:t.softFarFade??0,materialBlendMode:t.blendMode??o.Constants.ALPHA_ADD,materialTransparent:t.transparent??!0,materialDepthTest:t.depthTest??!0,materialDepthWrite:t.depthWrite??!1,materialAlphaTest:t.alphaTest??0,texture:t.texture??null,layerMask:t.layerMask??268435455},this.rendererSettings.renderMode!==exports.RenderMode.Mesh||this.rendererSettings.instancingNormals||(this.rendererSettings.instancingNormals=Si.createFallbackNormals(this.rendererSettings.instancingGeometry)),this.materialRef=t.material??null,this.applyMaterialSettings(this.materialRef,{blendMode:t.blendMode,transparent:t.transparent,depthTest:t.depthTest,depthWrite:t.depthWrite,alphaTest:t.alphaTest,texture:t.texture,layerMask:t.layerMask}),this.neededToUpdateRender=!0,this.particles=[],this.startTileIndex=t.startTileIndex||new wt(0),this.emitter=new ui(this,t.scene),this.paused=!1,this.particleNum=0,this.emissionState={isBursting:!1,burstParticleIndex:0,burstParticleCount:0,burstIndex:0,burstWaveIndex:0,time:0,waitEmiting:0,travelDistance:0},this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.startDelay.startGen(this.memory),this.startDelayTimeLeft=this.startDelay.genValue(this.memory,0),this.refreshTrailHistoryMode(),this.emitEnded=!1,this.markForDestroy=!1,this.prewarmed=!1}applyMaterialSettings(t,e={}){if(!this.rendererSettings)return;const i=void 0!==e.texture?e.texture:t?.albedoTexture??t?.diffuseTexture??t?.emissiveTexture??t?.opacityTexture??t?.baseTexture??this.rendererSettings.texture??null,s=e.blendMode??("number"==typeof t?.alphaMode?t.alphaMode:this.rendererSettings.materialBlendMode),r=e.transparent??("function"==typeof t?.needAlphaBlending?t.needAlphaBlending():"number"==typeof t?.alpha?t.alpha<1:this.rendererSettings.materialTransparent),n=e.depthTest??("boolean"==typeof t?.disableDepthTest?!t.disableDepthTest:this.rendererSettings.materialDepthTest),o=e.depthWrite??("boolean"==typeof t?.disableDepthWrite?!t.disableDepthWrite:"boolean"==typeof t?.forceDepthWrite?t.forceDepthWrite:this.rendererSettings.materialDepthWrite),a=e.alphaTest??("number"==typeof t?.alphaCutOff?t.alphaCutOff:"number"==typeof t?.alphaCutOffValue?t.alphaCutOffValue:this.rendererSettings.materialAlphaTest);this.rendererSettings.texture=i,this.rendererSettings.materialBlendMode=s,this.rendererSettings.materialTransparent=r,this.rendererSettings.materialDepthTest=n,this.rendererSettings.materialDepthWrite=o,this.rendererSettings.materialAlphaTest=a,void 0!==e.layerMask&&(this.rendererSettings.layerMask=e.layerMask),this.neededToUpdateRender=!0}pause(){this.paused=!0}play(){this.paused=!1}stop(){this.restart(),this.pause()}refreshTrailHistoryMode(){this.useFastTrailHistory=!this.behaviors.some(t=>"WidthOverLength"===t.type)}ensureTrailHistoryCapacity(t,e){const i=t;i._trailHistoryCapacity===e&&i._trailHistoryPositions||(i._trailHistoryCapacity=e,i._trailHistoryPositions=new Float32Array(3*e),i._trailHistorySizes=new Float32Array(e),i._trailHistoryColors=new Float32Array(4*e),i._trailHistoryHead=0,i._trailHistoryCount=0)}resetTrailHistory(t){const e=t;e._trailHistoryHead=0,e._trailHistoryCount=0}getTrailHistoryCount(t){const e=t._trailHistoryCount;return"number"==typeof e?e:t.previous.length}updateFastTrailHistory(t){const e=t,i=Math.max(1,Math.ceil(t.length));this.ensureTrailHistoryCapacity(t,i);let s=e._trailHistoryHead,r=e._trailHistoryCount;const n=e._trailHistoryPositions,o=e._trailHistorySizes,a=e._trailHistoryColors;if(t.age<=t.life){const e=3*s;n[e]=t.position.x,n[e+1]=t.position.y,n[e+2]=t.position.z,o[s]=t.size.x;const h=4*s;a[h]=t.color.x,a[h+1]=t.color.y,a[h+2]=t.color.z,a[h+3]=t.color.w,s=(s+1)%i,r<i&&r++}else r>0&&r--;e._trailHistoryHead=s,e._trailHistoryCount=r}setQualityFactor(t){this.qualityFactor=Math.max(.1,Math.min(1,t))}spawn(t,e,i){pi.setFromRotationMatrix(i);const s=yi,r=fi;i.decompose(s,pi,r);const n=this.behaviors,o=n.length,a=this.rendererSettings.renderMode,h=a===exports.RenderMode.Trail,l=e.time/this.duration,c=h?this.rendererEmitterSettings:void 0,u=Boolean(c?.followLocalOrigin);for(let s=0;s<t;s++){e.burstParticleIndex=s,this.particleNum++,this.particles.length<this.particleNum&&(h?this.particles.push(new de):this.particles.push(new ce));const t=this.particles[this.particleNum-1];if(t.reset(),t.speedModifier=1,this.startColor.startGen(t.memory),this.startColor.genColor(t.memory,t.startColor,this.emissionState.time),t.color.copy(t.startColor),this.startSpeed.startGen(t.memory),t.startSpeed=this.startSpeed.genValue(t.memory,l),this.startLife.startGen(t.memory),t.life=this.startLife.genValue(t.memory,l),t.age=0,this.startSize.startGen(t.memory),"vec3function"===this.startSize.type)this.startSize.genValue(t.memory,t.startSize,l);else{const e=this.startSize.genValue(t.memory,l);t.startSize.set(e,e,e)}if(this.startTileIndex.startGen(t.memory),t.uvTile=this.startTileIndex.genValue(t.memory),t.size.copy(t.startSize),this.rendererSettings.renderMode===exports.RenderMode.Mesh||this.rendererSettings.renderMode===exports.RenderMode.BillBoard||this.rendererSettings.renderMode===exports.RenderMode.VerticalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.HorizontalBillBoard||this.rendererSettings.renderMode===exports.RenderMode.StretchedBillBoard){const e=t;this.startRotation.startGen(t.memory),a===exports.RenderMode.Mesh?(e.rotation instanceof I||(e.rotation=new I),"rotation"===this.startRotation.type?this.startRotation.genValue(t.memory,e.rotation,1,l):e.rotation.setFromAxisAngle(mi,this.startRotation.genValue(e.memory,l))):"rotation"===this.startRotation.type?e.rotation=0:e.rotation=this.startRotation.genValue(e.memory,l)}else if(h&&c){const e=t;c.startLength.startGen(e.memory),e.length=c.startLength.genValue(e.memory,l),this.useFastTrailHistory&&(this.ensureTrailHistoryCapacity(e,Math.max(1,Math.ceil(e.length))),this.resetTrailHistory(e))}if(this.emitterShape.initialize(t,e),h&&u){const e=t;e.localPosition||(e.localPosition=new k),e.localPosition.copy(e.position)}this.worldSpace?(t.position.applyMatrix4(i),t.startSize.multiply(r).abs(),t.size.copy(t.startSize),t.velocity.multiply(r).applyMatrix3(this.normalMatrix),t.rotation&&t.rotation instanceof I&&t.rotation.multiplyQuaternions(pi,t.rotation)):this.onlyUsedByOther&&(t.parentMatrix=i);for(let e=0;e<o;e++)n[e].initialize(t,this)}}endEmit(){this.emitEnded=!0,this.autoDestroy&&(this.markForDestroy=!0),this.fire({type:"emitEnd",particleSystem:this})}dispose(){this._renderer&&this._renderer.deleteSystem(this),this.emitter.dispose(),this.fire({type:"destroy",particleSystem:this})}restart(){this.memory.length=0,this.paused=!1,this.particleNum=0,this.emissionState.isBursting=!1,this.emissionState.burstIndex=0,this.emissionState.burstWaveIndex=0,this.emissionState.time=0,this.emissionState.waitEmiting=0,this.behaviors.forEach(t=>t.reset()),this.emitEnded=!1,this.markForDestroy=!1,this.finishedEventFired=!1,this.prewarmed=!1,this.emissionBursts.forEach(t=>t.count.startGen(this.memory)),this.emissionOverDistance.startGen(this.memory),this.startDelay.startGen(this.memory),this.startDelayTimeLeft=this.startDelay.genValue(this.memory,0),this.previousEmitterPos=void 0,this.emitterVelocity.set(0,0,0)}update(t){if(this.paused)return;if(this.firstTimeUpdate&&(this.firstTimeUpdate=!1,this.emitter.computeWorldMatrix(!0)),!this.looping&&this.finishedEventFired&&0===this.particleNum)return;if(this.looping&&this.prewarm&&!this.prewarmed){this.prewarmed=!0;for(let t=0;t<60*this.duration;t++)this.update(1/60)}t>.1&&(t=.1),this.neededToUpdateRender&&(this._renderer&&this._renderer.updateSystem(this),this.neededToUpdateRender=!1);const e=this.emitter.matrixWorld.elements;if(this.tempEmitterPos.set(e[12],e[13],e[14]),void 0!==this.previousEmitterPos&&t>0&&this.emitterVelocity.copy(this.tempEmitterPos).sub(this.previousEmitterPos).divideScalar(t),(this.previousEmitterPos??(this.previousEmitterPos=new k)).copy(this.tempEmitterPos),this.startDelayTimeLeft>0&&(!this.prewarm||!this.looping)){if(this.startDelayTimeLeft-=t,this.startDelayTimeLeft>=0)return;t=Math.min(-this.startDelayTimeLeft,.1),this.startDelayTimeLeft=0}this.onlyUsedByOther||this.emit(t,this.emissionState,this.emitter.matrixWorld);const i=this.particles,s=this.behaviors.length,r=this.particleNum;this.emitterShape.update(this,t);for(let e=0;e<s;e++){const s=this.behaviors[e];s.frameUpdate(t);for(let e=0;e<r;e++){const r=i[e];r.died||s.update(r,t)}}const n=this.rendererSettings.renderMode===exports.RenderMode.Trail&&this.rendererEmitterSettings.followLocalOrigin,o=this.emitter.matrixWorld;for(let e=0;e<r;e++){const s=i[e];n&&s.localPosition?(s.position.copy(s.localPosition),s.parentMatrix?s.position.applyMatrix4(s.parentMatrix):s.position.applyMatrix4(o)):s.position.addScaledVector(s.velocity,t*s.speedModifier),s.age+=t}if(this.rendererSettings.renderMode===exports.RenderMode.Trail)for(let t=0;t<r;t++){const e=i[t];this.useFastTrailHistory?this.updateFastTrailHistory(e):e.update()}let a=this.particleNum;for(let t=0;t<a;t++){const e=i[t];!e.died||e instanceof de&&0!==this.getTrailHistoryCount(e)||(i[t]=i[a-1],i[a-1]=e,a--,t--,this.fire({type:"particleDied",particleSystem:this,particle:e}))}this.particleNum=a,this.notifyFinished()}notifyFinished(){this.isFinished()&&(this.finishedEventFired||(this.finishedEventFired=!0,this.fire({type:"finished",particleSystem:this})),this.autoDestroy&&(this.markForDestroy=!0,this.dispose()))}emit(t,e,i){e.time>this.duration&&(this.looping?(e.time-=this.duration,e.burstIndex=0,this.behaviors.forEach(t=>t.reset())):this.emitEnded||this.onlyUsedByOther||this.endEmit()),this.normalMatrix.getNormalMatrix(i);const s=this.emissionBursts,r=s.length,n=this.qualityFactor,o=Math.floor(e.waitEmiting);for(o>0&&(this.spawn(o,e,i),e.waitEmiting-=o);e.burstIndex<r&&s[e.burstIndex].time<=e.time;){const t=s[e.burstIndex];if(Math.random()<t.probability){const s=t.count.genValue(this.memory,this.time),r=n>=.999?s:Math.floor(s*n);e.isBursting=!0,e.burstParticleCount=r,this.spawn(r,e,i),e.isBursting=!1}e.burstIndex++}if(!this.emitEnded){const s=e.time/this.duration;e.waitEmiting+=t*this.emissionOverTime.genValue(this.memory,s)*n;const r=e.previousWorldPos;if(void 0!==r){this.temp.set(i.elements[12],i.elements[13],i.elements[14]),e.travelDistance+=r.distanceTo(this.temp);const t=this.emissionOverDistance.genValue(this.memory,s)*n;if(e.travelDistance*t>0){const i=Math.floor(e.travelDistance*t);e.travelDistance-=i/t,e.waitEmiting+=i}}}void 0===e.previousWorldPos&&(e.previousWorldPos=new k),e.previousWorldPos.set(i.elements[12],i.elements[13],i.elements[14]),e.time+=t}toJSON(t,e={}){const i=void 0===t||"string"==typeof t?{geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}}:t,s=this.ensureGeometryMeta(i),r=this.ensureMaterialMeta(i),n=this.toRendererSettingsJSON();return{version:"3.0",autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,startDelay:this.startDelay.toJSON(),shape:this.emitterShape.toJSON(),startLife:this.startLife.toJSON(),startSpeed:this.startSpeed.toJSON(),startRotation:this.startRotation.toJSON(),startSize:this.startSize.toJSON(),startColor:this.startColor.toJSON(),emissionOverTime:this.emissionOverTime.toJSON(),emissionOverDistance:this.emissionOverDistance.toJSON(),emissionBursts:this.emissionBursts.map(t=>({time:t.time,count:t.count.toJSON(),probability:t.probability,interval:t.interval,cycle:t.cycle})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:s,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:n,material:r,layers:this.rendererSettings.layerMask,startTileIndex:this.startTileIndex.toJSON(),uTileCount:this.rendererSettings.uTileCount,vTileCount:this.rendererSettings.vTileCount,blendTiles:this.rendererSettings.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,blending:this.rendererSettings.materialBlendMode,transparent:this.rendererSettings.materialTransparent,depthTest:this.rendererSettings.materialDepthTest,depthWrite:this.rendererSettings.materialDepthWrite,alphaTest:this.rendererSettings.materialAlphaTest,behaviors:this.behaviors.map(t=>t.toJSON()),worldSpace:this.worldSpace}}static fromJSON(t,e,i={},s){const r=jt(t.shape,e);let n;if(t.renderMode===exports.RenderMode.Trail){const e=t.rendererEmitterSettings;n={startLength:void 0!==e?.startLength?Tt(e.startLength):new wt(30),followLocalOrigin:e?.followLocalOrigin??!1}}else t.renderMode===exports.RenderMode.StretchedBillBoard?(n={...t.rendererEmitterSettings??{}},void 0!==t.speedFactor&&(n.speedFactor=t.speedFactor)):n={};const a=t.material?e.materials?.[t.material]:void 0,h=a?.texture??t.texture,l="string"==typeof h?e.textures?.[h]??null:h??null,c="string"==typeof t.instancingGeometry?e.geometries?.[t.instancingGeometry]:t.instancingGeometry,u=Si.resolveGeometryData(c),d=new Si({scene:s,autoDestroy:t.autoDestroy,looping:t.looping,prewarm:t.prewarm,duration:t.duration,startDelay:t.startDelay?Tt(t.startDelay):void 0,shape:r,startLife:Tt(t.startLife),startSpeed:Tt(t.startSpeed),startRotation:Ft(t.startRotation),startSize:Ft(t.startSize),startColor:Mt(t.startColor),emissionOverTime:Tt(t.emissionOverTime),emissionOverDistance:Tt(t.emissionOverDistance),emissionBursts:t.emissionBursts?.map(t=>({time:t.time,count:"number"==typeof t.count?new wt(t.count):Tt(t.count),probability:t.probability??1,interval:t.interval??.1,cycle:t.cycle??t.cycleCount??1})),onlyUsedByOther:t.onlyUsedByOther,instancingGeometry:u.positions,instancingIndices:u.indices,instancingUVs:u.uvs,instancingNormals:u.normals,renderMode:t.renderMode,rendererEmitterSettings:n,renderOrder:t.renderOrder,texture:l,material:a?.sourceMaterial??a,blendMode:a?.alphaMode??t.blending??o.Constants.ALPHA_ADD,transparent:a?.transparent??t.transparent??!0,depthTest:a?.depthTest??t.depthTest??!0,depthWrite:a?.depthWrite??t.depthWrite??!1,alphaTest:a?.alphaTest??t.alphaTest??0,startTileIndex:"number"==typeof t.startTileIndex?new wt(t.startTileIndex):Tt(t.startTileIndex),uTileCount:t.uTileCount,vTileCount:t.vTileCount,blendTiles:t.blendTiles,softParticles:t.softParticles,softFarFade:t.softFarFade,softNearFade:t.softNearFade,behaviors:[],worldSpace:t.worldSpace,layerMask:t.layers});return d.behaviors=(t.behaviors??[]).map(t=>{const e=Ge(t,d);return e&&"EmitSubParticleSystem"===e.type&&(i[t.subParticleSystem]=e),e}).filter(t=>null!==t),d}static nextSerializationId(t){return Si.serializationCounter+=1,`${t}_${Si.serializationCounter}`}static createFallbackNormals(t){const e=new Float32Array(t.length);for(let t=0;t<e.length;t+=3)e[t]=0,e[t+1]=0,e[t+2]=1;return e}toRendererSettingsJSON(){return this.renderMode===exports.RenderMode.Trail?{startLength:this.rendererEmitterSettings.startLength.toJSON(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?{speedFactor:this.rendererEmitterSettings.speedFactor,lengthFactor:this.rendererEmitterSettings.lengthFactor}:{}}ensureGeometryMeta(t){const e=Si.nextSerializationId("quarks_geometry");return t.geometries[e]={uuid:e,type:"QuarksGeometry",positions:Array.from(this.rendererSettings.instancingGeometry),indices:Array.from(this.rendererSettings.instancingIndices),uvs:this.rendererSettings.instancingUVs?Array.from(this.rendererSettings.instancingUVs):void 0,normals:this.rendererSettings.instancingNormals?Array.from(this.rendererSettings.instancingNormals):void 0},e}ensureMaterialMeta(t){const e=this.rendererSettings.texture;let i;e&&(i=Si.nextSerializationId("quarks_texture"),t.textures[i]=e);const s=Si.nextSerializationId("quarks_material");return t.materials[s]={uuid:s,type:"QuarksMaterial",transparent:this.rendererSettings.materialTransparent,alphaMode:this.rendererSettings.materialBlendMode,depthTest:this.rendererSettings.materialDepthTest,depthWrite:this.rendererSettings.materialDepthWrite,alphaTest:this.rendererSettings.materialAlphaTest,texture:i,sourceMaterial:this.materialRef??void 0},s}static resolveGeometryData(t){if(t?.positions){const e=t.positions instanceof Float32Array?t.positions:new Float32Array(t.positions);return{positions:e,indices:di(e,t.indices instanceof Uint16Array||t.indices instanceof Uint32Array?t.indices:t.indices?new Uint32Array(t.indices):void 0),uvs:t.uvs?t.uvs instanceof Float32Array?t.uvs:new Float32Array(t.uvs):void 0,normals:t.normals?t.normals instanceof Float32Array?t.normals:new Float32Array(t.normals):void 0}}const e=t?.data??t;if(e?.attributes?.position?.array){const t=new Float32Array(e.attributes.position.array);let i;if(e.index?.array){i=new("Uint16Array"===e.index.type?Uint16Array:Uint32Array)(e.index.array)}return{positions:t,indices:di(t,i),uvs:e.attributes.uv?.array?new Float32Array(e.attributes.uv.array):void 0,normals:e.attributes.normal?.array?new Float32Array(e.attributes.normal.array):void 0}}return{positions:xi,indices:vi,uvs:gi}}addBehavior(t){this.behaviors.push(t),this.refreshTrailHistoryMode()}getRendererSettings(){return this.rendererSettings}addEventListener(t,e){this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e)}removeAllEventListeners(t){this.listeners[t]&&(this.listeners[t]=[])}removeEventListener(t,e){if(this.listeners[t]){const i=this.listeners[t].indexOf(e);-1!==i&&this.listeners[t].splice(i,1)}}fire(t){this.listeners[t.type]&&this.listeners[t.type].forEach(e=>e(t))}clone(){const t=this.behaviors.map(t=>t.clone());let e;return e=this.renderMode===exports.RenderMode.Trail?{startLength:this.rendererEmitterSettings.startLength.clone(),followLocalOrigin:this.rendererEmitterSettings.followLocalOrigin}:this.renderMode===exports.RenderMode.StretchedBillBoard?{lengthFactor:this.rendererEmitterSettings.lengthFactor,speedFactor:this.rendererEmitterSettings.speedFactor}:{},new Si({autoDestroy:this.autoDestroy,looping:this.looping,prewarm:this.prewarm,duration:this.duration,startDelay:this.startDelay.clone(),shape:this.emitterShape.clone(),startLife:this.startLife.clone(),startSpeed:this.startSpeed.clone(),startRotation:this.startRotation.clone(),startSize:this.startSize.clone(),startColor:this.startColor.clone(),emissionOverTime:this.emissionOverTime.clone(),emissionOverDistance:this.emissionOverDistance.clone(),emissionBursts:this.emissionBursts.map(t=>({...t})),onlyUsedByOther:this.onlyUsedByOther,instancingGeometry:this.rendererSettings.instancingGeometry,instancingIndices:this.rendererSettings.instancingIndices,instancingUVs:this.rendererSettings.instancingUVs,instancingNormals:this.rendererSettings.instancingNormals,renderMode:this.renderMode,renderOrder:this.renderOrder,rendererEmitterSettings:e,material:this.materialRef,texture:this.rendererSettings.texture,startTileIndex:this.startTileIndex,uTileCount:this.rendererSettings.uTileCount,vTileCount:this.rendererSettings.vTileCount,blendTiles:this.rendererSettings.blendTiles,softParticles:this.rendererSettings.softParticles,softFarFade:this.rendererSettings.softFarFade,softNearFade:this.rendererSettings.softNearFade,behaviors:t,worldSpace:this.worldSpace,blendMode:this.rendererSettings.materialBlendMode,transparent:this.rendererSettings.materialTransparent,depthTest:this.rendererSettings.materialDepthTest,depthWrite:this.rendererSettings.materialDepthWrite,alphaTest:this.rendererSettings.materialAlphaTest,layerMask:this.rendererSettings.layerMask,scene:this.emitter.getScene()})}}Si.serializationCounter=0;class Mi{static runOnAllParticleEmitters(t,e){Mi.traverseNode(t,t=>{t instanceof ui&&e(t)})}static addToBatchRenderer(t,e){Mi.runOnAllParticleEmitters(t,t=>{e.addSystem(t.system)})}static play(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.play()})}static stop(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.stop()})}static pause(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.pause()})}static restart(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.restart()})}static setAutoDestroy(t,e){Mi.runOnAllParticleEmitters(t,t=>{t.system.autoDestroy=e})}static endEmit(t){Mi.runOnAllParticleEmitters(t,t=>{t.system.endEmit()})}static isEffectFinished(t){let e=!1,i=!0;return Mi.runOnAllParticleEmitters(t,t=>{e=!0;const s=t.system;s.looping?i=!1:s.isFinished()||(i=!1)}),e&&i}static traverseNode(t,e){e(t);const i=t.getChildren();for(const t of i)Mi.traverseNode(t,e)}}class wi extends e.TransformNode{constructor(t="QuarksPrefab",e){super(t,e),this.type="QuarksPrefab",this.animationData=[],this.isPlaying=!1,this.currentTime=-1e-5,this.timeScale=1,this.duration=0,this._lastUpdateTimeMs=Date.now(),this._tempAnimationJSON=[]}registerBatchedRenderer(t){this._batchedRenderer=t}addParticleSystemAnimation(t,e=0,i=0,s=!1){const r={startTime:e,duration:i>0?i:t.system.duration,type:"ps",loop:s,target:t};return this.animationData.push(r),this.pause(),this.updateDuration(),r}addThreeAnimation(t,e,i=0,s=e?.duration??0,r=!1,n){const o={startTime:i,duration:s>0?s:e?.duration??0,type:"three",loop:r,target:t,clip:e,clipUUID:n??e?.uuid};return this.animationData.push(o),this.updateDuration(),o}removeAnimation(t){this.animationData.splice(t,1),this.updateDuration()}play(){this.isPlaying||(this.isPlaying=!0,this._lastUpdateTimeMs=Date.now())}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationData.forEach(t=>{"ps"===t.type&&t.target instanceof ui?t.target.system.pause():t.clip?.pause?.()}))}stop(){this.pause(),this.currentTime=-1e-5,this.animationData.forEach(t=>{"ps"===t.type&&t.target instanceof ui?t.target.system.stop():t.clip?.stop?.()})}update(t){if(!this.isPlaying)return;const e=Date.now(),i=t??Math.max((e-this._lastUpdateTimeMs)/1e3,0);this._lastUpdateTimeMs=e;const s=this.currentTime;this.currentTime+=i*this.timeScale,this.currentTime>this.duration?this.stop():this.animationData.forEach(t=>{const e=t.startTime,i=t.startTime+t.duration,r=this.currentTime>=e&&this.currentTime<=i,n=s>=e&&s<=i;if(!r||n){if(!r&&n){if(t.loop&&"ps"===t.type&&t.target instanceof ui)return void t.target.system.restart();"ps"===t.type&&t.target instanceof ui?t.target.system.endEmit():t.loop?t.clip?.play?.():t.clip?.stop?.()}}else"ps"===t.type&&t.target instanceof ui?(t.target.system.restart(),this._batchedRenderer&&this._batchedRenderer.addSystem(t.target.system)):t.clip?.play?.()})}setTime(t){const e=this.currentTime;this.currentTime=t,this.animationData.forEach(i=>{const s=i.startTime,r=i.startTime+i.duration,n=this.currentTime>=s&&this.currentTime<r,o=e>=s&&e<r;!n||o?n||!o?n&&"three"===i.type&&i.clip?.setTime?.(Math.max(t-s,0)):"ps"===i.type&&i.target instanceof ui?i.target.system.endEmit():i.clip?.stop?.():"ps"===i.type&&i.target instanceof ui?i.target.system.restart():i.clip?.play?.()})}getDuration(){return this.duration}resolveReferences(t){const i={},s=t=>{t._quarksUUID&&(i[t._quarksUUID]=t),i[t.uniqueId.toString()]=t;const r=t.getChildren();for(const t of r)t instanceof e.TransformNode&&s(t)};s(t),this._tempAnimationJSON.forEach(t=>{const e=i[t.targetUUID];if("ps"===t.type&&e instanceof ui)this.addParticleSystemAnimation(e,t.startTime,t.duration,t.loop);else if("three"===t.type&&e){const i=this.resolveTimelineClip(e,t.clipUUID);this.addThreeAnimation(e,i,t.startTime,t.duration,t.loop,t.clipUUID)}}),this.updateDuration(),this._tempAnimationJSON=[]}toJSON(){return{type:this.type,name:this.name,animationData:this.animationData.map(t=>({startTime:t.startTime,duration:t.duration,type:t.type,targetUUID:t.target._quarksUUID??t.target.uniqueId.toString(),clipUUID:"three"===t.type?t.clipUUID??t.clip?.uuid:void 0,loop:t.loop}))}}static fromJSON(t,e){const i=new wi(t.name||"QuarksPrefab",e);return Array.isArray(t.animationData)&&(i._tempAnimationJSON=t.animationData.filter(t=>"ps"===t?.type||"three"===t?.type)),i}resolveTimelineClip(t,e){const i=[t.animations,t.animationGroups,t.metadata?.animations,t.metadata?.animationGroups];for(const t of i){if(!Array.isArray(t))continue;if(!e)return t[0];const i=t.find(t=>t?.uuid===e);if(i)return i}}updateDuration(){let t=0;this.animationData.forEach(e=>{const i=e.startTime+e.duration;i>t&&(t=i)}),this.duration=t}}class bi extends c.StandardMaterial{constructor(t,e,i={}){super(t,e),this.isParticleMeshStandardMaterial=!0,Object.assign(this,i)}}class _i extends u.PBRMaterial{constructor(t,e,i={}){super(t,e),this.isParticleMeshPhysicsMaterial=!0,Object.assign(this,i)}}Ze(),Xe(je),exports.ApplyCollision=Je,exports.ApplyForce=pe,exports.ApplySequences=Ee,exports.AxisAngleGenerator=Bt,exports.BatchedParticleRenderer=ci,exports.BatchedRenderer=li,exports.BehaviorFromJSON=Ge,exports.BehaviorTypes=qe,exports.Bezier=ht,exports.ChangeEmitDirection=fe,exports.CircleEmitter=Et,exports.ColorBySpeed=Ie,exports.ColorGeneratorFromJSON=Mt,exports.ColorOverLife=Ht,exports.ColorRange=pt,exports.ConeEmitter=At,exports.ConstantColor=St,exports.ConstantValue=wt,exports.DEG2RAD=p,exports.DonutEmitter=Ut,exports.EmitSubParticleSystem=ge,exports.EmitterFromJSON=jt,exports.EmitterShapes=Wt,exports.Euler=et,exports.EulerGenerator=Pt,exports.ForceOverLife=Kt,exports.FrameOverLife=oe,exports.GeneratorFromJSON=Ft,exports.Gradient=xt,exports.GravityForce=ye,exports.GridEmitter=Qt,exports.HemisphereEmitter=Gt,exports.InheritVelocity=se,exports.IntervalValue=bt,exports.LimitSpeedOverLife=Le,exports.MathUtils=J,exports.Matrix3=rt,exports.Matrix4=Q,exports.MeshSurfaceEmitter=We,exports.MeshSurfaceEmitterPlugin=je,exports.NodeParticle=class{constructor(){this.position=new k,this.velocity=new k,this.age=0,this.life=1,this.size=new k,this.rotation=0,this.color=new st(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}},exports.Noise=Ve,exports.OrbitOverLife=ae,exports.ParticleEmitter=ui,exports.ParticleMeshPhysicsMaterial=_i,exports.ParticleMeshStandardMaterial=bi,exports.ParticleSystem=Si,exports.PiecewiseBezier=zt,exports.PiecewiseFunction=_t,exports.Plugins=Qe,exports.PointEmitter=Lt,exports.QuarksLoader=class{constructor(t,e={}){this.scene=t,this.options=e}async load(t){const e=this.options.baseUrl||t.substring(0,t.lastIndexOf("/")+1),i=await fetch(t),s=await i.json();return this.parse(s,e)}parse(t,e=""){const i={textures:{},geometries:{},materials:{}};t.geometries&&this.parseGeometries(t.geometries,i),t.images&&this.parseImages(t.images,e,i),t.textures&&this.parseTextures(t.textures,i),t.materials&&this.parseMaterials(t.materials,i);const s=this.parseObject(t.object,i);return this.linkReferences(s),s}parseGeometries(t,e){for(const i of t)if("PlaneGeometry"===i.type){const t=(i.width||1)/2,s=(i.height||1)/2;e.geometries[i.uuid]={positions:new Float32Array([-t,-s,0,t,-s,0,t,s,0,-t,s,0]),indices:new Uint32Array([0,1,2,0,2,3]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),normals:new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1])}}else if("SphereGeometry"===i.type)e.geometries[i.uuid]=this.parseSphereGeometry(i);else if("BufferGeometry"===i.type&&i.data){const t=this.parseBufferGeometry(i.data);e.geometries[i.uuid]=t}else"QuarksGeometry"===i.type&&(e.geometries[i.uuid]={positions:new Float32Array(i.positions??[]),indices:i.indices?new Uint32Array(i.indices):new Uint32Array(0),uvs:i.uvs?new Float32Array(i.uvs):void 0,normals:i.normals?new Float32Array(i.normals):void 0})}parseSphereGeometry(t){const e=t.radius??.5,i=Math.max(3,Math.floor(t.widthSegments??16)),s=Math.max(2,Math.floor(t.heightSegments??8)),r=t.phiStart??0,n=t.phiLength??2*Math.PI,o=t.thetaStart??0,a=t.thetaLength??Math.PI,h=[],l=[],c=[],u=[],d=[];let m=0;for(let t=0;t<=s;t++){const u=[],p=t/s,y=o+p*a;for(let t=0;t<=i;t++){const s=t/i,o=r+s*n,a=-e*Math.cos(o)*Math.sin(y),d=e*Math.cos(y),f=e*Math.sin(o)*Math.sin(y);h.push(a,d,f);const x=Math.hypot(a,d,f)||1;l.push(a/x,d/x,f/x),c.push(s,1-p),u.push(m++)}d.push(u)}const p=o<=0,y=o+a>=Math.PI;for(let t=0;t<s;t++)for(let e=0;e<i;e++){const i=d[t][e+1],r=d[t][e],n=d[t+1][e],o=d[t+1][e+1];0===t&&p||u.push(i,r,o),t===s-1&&y||u.push(r,n,o)}const f=h.length/3>65535?new Uint32Array(u):new Uint16Array(u);return{positions:new Float32Array(h),indices:f,uvs:new Float32Array(c),normals:new Float32Array(l)}}parseBufferGeometry(t){let e,i,s=new Float32Array(0),r=new Uint32Array(0);if(t.interleavedBuffers&&t.arrayBuffers){const r={};for(const[e,i]of Object.entries(t.interleavedBuffers)){const s=t.arrayBuffers[i.buffer];if(s){const t=new Float32Array(Array.isArray(s)?this.int32ArrayToFloat32(s):s);r[e]={data:t,stride:i.stride}}}if(t.attributes){if(t.attributes.position?.isInterleavedBufferAttribute){const e=t.attributes.position,i=r[e.data];i&&(s=this.extractInterleavedAttribute(i.data,i.stride,e.offset,e.itemSize))}if(t.attributes.uv?.isInterleavedBufferAttribute){const i=t.attributes.uv,s=r[i.data];s&&(e=this.extractInterleavedAttribute(s.data,s.stride,i.offset,i.itemSize))}if(t.attributes.normal?.isInterleavedBufferAttribute){const e=t.attributes.normal,s=r[e.data];s&&(i=this.extractInterleavedAttribute(s.data,s.stride,e.offset,e.itemSize))}}}else t.attributes&&(t.attributes.position?.array&&(s=new Float32Array(t.attributes.position.array)),t.attributes.uv?.array&&(e=new Float32Array(t.attributes.uv.array)),t.attributes.normal?.array&&(i=new Float32Array(t.attributes.normal.array)));return t.index&&(r="Uint16Array"===t.index.type?new Uint16Array(t.index.array):new Uint32Array(t.index.array)),r=di(s,r),{positions:s,indices:r,uvs:e,normals:i}}extractInterleavedAttribute(t,e,i,s){const r=Math.floor(t.length/e),n=new Float32Array(r*s);for(let o=0;o<r;o++)for(let r=0;r<s;r++)n[o*s+r]=t[o*e+i+r];return n}int32ArrayToFloat32(t){const e=new ArrayBuffer(4*t.length),i=new Int32Array(e);for(let e=0;e<t.length;e++)i[e]=t[e];return new Float32Array(e)}parseImages(t,e,i){this._images={};for(const i of t)this._images[i.uuid]=i.url?e+i.url:null}parseTextures(t,e){const i=this._images||{};for(const s of t){const t=i[s.image];if(t){const i=new l.Texture(t,this.scene);Array.isArray(s.wrap)&&(i.wrapU=this.mapWrapMode(s.wrap[0]),i.wrapV=this.mapWrapMode(s.wrap[1]??s.wrap[0])),Array.isArray(s.repeat)&&(i.uScale=s.repeat[0]??1,i.vScale=s.repeat[1]??1),Array.isArray(s.offset)&&(i.uOffset=s.offset[0]??0,i.vOffset=s.offset[1]??0),"number"==typeof s.rotation&&(i.wAng=s.rotation),e.textures[s.uuid]=i}else e.textures[s.uuid]=null}}mapWrapMode(t){switch(t){case 1001:return l.Texture.CLAMP_ADDRESSMODE;case 1002:return l.Texture.MIRROR_ADDRESSMODE;default:return l.Texture.WRAP_ADDRESSMODE}}parseMaterials(t,e){for(const i of t){const t={uuid:i.uuid,transparent:i.transparent??!0,blending:i.blending??1,side:i.side??2,depthTest:i.depthTest??!0,depthWrite:i.depthWrite??!1,alphaTest:i.alphaTest??0,texture:null},s=i.map??i.texture;if(s&&(t.texture=e.textures[s]||null),"number"==typeof i.alphaMode)t.alphaMode=i.alphaMode;else{const e={1:o.Constants.ALPHA_COMBINE,2:o.Constants.ALPHA_ADD,3:o.Constants.ALPHA_SUBTRACT,4:o.Constants.ALPHA_MULTIPLY};t.alphaMode=e[i.blending]||o.Constants.ALPHA_COMBINE}e.materials[i.uuid]=t}}getGeometry(t,e){if(e)return t.geometries[e]}getMaterial(t,e){if(!e)return;const i=Array.isArray(e)?e[0]:e;return t.materials[i]}createPlaceholderNode(t,i){const s=new e.TransformNode(i||t||"node",this.scene);return s.quarksOriginalType=t,s}createMeshNode(t,e){const s=new i.Mesh(t.name||t.type||"mesh",this.scene),n=this.getGeometry(e,t.geometry);if(n&&n.positions.length>0&&n.indices.length>0){const t=new r.VertexData;t.positions=n.positions,t.indices=n.indices,n.uvs&&n.uvs.length>0&&(t.uvs=n.uvs),n.normals&&n.normals.length>0&&(t.normals=n.normals),t.applyToMesh(s,!0)}const a=this.getMaterial(e,t.material);if(a){const t=new c.StandardMaterial(`quarks_loader_material_${a.uuid}`,this.scene);t.alphaMode=a.alphaMode??o.Constants.ALPHA_COMBINE,t.backFaceCulling=2!==a.side,t.alphaCutOff=a.alphaTest??0,t.disableDepthWrite=!a.depthWrite,a.texture&&(t.diffuseTexture=a.texture,t.opacityTexture=a.texture),s.material=t}return s}parseObject(t,i){let s;switch(t.type){case"QuarksPrefab":s=wi.fromJSON(t,this.scene);break;case"ParticleEmitter":if(t.ps){s=this.parseParticleSystem(t.ps,i).emitter;break}s=this.createPlaceholderNode(t.type,t.name);break;case"Mesh":case"SkinnedMesh":case"InstancedMesh":case"BatchedMesh":s=this.createMeshNode(t,i);break;case"Scene":case"Group":case"Object3D":case"PerspectiveCamera":case"OrthographicCamera":case"AmbientLight":case"DirectionalLight":case"PointLight":case"RectAreaLight":case"SpotLight":case"HemisphereLight":case"LightProbe":case"LOD":case"Line":case"LineSegments":case"LineLoop":case"PointCloud":case"Points":case"Sprite":case"Bone":s=this.createPlaceholderNode(t.type,t.name);break;default:s=new e.TransformNode(t.name||t.type||"node",this.scene)}if(t.uuid&&(s._quarksUUID=t.uuid),t.name&&(s.name=t.name),t.matrix){const e=a.Matrix.FromArray(t.matrix),i=new a.Vector3(1,1,1),r=a.Quaternion.Identity(),n=new a.Vector3(0,0,0);e.decompose(i,r,n),s.position.copyFrom(n),s.scaling.copyFrom(i),s.rotationQuaternion=r}else t.position&&s.position.set(t.position[0],t.position[1],t.position[2]),t.scale&&s.scaling.set(t.scale[0],t.scale[1],t.scale[2]),t.quaternion?s.rotationQuaternion=new a.Quaternion(t.quaternion[0],t.quaternion[1],t.quaternion[2],t.quaternion[3]):t.rotation&&s.rotation.set(t.rotation[0],t.rotation[1],t.rotation[2]);if(void 0!==t.visible&&s.setEnabled(t.visible),t.children)for(const e of t.children){this.parseObject(e,i).parent=s}return s}parseParticleSystem(t,e){const i=Si.fromJSON(t,e,{},this.scene);return i._meshSurfaceReferenceUUID="mesh_surface"===t?.shape?.type?t?.shape?.mesh:void 0,i}linkReferences(t){const s={},r=t=>{t._quarksUUID&&(s[t._quarksUUID]=t);for(const i of t.getChildren())i instanceof e.TransformNode&&r(i)};r(t);const n=r=>{if(r instanceof wi&&r.resolveReferences(t),r instanceof ui){const t=r.system,e=t._meshSurfaceReferenceUUID;if(e&&"mesh_surface"===t.emitterShape.type){const r=s[e];r instanceof i.Mesh&&(t.emitterShape.mesh=r)}for(let e=0;e<t.behaviors.length;e++)if(t.behaviors[e]instanceof ge){const i=t.behaviors[e],r=i.subParticleSystem;if("string"==typeof r&&s[r]){const t=s[r];i.subParticleSystem=t,t instanceof ui&&(t.system.onlyUsedByOther=!0)}}}for(const t of r.getChildren())t instanceof e.TransformNode&&n(t)};n(t)}},exports.QuarksPrefab=wi,exports.QuarksUtil=Mi,exports.Quaternion=I,exports.RAD2DEG=y,exports.RandomColor=mt,exports.RandomColorBetweenGradient=vt,exports.RandomQuatGenerator=Ot,exports.RecordState=ue,exports.RectangleEmitter=Xt,exports.Rotation3DOverLife=Zt,exports.RotationBySpeed=Ue,exports.RotationGeneratorFromJSON=Nt,exports.RotationOverLife=Yt,exports.SequencerFromJSON=Ae,exports.SizeBySpeed=ke,exports.SizeOverLife=re,exports.SpeedOverLife=ne,exports.SphereEmitter=qt,exports.SpriteBatch=ai,exports.SpriteParticle=ce,exports.TextureSequencer=Fe,exports.TrailBatch=hi,exports.TrailParticle=de,exports.TurbulenceField=Be,exports.VFXBatch=oi,exports.ValueGeneratorFromJSON=Tt,exports.Vector2=it,exports.Vector3=k,exports.Vector3Function=Ct,exports.Vector3GeneratorFromJSON=Vt,exports.Vector4=st,exports.VelocityOverLife=ie,exports.WebGLCoordinateSystem=q,exports.WebGPUCoordinateSystem=G,exports.WidthOverLength=me,exports.ceilPowerOfTwo=F,exports.clamp=x,exports.damp=w,exports.degToRad=N,exports.denormalize=D,exports.euclideanModulo=g,exports.floorPowerOfTwo=A,exports.generateUUID=f,exports.getPhysicsResolver=Re,exports.getRegisteredShaderChunks=function(){return He},exports.getShaderChunk=function(t){return He[t]},exports.getValueFromEmitterMode=at,exports.inverseLerp=S,exports.isPowerOfTwo=V,exports.lerp=M,exports.loadPlugin=Xe,exports.localParticlePhysicsVertShader=ei,exports.localParticleVertShader="\n// Per-vertex attributes\nattribute vec3 position;\nattribute vec2 uv;\n\n// Per-instance attributes\nattribute vec3 offset;\nattribute vec4 color;\nattribute vec3 size;\nattribute vec4 rotation;\nattribute float uvTile;\n\n// Uniforms\nuniform mat4 worldViewProjection;\n\n#ifdef UV_TILE\nuniform float tileCountX;\nuniform float tileCountY;\n#endif\n\n// Varyings\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 qVec = q.xyz;\n float qW = q.w;\n vec3 t = 2.0 * cross(qVec, v);\n return v + qW * t + cross(qVec, t);\n}\n\nvoid main() {\n vec3 rotatedPosition = applyQuaternion(position * size, rotation);\n vec3 worldPos = rotatedPosition + offset;\n\n gl_Position = worldViewProjection * vec4(worldPos, 1.0);\n\n #ifdef UV_TILE\n vec2 tc = vec2(tileCountX, tileCountY);\n float baseTile = floor(uvTile);\n float tileU = mod(baseTile, tc.x) / tc.x;\n float tileV = 1.0 - floor(baseTile / tc.x) / tc.y - 1.0 / tc.y;\n vUV = uv / tc + vec2(tileU, tileV);\n #else\n vUV = uv;\n #endif\n\n vColor = color;\n}\n",exports.mapLinear=v,exports.normalize=R,exports.particleFragShader=ti,exports.particlePhysicsFragShader=ii,exports.particleVertShader=$e,exports.pingpong=b,exports.radToDeg=C,exports.randFloat=O,exports.randFloatSpread=B,exports.randInt=T,exports.registerShaderChunks=Ze,exports.seededRandom=P,exports.setPhysicsResolver=function(t){De=t},exports.setQuaternionFromProperEuler=E,exports.smootherstep=z,exports.smoothstep=_,exports.stretchedBillboardVertShader=si,exports.trailFragShader=ni,exports.trailVertShader=ri,exports.unloadPlugin=function(t){const e=Qe.find(e=>e.id===t);if(e){for(const t of e.emitterShapes)Wt[t.type]&&delete Wt[t.type];for(const t of e.behaviors)qe[t.type]&&delete qe[t.type]}};
2
2
  //# sourceMappingURL=babylon.quarks.cjs.map