@newkrok/three-particles 2.15.0 → 2.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +36 -1
- package/dist/index.js.map +1 -1
- package/dist/three-particles.min.js +1 -1
- package/dist/three-particles.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"three";import{Gyroscope as t}from"three/examples/jsm/misc/Gyroscope.js";var n,r,i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,d=(n={"node_modules/easing-functions/index.js"(e,t){var n=e=>e,r={In:e=>e*e,Out:e=>e*(2-e),InOut(e){let t=2*e;return t<1?.5*t*t:(t-=1,-.5*(t*(t-2)-1))}},i={In:e=>e*e*e,Out:e=>--e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t:(t-=2,.5*(t*t*t+2))}},a={In:e=>e*e*e*e,Out:e=>1- --e*e*e*e,InOut(e){let t=2*e;return t<1?.5*t*t*t*t:(t-=2,-.5*(t*t*t*t-2))}},o={In:e=>e*e*e*e*e,Out:e=>--e*e*e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t*t*t:(t-=2,.5*(t*t*t*t*t+2))}},s={In:e=>1-Math.cos(e*Math.PI/2),Out:e=>Math.sin(e*Math.PI/2),InOut:e=>.5*(1-Math.cos(Math.PI*e))},l={In:e=>0===e?0:1024**(e-1),Out:e=>1===e?1:1-2**(-10*e),InOut(e){if(0===e)return 0;if(1===e)return 1;const t=2*e;return t<1?.5*1024**(t-1):.5*(2-2**(-10*(t-1)))}},c={In:e=>1-Math.sqrt(1-e*e),Out:e=>Math.sqrt(1- --e*e),InOut(e){let t=2*e;return t<1?-.5*(Math.sqrt(1-t*t)-1):(t-=2,.5*(Math.sqrt(1-t*t)+1))}},d={In(e){let t,n=.1;return 0===e?0:1===e?1:(n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),-n*2**(10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},Out(e){let t,n=.1;return 0===e?0:1===e?1:(n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),n*2**(-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},InOut(e){let t=.1;const n=.4;let r;if(0===e)return 0;if(1===e)return 1;t<1?(t=1,r=.1):r=n*Math.asin(1/t)/(2*Math.PI);const i=2*e;if(i<1){const e=i-1;return t*2**(10*e)*Math.sin((e-r)*(2*Math.PI)/n)*-.5}const a=i-1;return t*2**(-10*a)*Math.sin((a-r)*(2*Math.PI)/n)*.5+1}},f={In(e){const t=1.70158;return e*e*((t+1)*e-t)},Out(e){const t=1.70158;return--e*e*((t+1)*e+t)+1},InOut(e){const t=2.5949095;let n=2*e;return n<1?n*n*((t+1)*n-t)*.5:(n-=2,.5*(n*n*((t+1)*n+t)+2))}},m={In:e=>1-m.Out(1-e),Out(e){if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const t=e-1.5/2.75;return 7.5625*t*t+.75}if(e<2.5/2.75){const t=e-2.25/2.75;return 7.5625*t*t+.9375}const t=e-2.625/2.75;return 7.5625*t*t+.984375},InOut:e=>e<.5?.5*m.In(2*e):.5*m.Out(2*e-1)+.5},p={Quadratic:r,Cubic:i,Quartic:a,Quintic:o,Sinusoidal:s,Exponential:l,Circular:c,Elastic:d,Back:f,Bounce:m},u=(e,t,n)=>Object.defineProperty(e,t,{value:n});for(const e of Object.keys(p)){const t=p[e],n=e.toLowerCase();u(p,n,t);for(const r of Object.keys(t)){const i=t[r],a=r.toLowerCase();u(p,`${e}.${r}`,i),u(p,`${n}.${a}`,i),u(t,a,i)}}p.Linear=n,u(p,"linear",n),t.exports=p,"undefined"!=typeof window&&(window.Easing=p)}},function(){return r||(0,n[s(n)[0]])((r={exports:{}}).exports,r),r.exports}),f=[],m=(e,t)=>{let n=1;for(let r=1;r<=t;r++)n*=(e+1-r)/r;return n},p=(e,t)=>{const n=f.find(e=>e.bezierPoints===t);if(n)return n.referencedBy.includes(e)||n.referencedBy.push(e),n.curveFunction;const r={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let n=0,r=t.length-1;t.find((t,i)=>{const a=e<(t.percentage??0);return a?r=i:void 0!==t.percentage&&(n=i),a});const i=r-n,a=(e-(t[n].percentage??0))/((t[r].percentage??1)-(t[n].percentage??0));let o=0;for(let e=0;e<=i;e++){const r=t[n+e];o+=m(i,e)*Math.pow(1-a,i-e)*Math.pow(a,e)*r.y}return o}};return f.push(r),r.curveFunction},u=e=>{for(;;){const t=f.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const n=f[t];n.referencedBy=n.referencedBy.filter(t=>t!==e),0===n.referencedBy.length&&f.splice(t,1)}},y=()=>f.length,v=((e,t,n)=>(n=null!=e?i(l(e)):{},((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of s(t))c.call(e,i)||i===n||a(e,i,{get:()=>t[i],enumerable:!(r=o(t,i))||r.enumerable});return e})(a(n,"default",{value:e,enumerable:!0}),e)))(d()),g=(e=>(e.BEZIER="BEZIER",e.LINEAR="LINEAR",e.QUADRATIC_IN="QUADRATIC_IN",e.QUADRATIC_OUT="QUADRATIC_OUT",e.QUADRATIC_IN_OUT="QUADRATIC_IN_OUT",e.CUBIC_IN="CUBIC_IN",e.CUBIC_OUT="CUBIC_OUT",e.CUBIC_IN_OUT="CUBIC_IN_OUT",e.QUARTIC_IN="QUARTIC_IN",e.QUARTIC_OUT="QUARTIC_OUT",e.QUARTIC_IN_OUT="QUARTIC_IN_OUT",e.QUINTIC_IN="QUINTIC_IN",e.QUINTIC_OUT="QUINTIC_OUT",e.QUINTIC_IN_OUT="QUINTIC_IN_OUT",e.SINUSOIDAL_IN="SINUSOIDAL_IN",e.SINUSOIDAL_OUT="SINUSOIDAL_OUT",e.SINUSOIDAL_IN_OUT="SINUSOIDAL_IN_OUT",e.EXPONENTIAL_IN="EXPONENTIAL_IN",e.EXPONENTIAL_OUT="EXPONENTIAL_OUT",e.EXPONENTIAL_IN_OUT="EXPONENTIAL_IN_OUT",e.CIRCULAR_IN="CIRCULAR_IN",e.CIRCULAR_OUT="CIRCULAR_OUT",e.CIRCULAR_IN_OUT="CIRCULAR_IN_OUT",e.ELASTIC_IN="ELASTIC_IN",e.ELASTIC_OUT="ELASTIC_OUT",e.ELASTIC_IN_OUT="ELASTIC_IN_OUT",e.BACK_IN="BACK_IN",e.BACK_OUT="BACK_OUT",e.BACK_IN_OUT="BACK_IN_OUT",e.BOUNCE_IN="BOUNCE_IN",e.BOUNCE_OUT="BOUNCE_OUT",e.BOUNCE_IN_OUT="BOUNCE_IN_OUT",e))(g||{}),h={LINEAR:v.default.Linear.None,QUADRATIC_IN:v.default.Quadratic.In,QUADRATIC_OUT:v.default.Quadratic.Out,QUADRATIC_IN_OUT:v.default.Quadratic.InOut,CUBIC_IN:v.default.Cubic.In,CUBIC_OUT:v.default.Cubic.Out,CUBIC_IN_OUT:v.default.Cubic.InOut,QUARTIC_IN:v.default.Quartic.In,QUARTIC_OUT:v.default.Quartic.Out,QUARTIC_IN_OUT:v.default.Quartic.InOut,QUINTIC_IN:v.default.Quintic.In,QUINTIC_OUT:v.default.Quintic.Out,QUINTIC_IN_OUT:v.default.Quintic.InOut,SINUSOIDAL_IN:v.default.Sinusoidal.In,SINUSOIDAL_OUT:v.default.Sinusoidal.Out,SINUSOIDAL_IN_OUT:v.default.Sinusoidal.InOut,EXPONENTIAL_IN:v.default.Exponential.In,EXPONENTIAL_OUT:v.default.Exponential.Out,EXPONENTIAL_IN_OUT:v.default.Exponential.InOut,CIRCULAR_IN:v.default.Circular.In,CIRCULAR_OUT:v.default.Circular.Out,CIRCULAR_IN_OUT:v.default.Circular.InOut,ELASTIC_IN:v.default.Elastic.In,ELASTIC_OUT:v.default.Elastic.Out,ELASTIC_IN_OUT:v.default.Elastic.InOut,BACK_IN:v.default.Back.In,BACK_OUT:v.default.Back.Out,BACK_IN_OUT:v.default.Back.InOut,BOUNCE_IN:v.default.Bounce.In,BOUNCE_OUT:v.default.Bounce.Out,BOUNCE_IN_OUT:v.default.Bounce.InOut},x=e=>"function"==typeof e?e:h[e],I=(e=>(e.LOCAL="LOCAL",e.WORLD="WORLD",e))(I||{}),b=(e=>(e.SPHERE="SPHERE",e.CONE="CONE",e.BOX="BOX",e.CIRCLE="CIRCLE",e.RECTANGLE="RECTANGLE",e))(b||{}),C=(e=>(e.VOLUME="VOLUME",e.SHELL="SHELL",e.EDGE="EDGE",e))(C||{}),A=(e=>(e.LIFETIME="LIFETIME",e.FPS="FPS",e))(A||{}),P=(e=>(e.BEZIER="BEZIER",e.EASING="EASING",e))(P||{}),w=(e=>(e.BIRTH="BIRTH",e.DEATH="DEATH",e))(w||{}),T=(e=>(e.POINT="POINT",e.DIRECTIONAL="DIRECTIONAL",e))(T||{}),O=(e=>(e.POINTS="POINTS",e.INSTANCED="INSTANCED",e.TRAIL="TRAIL",e.MESH="MESH",e))(O||{}),S=(e=>(e.NONE="NONE",e.LINEAR="LINEAR",e.QUADRATIC="QUADRATIC",e))(S||{}),_=(e,t,n,r,{radius:i,radiusThickness:a,arc:o})=>{const s=Math.random()*(o/360),l=Math.random(),c=Math.random(),d=2*Math.PI*s,f=Math.acos(2*l-1),m=Math.sin(f),p=m*Math.cos(d),u=m*Math.sin(d),y=Math.cos(f),v=1-a;e.x=i*v*p+i*a*c*p,e.y=i*v*u+i*a*c*u,e.z=i*v*y+i*a*c*y,e.applyQuaternion(t);const g=1/e.length();n.set(e.x*g*r,e.y*g*r,e.z*g*r),n.applyQuaternion(t)},U=(t,n,r,i,{radius:a,radiusThickness:o,arc:s,angle:l=90})=>{const c=2*Math.PI*Math.random()*(s/360),d=Math.random(),f=Math.cos(c),m=Math.sin(c),p=1-o;t.x=a*p*f+a*o*d*f,t.y=a*p*m+a*o*d*m,t.z=0,t.applyQuaternion(n);const u=t.length(),y=Math.abs(u/a*e.MathUtils.degToRad(l)),v=Math.sin(y),g=1/u;r.set(t.x*v*g*i,t.y*v*g*i,Math.cos(y)*i),r.applyQuaternion(n)},L=(e,t,n,r,{scale:i,emitFrom:a})=>{const o=i;switch(a){case"VOLUME":e.x=Math.random()*o.x-o.x/2,e.y=Math.random()*o.y-o.y/2,e.z=Math.random()*o.z-o.z/2;break;case"SHELL":const t=Math.floor(6*Math.random()),n=t%3,r=[];r[n]=t>2?1:0,r[(n+1)%3]=Math.random(),r[(n+2)%3]=Math.random(),e.x=r[0]*o.x-o.x/2,e.y=r[1]*o.y-o.y/2,e.z=r[2]*o.z-o.z/2;break;case"EDGE":const i=Math.floor(6*Math.random()),a=i%3,s=Math.floor(4*Math.random()),l=[];l[a]=i>2?1:0,l[(a+1)%3]=s<2?Math.random():s-2,l[(a+2)%3]=s<2?s:Math.random(),e.x=l[0]*o.x-o.x/2,e.y=l[1]*o.y-o.y/2,e.z=l[2]*o.z-o.z/2}e.applyQuaternion(t),n.set(0,0,r),n.applyQuaternion(t)},E=(e,t,n,r,{radius:i,radiusThickness:a,arc:o})=>{const s=2*Math.PI*Math.random()*(o/360),l=Math.random(),c=Math.cos(s),d=Math.sin(s),f=1-a;e.x=i*f*c+i*a*l*c,e.y=i*f*d+i*a*l*d,e.z=0,e.applyQuaternion(t);const m=1/e.length();n.set(e.x*m*r,e.y*m*r,0),n.applyQuaternion(t)},z=(t,n,r,i,{rotation:a,scale:o})=>{const s=o,l=a,c=Math.random()*s.x-s.x/2,d=Math.random()*s.y-s.y/2,f=e.MathUtils.degToRad(l.x),m=e.MathUtils.degToRad(l.y);t.x=c*Math.cos(m),t.y=d*Math.cos(f),t.z=c*Math.sin(m)-d*Math.sin(f),t.applyQuaternion(n),r.set(0,0,i),r.applyQuaternion(n)},M=()=>{try{const t=document.createElement("canvas");t.width=1,t.height=1;const n=t.getContext("2d");if(n){n.fillStyle="white",n.fillRect(0,0,1,1);const r=new e.CanvasTexture(t);return r.needsUpdate=!0,r}return null}catch{return null}},N=()=>{try{const t=document.createElement("canvas"),n=64;t.width=n,t.height=n;const r=t.getContext("2d");if(r){const i=n/2,a=n/2,o=n/2-2;r.beginPath(),r.arc(i,a,o,0,2*Math.PI,!1),r.fillStyle="white",r.fill();const s=new e.CanvasTexture(t);return s.needsUpdate=!0,s}return null}catch(e){return null}},F=e=>"number"!=typeof e&&"type"in e,D=(e,t)=>{if("BEZIER"===t.type)return p(e,t.bezierPoints);if("EASING"===t.type)return t.curveFunction;throw new Error(`Unsupported value type: ${t}`)},V=(t,n,r=0)=>{if("number"==typeof n)return n;if("min"in n&&"max"in n)return n.min===n.max?n.min??0:e.MathUtils.randFloat(n.min??0,n.max??1);const i=n;return D(t,i)(r)*(i.scale??1)},R=new e.Vector3(0,0,0),B=new e.Euler,k=({delta:e,generalData:t,normalizedConfig:n,attributes:r,particleLifetimePercentage:i,particleIndex:a})=>{const{particleSystemId:o,startValues:s,lifetimeValues:l,linearVelocityData:c,orbitalVelocityData:d,noise:f}=t,m=3*a,p=r.position.array;if(c){const{speed:t,valueModifiers:n}=c[a],o=n.x?n.x(i):t.x,s=n.y?n.y(i):t.y,l=n.z?n.z(i):t.z;p[m]+=o*e,p[m+1]+=s*e,p[m+2]+=l*e,r.position.needsUpdate=!0}if(d){const{speed:t,positionOffset:n,valueModifiers:o}=d[a];p[m]-=n.x,p[m+1]-=n.y,p[m+2]-=n.z;const s=o.x?o.x(i):t.x,l=o.y?o.y(i):t.y,c=o.z?o.z(i):t.z;B.set(s*e,c*e,l*e),n.applyEuler(B),p[m]+=n.x,p[m+1]+=n.y,p[m+2]+=n.z,r.position.needsUpdate=!0}if(n.sizeOverLifetime.isActive){const e=V(o,n.sizeOverLifetime.lifetimeCurve,i);r.size.array[a]=s.startSize[a]*e,r.size.needsUpdate=!0}if(n.opacityOverLifetime.isActive){const e=V(o,n.opacityOverLifetime.lifetimeCurve,i);r.colorA.array[a]=s.startOpacity[a]*e,r.colorA.needsUpdate=!0}if(n.colorOverLifetime.isActive){const e=V(o,n.colorOverLifetime.r,i),t=V(o,n.colorOverLifetime.g,i),l=V(o,n.colorOverLifetime.b,i);r.colorR.array[a]=s.startColorR[a]*e,r.colorG.array[a]=s.startColorG[a]*t,r.colorB.array[a]=s.startColorB[a]*l,r.colorR.needsUpdate=!0,r.colorG.needsUpdate=!0,r.colorB.needsUpdate=!0}if(l.rotationOverLifetime&&(r.rotation.array[a]+=l.rotationOverLifetime[a]*e*.02,r.rotation.needsUpdate=!0),f.isActive){const{sampler:e,strength:t,noisePower:n,offsets:o,positionAmount:s,rotationAmount:l,sizeAmount:c}=f;let d;const u=10*(i+(o?o[a]:0))*t;R.set(u,0,0),d=e.get3(R),p[m]+=d*n*s,0!==l&&(r.rotation.array[a]+=d*n*l,r.rotation.needsUpdate=!0),0!==c&&(r.size.array[a]+=d*n*c,r.size.needsUpdate=!0),R.set(u,u,0),d=e.get3(R),p[m+1]+=d*n*s,R.set(u,u,u),d=e.get3(R),p[m+2]+=d*n*s,r.position.needsUpdate=!0}if(r.quat){const e=.5*r.rotation.array[a],t=4*a;r.quat.array[t]=0,r.quat.array[t+1]=0,r.quat.array[t+2]=Math.sin(e),r.quat.array[t+3]=Math.cos(e),r.quat.needsUpdate=!0}},Q={};((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})})(Q,{deepMerge:()=>j,getObjectDiff:()=>q,patchObject:()=>H});var H=(e,t,n={skippedProperties:[],applyToFirstObject:!1})=>{const r={};return Object.keys(e).forEach(i=>{n.skippedProperties&&n.skippedProperties.includes(i)||("object"==typeof e[i]&&e[i]&&t[i]&&!Array.isArray(e[i])?r[i]=H(e[i],t[i],n):(r[i]=0===t[i]?0:!1!==t[i]&&(t[i]||e[i]),n.applyToFirstObject&&(e[i]=r[i])))}),r},j=(e,t,n={skippedProperties:[],applyToFirstObject:!1})=>{const r={};return Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})])).forEach(i=>{n.skippedProperties&&n.skippedProperties.includes(i)||("object"==typeof e?.[i]&&e?.[i]&&t?.[i]&&!Array.isArray(e[i])?r[i]=j(e[i],t[i],n):(r[i]=0===t?.[i]?0:!1!==t?.[i]&&(t?.[i]||e?.[i]),n.applyToFirstObject&&(e[i]=r[i])))}),r},q=(e,t,n={skippedProperties:[]})=>{const r={};return Object.keys(e).forEach(i=>{if(!n.skippedProperties||!n.skippedProperties.includes(i))if("object"==typeof e[i]&&e[i]&&t[i]&&!Array.isArray(e[i])){const a=q(e[i],t[i],n);Object.keys(a).length>0&&(r[i]=a)}else{const n=0===t[i]?0:t[i]||e[i];n!==e[i]&&(r[i]=n)}}),r},G=function(){};G.prototype.load=G,G.prototype.parse=G;var W=G;Array.from({length:3},()=>({loader:new W,isUsed:!1})),Array.from({length:3},()=>({loader:new e.TextureLoader,isUsed:!1})),Array.from({length:3},()=>({loader:new e.AudioLoader,isUsed:!1}));var Z=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],X=class{constructor(t){const n=[new e.Vector3(1,1,0),new e.Vector3(-1,1,0),new e.Vector3(1,-1,0),new e.Vector3(-1,-1,0),new e.Vector3(1,0,1),new e.Vector3(-1,0,1),new e.Vector3(1,0,-1),new e.Vector3(-1,0,-1),new e.Vector3(0,1,1),new e.Vector3(0,-1,1),new e.Vector3(0,1,-1),new e.Vector3(0,-1,-1)];var r=new Array(512),i=new Array(512);t||(t=1),t*=65536,(t=Math.floor(t))<256&&(t|=t<<8);for(var a=0;a<256;a++){var o;o=1&a?Z[a]^255&t:Z[a]^t>>8&255,r[a]=r[a+256]=o,i[a]=i[a+256]=n[o%12]}this._seed=t,this._offsetMatrix=[new e.Vector3(0,0,0),new e.Vector3(0,0,1),new e.Vector3(0,1,0),new e.Vector3(0,1,1),new e.Vector3(1,0,0),new e.Vector3(1,0,1),new e.Vector3(1,1,0),new e.Vector3(1,1,1)],this.shaderChunk={defines:"",header:'#define GLSLIFY 1\n// From https://github.com/hughsk/glsl-noise/blob/master/periodic/2d.glsl\n\n//\n// GLSL textureless classic 2D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\n\nvec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }\n\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nvec2 fade(vec2 t) { return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); }\n\nfloat map(float value, float min1, float max1, float min2, float max2) {\n return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin(vec2 P) {\n\n vec2 rep = vec2(255.0, 255.0);\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n vec4 gy = abs(gx) - 0.5;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x, gy.x);\n vec2 g10 = vec2(gx.y, gy.y);\n vec2 g01 = vec2(gx.z, gy.z);\n vec2 g11 = vec2(gx.w, gy.w);\n\n vec4 norm = taylorInvSqrt(\n vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return map(2.3 * n_xy, -1.0, 1.0, 0.0, 1.0);\n}\n\nfloat fbm(vec2 pos, vec4 props) {\n float persistance = props.x;\n float lacunarity = props.y;\n float redistribution = props.z;\n int octaves = int(props.w);\n\n float result = 0.0;\n float amplitude = 1.0;\n float frequency = 1.0;\n float maximum = amplitude;\n\n for (int i = 0; i < 2; i++) {\n\n vec2 p = pos.xy * frequency;\n\n float noiseVal = perlin(p);\n result += noiseVal * amplitude;\n\n frequency *= lacunarity;\n amplitude *= persistance;\n maximum += amplitude;\n }\n\n float redistributed = pow(result, redistribution);\n return redistributed / maximum;\n}\n',main:"",uniforms:[{three_noise_seed:this._seed}]},this.perm=r,this.gradP=i}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,n){return(1-n)*e+n*t}_gradient(t){return t instanceof e.Vector3?t.x+this.perm[t.y+this.perm[t.z]]:t.x+this.perm[t.y]}static map(e,t,n,r,i){return(e-t)*(i-r)/(n-t)+r}get2(t){void 0!==t.z&&(t=new e.Vector2(t.x,t.y));const n=new e.Vector2(Math.floor(t.x),Math.floor(t.y));t.sub(n),n.x&=255,n.y&=255;const r=[];for(let i=0;i<4;i++){const a=this._offsetMatrix[2*i],o=new e.Vector2(a.x,a.y),s=this.gradP[this._gradient((new e.Vector2).addVectors(n,o))],l=new e.Vector2(s.x,s.y),c=(new e.Vector2).subVectors(t,o);r.push(l.dot(c))}const i=this._fade(t.x),a=this._fade(t.y);return this._lerp(this._lerp(r[0],r[2],i),this._lerp(r[1],r[3],i),a)}get3(t){if(void 0===t.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const n=new e.Vector3(Math.floor(t.x),Math.floor(t.y),Math.floor(t.z));t.sub(n),n.x&=255,n.y&=255,n.z&=255;const r=[];for(let i=0;i<8;i++){const a=this._offsetMatrix[i],o=this.gradP[this._gradient((new e.Vector3).addVectors(n,a))],s=(new e.Vector3).subVectors(t,a);r.push(o.dot(s))}const i=this._fade(t.x),a=this._fade(t.y),o=this._fade(t.z);return this._lerp(this._lerp(this._lerp(r[0],r[4],i),this._lerp(r[1],r[5],i),o),this._lerp(this._lerp(r[2],r[6],i),this._lerp(r[3],r[7],i),o),a)}},Y=class{constructor(e){const{seed:t,scale:n,persistance:r,lacunarity:i,octaves:a,redistribution:o}=e;this._noise=new X(t),this._scale=n||1,this._persistance=r||.5,this._lacunarity=i||2,this._octaves=a||6,this._redistribution=o||1}get2(t){let n=0,r=1,i=1,a=r,o=this._noise.get2.bind(this._noise);for(let s=0;s<this._octaves;s++){n+=o(new e.Vector2(t.x*this._scale*i,t.y*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,a+=r}return Math.pow(n,this._redistribution)/a}get3(t){let n=0,r=1,i=1,a=r,o=this._noise.get3.bind(this._noise);for(let s=0;s<this._octaves;s++){n+=o(new e.Vector3(t.x*this._scale*i,t.y*this._scale*i,t.z*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,a+=r}return Math.pow(n,this._redistribution)/a}},K=new e.Vector3,$=(e,t,n,r,i,a)=>{K.set(e.position.x-r[i],e.position.y-r[i+1],e.position.z-r[i+2]);const o=K.length();if(o<1e-4)return;if(e.range!==1/0&&o>e.range)return;K.divideScalar(o);let s=1;if(e.range!==1/0){const t=o/e.range;switch(e.falloff){case"LINEAR":s=1-t;break;case"QUADRATIC":s=1-t*t;break;case"NONE":s=1}}const l=t*s*a;n.x+=K.x*l,n.y+=K.y*l,n.z+=K.z*l},J=(e,t,n,r)=>{const i=t*r;n.x+=e.direction.x*i,n.y+=e.direction.y*i,n.z+=e.direction.z*i},ee=({particleSystemId:e,forceFields:t,velocity:n,positionArr:r,positionIndex:i,delta:a,systemLifetimePercentage:o})=>{for(let s=0;s<t.length;s++){const l=t[s];if(!l.isActive)continue;const c=V(e,l.strength,o);0!==c&&("POINT"===l.type?$(l,c,n,r,i,a):"DIRECTIONAL"===l.type&&J(l,c,n,a))}},te=(e,t)=>{if(!e)return t;const n=e;return!n.type&&Array.isArray(n.bezierPoints)?{type:"BEZIER",...n}:e},ne=0,re=[],ie=new e.Vector3,ae=new e.Vector3;new e.Vector3,new e.Vector3,new e.Vector3;var oe={x:0,y:0,z:0},se={x:0,y:0,z:0},le={delta:0,generalData:null,normalizedConfig:null,attributes:null,particleLifetimePercentage:0,particleIndex:0},ce=(t,n)=>t?new e.Vector3(t.x??0,t.y??0,t.z??0):n.clone(),de=t=>(t??[]).map(t=>({isActive:t.isActive??!0,type:t.type??"POINT",position:ce(t.position,new e.Vector3(0,0,0)),direction:ce(t.direction,new e.Vector3(0,1,0)).normalize(),strength:t.strength??1,range:Math.max(0,t.range??1/0),falloff:t.falloff??"LINEAR"})),fe={"THREE.NoBlending":e.NoBlending,"THREE.NormalBlending":e.NormalBlending,"THREE.AdditiveBlending":e.AdditiveBlending,"THREE.SubtractiveBlending":e.SubtractiveBlending,"THREE.MultiplyBlending":e.MultiplyBlending},me=()=>JSON.parse(JSON.stringify(pe)),pe={transform:{position:new e.Vector3,rotation:new e.Vector3,scale:new e.Vector3(1,1,1)},duration:5,looping:!0,startDelay:0,startLifetime:5,startSpeed:1,startSize:1,startOpacity:1,startRotation:0,startColor:{min:{r:1,g:1,b:1},max:{r:1,g:1,b:1}},gravity:0,simulationSpace:"LOCAL",maxParticles:100,emission:{rateOverTime:10,rateOverDistance:0,bursts:[]},shape:{shape:"SPHERE",sphere:{radius:1,radiusThickness:1,arc:360},cone:{angle:25,radius:1,radiusThickness:1,arc:360},circle:{radius:1,radiusThickness:1,arc:360},rectangle:{rotation:{x:0,y:0},scale:{x:1,y:1}},box:{scale:{x:1,y:1,z:1},emitFrom:"VOLUME"}},map:void 0,renderer:{blending:e.NormalBlending,discardBackgroundColor:!1,backgroundColorTolerance:1,backgroundColor:{r:1,g:1,b:1},transparent:!0,depthTest:!0,depthWrite:!1,softParticles:{enabled:!1,intensity:1}},velocityOverLifetime:{isActive:!1,linear:{x:0,y:0,z:0},orbital:{x:0,y:0,z:0}},sizeOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},colorOverLifetime:{isActive:!1,r:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]},g:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]},b:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]}},opacityOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},rotationOverLifetime:{isActive:!1,min:0,max:0},noise:{isActive:!1,useRandomOffset:!1,strength:1,frequency:.5,octaves:1,positionAmount:1,rotationAmount:0,sizeAmount:0},textureSheetAnimation:{tiles:new e.Vector2(1,1),timeMode:"LIFETIME",fps:30,startFrame:0},forceFields:[]},ue=({geometry:t,propertyName:n,maxParticles:r,factory:i,instanced:a})=>{const o=new Float32Array(r);if("function"==typeof i)for(let e=0;e<r;e++)o[e]=i(void 0,e);else o.fill(i);const s=a?new e.InstancedBufferAttribute(o,1):new e.BufferAttribute(o,1);t.setAttribute(n,s)},ye=(e,{shape:t,sphere:n,cone:r,circle:i,rectangle:a,box:o},s,l,c)=>{const d=V(e.particleSystemId,s,e.normalizedLifetimePercentage);switch(t){case"SPHERE":_(l,e.wrapperQuaternion,c,d,n);break;case"CONE":U(l,e.wrapperQuaternion,c,d,r);break;case"CIRCLE":E(l,e.wrapperQuaternion,c,d,i);break;case"RECTANGLE":z(l,e.wrapperQuaternion,c,d,a);break;case"BOX":L(l,e.wrapperQuaternion,c,d,o)}},ve=(n=pe,r)=>{const i=r||Date.now(),a={particleSystemId:ne++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new e.Vector3(-99999),currentWorldPosition:new e.Vector3(-99999),worldPositionChange:new e.Vector3,worldQuaternion:new e.Quaternion,wrapperQuaternion:new e.Quaternion,lastWorldQuaternion:new e.Quaternion(-99999),worldEuler:new e.Euler,gravityVelocity:new e.Vector3(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,noisePower:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},o=Q.deepMerge(pe,n,{applyToFirstObject:!1,skippedProperties:[]});let s=o.map||("MESH"===o.renderer.rendererType?M():N());const{transform:l,duration:c,looping:d,startDelay:f,startLifetime:m,startSpeed:p,startSize:y,startRotation:v,startColor:g,startOpacity:h,gravity:x,simulationSpace:I,maxParticles:b,emission:C,shape:A,renderer:P,noise:w,velocityOverLifetime:T,onUpdate:O,onComplete:S,textureSheetAnimation:_,subEmitters:U,forceFields:L}=o,E=de(L);"string"==typeof P?.blending&&(P.blending=fe[P.blending]);const z=Array.from({length:b},()=>new e.Vector3),R=Array.from({length:b},()=>new e.Vector3);a.creationTimes=Array.from({length:b},()=>0);const B=Array.from({length:b},(e,t)=>b-1-t);T.isActive&&(a.linearVelocityData=Array.from({length:b},()=>({speed:new e.Vector3(T.linear.x?V(a.particleSystemId,T.linear.x,0):0,T.linear.y?V(a.particleSystemId,T.linear.y,0):0,T.linear.z?V(a.particleSystemId,T.linear.z,0):0),valueModifiers:{x:F(T.linear.x||0)?D(a.particleSystemId,T.linear.x):void 0,y:F(T.linear.y||0)?D(a.particleSystemId,T.linear.y):void 0,z:F(T.linear.z||0)?D(a.particleSystemId,T.linear.z):void 0}})),a.orbitalVelocityData=Array.from({length:b},()=>({speed:new e.Vector3(T.orbital.x?V(a.particleSystemId,T.orbital.x,0):0,T.orbital.y?V(a.particleSystemId,T.orbital.y,0):0,T.orbital.z?V(a.particleSystemId,T.orbital.z,0):0),valueModifiers:{x:F(T.orbital.x||0)?D(a.particleSystemId,T.orbital.x):void 0,y:F(T.orbital.y||0)?D(a.particleSystemId,T.orbital.y):void 0,z:F(T.orbital.z||0)?D(a.particleSystemId,T.orbital.z):void 0},positionOffset:new e.Vector3})));["startSize","startOpacity"].forEach(e=>{a.startValues[e]=Array.from({length:b},()=>V(a.particleSystemId,o[e],0))}),a.startValues.startColorR=Array.from({length:b},()=>0),a.startValues.startColorG=Array.from({length:b},()=>0),a.startValues.startColorB=Array.from({length:b},()=>0);["rotationOverLifetime"].forEach(t=>{const n=o[t];n.isActive&&(a.lifetimeValues[t]=Array.from({length:b},()=>e.MathUtils.randFloat(n.min,n.max)))}),a.noise={isActive:w.isActive,strength:w.strength,noisePower:.15*w.strength,positionAmount:w.positionAmount,rotationAmount:w.rotationAmount,sizeAmount:w.sizeAmount,sampler:w.isActive?new Y({seed:Math.random(),scale:w.frequency,octaves:w.octaves}):void 0,offsets:w.useRandomOffset?Array.from({length:b},()=>100*Math.random()):void 0},C.bursts&&C.bursts.length>0&&(a.burstStates=C.bursts.map(()=>({cyclesExecuted:0,lastCycleTime:0,probabilityPassed:!1})));const H="TRAIL"===P.rendererType,j="MESH"===P.rendererType,q=!H&&!j&&"INSTANCED"===P.rendererType,G=q||j,W={type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:0,percentage:1}]},Z=H?{length:P.trail?.length??20,width:P.trail?.width??1,widthOverTrail:te(P.trail?.widthOverTrail,W),opacityOverTrail:te(P.trail?.opacityOverTrail,W),colorOverTrail:P.trail?.colorOverTrail,minVertexDistance:P.trail?.minVertexDistance??0,maxTime:P.trail?.maxTime??0,smoothing:P.trail?.smoothing??!1,smoothingSubdivisions:P.trail?.smoothingSubdivisions??3,twistPrevention:P.trail?.twistPrevention??!1,ribbonId:P.trail?.ribbonId}:void 0;if(H&&Z){const e=Z.length;a.trailLength=e,a.positionHistory=new Float32Array(b*e*3),a.positionHistoryIndex=new Uint16Array(b),a.positionHistoryCount=new Uint16Array(b),Z.minVertexDistance>0&&(a.trailLastSampledPosition=new Float32Array(3*b)),Z.maxTime>0&&(a.trailSampleTimes=new Float64Array(b*e)),Z.twistPrevention&&(a.trailPrevNormal=new Float32Array(3*b))}const X=e=>G?`instance${e.charAt(0).toUpperCase()}${e.slice(1)}`:e,K=G?"instanceOffset":"position",$=!(!P.softParticles?.enabled||!P.softParticles?.depthTexture),J={elapsed:{value:0},map:{value:s},tiles:{value:_.tiles},fps:{value:_.fps},useFPSForFrameIndex:{value:"FPS"===_.timeMode},backgroundColor:{value:P.backgroundColor},discardBackgroundColor:{value:P.discardBackgroundColor},backgroundColorTolerance:{value:P.backgroundColorTolerance},...q?{viewportHeight:{value:1}}:{},softParticlesEnabled:{value:$},softParticlesIntensity:{value:Math.max(P.softParticles?.intensity??1,.001)},sceneDepthTexture:{value:P.softParticles?.depthTexture??null},cameraNearFar:{value:new e.Vector2(.1,1e3)}},ee=new e.ShaderMaterial({uniforms:J,vertexShader:j?"\n attribute float instanceSize;\n attribute float instanceColorR;\n attribute float instanceColorG;\n attribute float instanceColorB;\n attribute float instanceColorA;\n attribute float instanceLifetime;\n attribute float instanceStartLifetime;\n attribute float instanceRotation;\n attribute float instanceStartFrame;\n attribute vec3 instanceOffset;\n attribute vec4 instanceQuat;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying vec3 vNormal;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n vec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 t = 2.0 * cross(q.xyz, v);\n return v + q.w * t + cross(q.xyz, t);\n }\n\n void main()\n {\n vColor = vec4(instanceColorR, instanceColorG, instanceColorB, instanceColorA);\n vLifetime = instanceLifetime;\n vStartLifetime = instanceStartLifetime;\n vStartFrame = instanceStartFrame;\n vRotation = instanceRotation;\n\n // Apply quaternion rotation to the mesh vertex position\n vec3 rotatedPosition = applyQuaternion(position, instanceQuat);\n\n // Scale mesh by particle size\n vec3 scaledPosition = rotatedPosition * instanceSize;\n\n // Apply instance offset (particle world position)\n vec3 worldPos = scaledPosition + instanceOffset;\n\n vec4 mvPosition = modelViewMatrix * vec4(worldPos, 1.0);\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n // Transform normal by quaternion for lighting\n vNormal = normalize((modelViewMatrix * vec4(applyQuaternion(normal, instanceQuat), 0.0)).xyz);\n\n // Pass through UVs from the mesh geometry\n vUv = uv;\n\n #include <logdepthbuf_vertex>\n }\n":q?"\n attribute float instanceSize;\n attribute float instanceColorR;\n attribute float instanceColorG;\n attribute float instanceColorB;\n attribute float instanceColorA;\n attribute float instanceLifetime;\n attribute float instanceStartLifetime;\n attribute float instanceRotation;\n attribute float instanceStartFrame;\n attribute vec3 instanceOffset;\n\n uniform float viewportHeight;\n\n varying vec2 vUv;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vColor = vec4(instanceColorR, instanceColorG, instanceColorB, instanceColorA);\n vLifetime = instanceLifetime;\n vStartLifetime = instanceStartLifetime;\n vStartFrame = instanceStartFrame;\n vRotation = instanceRotation;\n\n vec4 mvPosition = modelViewMatrix * vec4(instanceOffset, 1.0);\n\n // Match the Points renderer pixel size: gl_PointSize = size * 100.0 / distance.\n // A view-space offset of d produces d * projectionMatrix[1][1] / w * (viewportHeight/2) pixels,\n // where w = -mvPosition.z for perspective. Solving for d so the result equals\n // the gl_PointSize pixel count:\n // d = size * 100.0 / distance\n // * (-mvPosition.z)\n // / (projectionMatrix[1][1] * viewportHeight * 0.5)\n // Since distance ≈ -mvPosition.z for view-aligned particles the two cancel out,\n // leaving a distance-independent expression. We keep them explicit so particles\n // off the viewing axis still scale correctly.\n float dist = length(mvPosition.xyz);\n float pointSizePx = instanceSize * 100.0 / dist;\n float perspectiveSize = pointSizePx * (-mvPosition.z)\n / (projectionMatrix[1][1] * viewportHeight * 0.5);\n\n // Billboard: offset quad vertices in view space (no rotation here;\n // rotation is applied to UVs in the fragment shader to keep behaviour\n // identical to the Points renderer).\n mvPosition.xy += position.xy * perspectiveSize;\n\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n // Pass UV for texture sampling (quad ranges from -0.5..0.5, map to 0..1).\n // Flip Y to match gl_PointCoord convention (Y runs top-to-bottom).\n vUv = vec2(position.x + 0.5, 0.5 - position.y);\n\n #include <logdepthbuf_vertex>\n }\n":"\n attribute float size;\n attribute float colorR;\n attribute float colorG;\n attribute float colorB;\n attribute float colorA;\n attribute float lifetime;\n attribute float startLifetime;\n attribute float rotation;\n attribute float startFrame;\n\n varying mat4 vPosition;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vColor = vec4(colorR, colorG, colorB, colorA);\n vLifetime = lifetime;\n vStartLifetime = startLifetime;\n vRotation = rotation;\n vStartFrame = startFrame;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_PointSize = size * (100.0 / length(mvPosition.xyz));\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:j?"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying vec3 vNormal;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n gl_FragColor = vColor;\n\n // Use mesh UVs directly for texture sampling\n vec2 uvPoint = vUv;\n\n // Apply texture sheet animation if tiles > 1x1\n if (tiles.x > 1.0 || tiles.y > 1.0) {\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n\n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n uvPoint = vec2(\n vUv.x / tiles.x + spriteXIndex / tiles.x,\n vUv.y / tiles.y + spriteYIndex / tiles.y\n );\n }\n\n vec4 texColor = texture2D(map, uvPoint);\n gl_FragColor = gl_FragColor * texColor;\n\n if (discardBackgroundColor && abs(length(texColor.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n // Simple directional lighting from camera direction\n float lightIntensity = 0.5 + 0.5 * max(dot(vNormal, vec3(0.0, 0.0, 1.0)), 0.0);\n gl_FragColor.rgb *= lightIntensity;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n #include <logdepthbuf_fragment>\n }\n":q?"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying vec2 vUv;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n gl_FragColor = vColor;\n\n // Rotate UV around centre (matches Points renderer behaviour)\n vec2 center = vec2(0.5);\n vec2 centeredPoint = vUv - center;\n\n mat2 rotation = mat2(\n cos(vRotation), sin(vRotation),\n -sin(vRotation), cos(vRotation)\n );\n\n centeredPoint = rotation * centeredPoint;\n vec2 centeredMiddlePoint = centeredPoint + center;\n\n // Discard pixels outside the inscribed circle\n float dist = distance(centeredMiddlePoint, center);\n if (dist > 0.5) discard;\n\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n\n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n vec2 uvPoint = vec2(\n centeredMiddlePoint.x / tiles.x + spriteXIndex / tiles.x,\n centeredMiddlePoint.y / tiles.y + spriteYIndex / tiles.y\n );\n\n vec4 rotatedTexture = texture2D(map, uvPoint);\n\n gl_FragColor = gl_FragColor * rotatedTexture;\n\n if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n #include <logdepthbuf_fragment>\n }\n":"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n gl_FragColor = vColor;\n float mid = 0.5;\n\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n \n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n vec2 frameUV = vec2(\n gl_PointCoord.x / tiles.x + spriteXIndex / tiles.x,\n gl_PointCoord.y / tiles.y + spriteYIndex / tiles.y);\n\n vec2 center = vec2(0.5, 0.5);\n vec2 centeredPoint = gl_PointCoord - center;\n\n mat2 rotation = mat2(\n cos(vRotation), sin(vRotation),\n -sin(vRotation), cos(vRotation)\n );\n\n centeredPoint = rotation * centeredPoint;\n vec2 centeredMiddlePoint = vec2(\n centeredPoint.x + center.x,\n centeredPoint.y + center.y\n );\n\n float dist = distance(centeredMiddlePoint, center);\n if (dist > 0.5) discard;\n\n vec2 uvPoint = vec2(\n centeredMiddlePoint.x / tiles.x + spriteXIndex / tiles.x,\n centeredMiddlePoint.y / tiles.y + spriteYIndex / tiles.y\n );\n\n vec4 rotatedTexture = texture2D(map, uvPoint);\n\n gl_FragColor = gl_FragColor * rotatedTexture;\n\n if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n #include <logdepthbuf_fragment>\n }\n",transparent:P.transparent,blending:P.blending,depthTest:P.depthTest,depthWrite:P.depthWrite});let ae;if(j){const t=P.mesh;if(!t?.geometry)throw new Error("RendererType.MESH requires a mesh configuration with a geometry. Set renderer.mesh.geometry to a THREE.BufferGeometry instance.");const n=new e.InstancedBufferGeometry,r=t.geometry,i=r.getAttribute("position");i&&n.setAttribute("position",i);const a=r.getAttribute("normal");a&&n.setAttribute("normal",a);const o=r.getAttribute("uv");o&&n.setAttribute("uv",o);const s=r.getIndex();s&&n.setIndex(s),n.instanceCount=b,ae=n}else if(q){const t=new e.InstancedBufferGeometry,n=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),r=new Uint16Array([0,1,2,0,2,3]);t.setAttribute("position",new e.BufferAttribute(n,3)),t.setIndex(new e.BufferAttribute(r,1)),t.instanceCount=b,ae=t}else ae=new e.BufferGeometry;for(let e=0;e<b;e++)ye(a,A,p,z[e],R[e]);const oe=new Float32Array(3*b);for(let e=0;e<b;e++)oe[3*e]=z[e].x,oe[3*e+1]=z[e].y,oe[3*e+2]=z[e].z;const se=G?new e.InstancedBufferAttribute(oe,3):new e.BufferAttribute(oe,3);ae.setAttribute(K,se),ue({geometry:ae,propertyName:X("isActive"),maxParticles:b,factory:0,instanced:G}),ue({geometry:ae,propertyName:X("lifetime"),maxParticles:b,factory:0,instanced:G}),ue({geometry:ae,propertyName:X("startLifetime"),maxParticles:b,factory:()=>1e3*V(a.particleSystemId,m,0),instanced:G}),ue({geometry:ae,propertyName:X("startFrame"),maxParticles:b,factory:()=>_.startFrame?V(a.particleSystemId,_.startFrame,0):0,instanced:G}),ue({geometry:ae,propertyName:X("size"),maxParticles:b,factory:(e,t)=>a.startValues.startSize[t],instanced:G}),ue({geometry:ae,propertyName:X("rotation"),maxParticles:b,factory:0,instanced:G});const le=Math.random();if(ue({geometry:ae,propertyName:X("colorR"),maxParticles:b,factory:()=>g.min.r+le*(g.max.r-g.min.r),instanced:G}),ue({geometry:ae,propertyName:X("colorG"),maxParticles:b,factory:()=>g.min.g+le*(g.max.g-g.min.g),instanced:G}),ue({geometry:ae,propertyName:X("colorB"),maxParticles:b,factory:()=>g.min.b+le*(g.max.b-g.min.b),instanced:G}),ue({geometry:ae,propertyName:X("colorA"),maxParticles:b,factory:0,instanced:G}),j){const t=new Float32Array(4*b);for(let e=0;e<b;e++)t[4*e+3]=1;ae.setAttribute(X("quat"),new e.InstancedBufferAttribute(t,4))}const ce=ae.attributes,me=ce[X("isActive")],he=ce[X("colorR")],xe=ce[X("colorG")],Ie=ce[X("colorB")],be=ce[X("colorA")],Ce=ce[X("startFrame")],Ae=ce[X("startLifetime")],Pe=ce[X("size")],we=ce[X("rotation")],Te=ce[X("lifetime")],Oe=ce[K],Se=j?ce[X("quat")]:void 0,_e=U??[],Ue=_e.filter(e=>"DEATH"===(e.trigger??"DEATH")),Le=_e.filter(e=>"BIRTH"===e.trigger),Ee=new Map;for(const e of _e)Ee.set(e,[]);const ze=t=>{for(let n=t.length-1;n>=0;n--){const r=t[n],i=r.instance instanceof e.Points||r.instance instanceof e.Mesh?r.instance:r.instance.children[0],a=i?.geometry?.attributes,o=a?a.isActive?.array??a.instanceIsActive?.array:void 0;if(!o){r.dispose(),t.splice(n,1);continue}let s=!1;for(let e=0;e<o.length;e++)if(o[e]){s=!0;break}s||(r.dispose(),t.splice(n,1))}},Me=(t,n,r,i)=>{for(const a of t){const t=Ee.get(a),o=a.maxInstances??32;if(t.length>=o&&(ze(t),t.length>=o))continue;const s=a.inheritVelocity??0,l=ve({...a.config,looping:!1,transform:{...a.config.transform,position:new e.Vector3(n.x,n.y,n.z)},renderer:{...a.config.renderer??{},...a.config.renderer?.rendererType||"MESH"===P.rendererType||"TRAIL"===P.rendererType?{}:{rendererType:P.rendererType}},...s>0?{startSpeed:("number"==typeof a.config.startSpeed?a.config.startSpeed:"object"==typeof a.config.startSpeed&&null!==a.config.startSpeed&&"min"in a.config.startSpeed?a.config.startSpeed.min??0:0)+r.length()*s}:{}},i),c=(We||je).parent;c&&c.add(l.instance),t.push(l)}};let Ne,Fe,De,Ve,Re,Be,ke,Qe,He;if(H&&Z){const t=Z.length,n=2*t,r=b*n,i=6*(t-1),o=b*i;Fe=new e.BufferGeometry;const l=new Float32Array(3*r),c=new Float32Array(3*r),d=new Float32Array(r),f=new Float32Array(4*r),m=new Float32Array(r),p=new Float32Array(r),u=new Float32Array(2*r),y=new Uint32Array(o);for(let e=0;e<b;e++){const r=e*n,a=e*i;for(let e=0;e<t;e++)m[r+2*e]=-1,m[r+2*e+1]=1;for(let e=0;e<t-1;e++){const t=a+6*e,n=r+2*e;y[t]=n,y[t+1]=n+1,y[t+2]=n+2,y[t+3]=n+1,y[t+4]=n+3,y[t+5]=n+2}}De=new e.BufferAttribute(l,3),De.setUsage(e.DynamicDrawUsage);const v=new e.BufferAttribute(c,3);v.setUsage(e.DynamicDrawUsage),Ve=new e.BufferAttribute(d,1),Ve.setUsage(e.DynamicDrawUsage),Re=new e.BufferAttribute(f,4),Re.setUsage(e.DynamicDrawUsage);const g=new e.BufferAttribute(p,1);g.setUsage(e.DynamicDrawUsage);const h=new e.BufferAttribute(u,2);h.setUsage(e.DynamicDrawUsage),Be=new e.BufferAttribute(y,1),Fe.setAttribute("position",De),Fe.setAttribute("trailNext",v),Fe.setAttribute("trailAlpha",Ve),Fe.setAttribute("trailColor",Re),Fe.setAttribute("trailOffset",new e.BufferAttribute(m,1)),Fe.setAttribute("trailHalfWidth",g),Fe.setAttribute("trailUV",h),Fe.setIndex(Be);const x=new e.ShaderMaterial({uniforms:{map:{value:s},useMap:{value:!!s},discardBackgroundColor:{value:P.discardBackgroundColor},backgroundColor:{value:P.backgroundColor},backgroundColorTolerance:{value:P.backgroundColorTolerance},softParticlesEnabled:{value:$},softParticlesIntensity:{value:Math.max(P.softParticles?.intensity??1,.001)},sceneDepthTexture:{value:P.softParticles?.depthTexture??null},cameraNearFar:{value:new e.Vector2(.1,1e3)}},vertexShader:"\n attribute float trailAlpha;\n attribute vec4 trailColor;\n attribute float trailOffset;\n attribute float trailHalfWidth;\n attribute vec3 trailNext;\n attribute vec2 trailUV;\n\n varying float vAlpha;\n varying vec4 vColor;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vAlpha = trailAlpha;\n vColor = trailColor;\n vUv = trailUV;\n\n // Compute tangent from current position to next sample\n vec3 tangent = trailNext - position;\n float tangentLen = length(tangent);\n if (tangentLen < 0.0001) {\n tangent = vec3(0.0, 1.0, 0.0);\n } else {\n tangent = tangent / tangentLen;\n }\n\n // Billboard: perpendicular = cross(tangent, viewDirection)\n vec3 worldPos = (modelMatrix * vec4(position, 1.0)).xyz;\n vec3 viewDir = normalize(cameraPosition - worldPos);\n vec3 perp = cross(tangent, viewDir);\n float perpLen = length(perp);\n\n // When tangent is nearly parallel to view direction, the cross product\n // collapses and the ribbon becomes edge-on (invisible). Build a stable\n // fallback perpendicular from the camera's right axis — this keeps the\n // ribbon in screen-space and prevents it from flipping into an arbitrary\n // plane when viewed edge-on.\n vec3 camRight = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);\n vec3 fallbackPerp = normalize(camRight - tangent * dot(camRight, tangent));\n\n if (perpLen < 0.0001) {\n perp = fallbackPerp;\n } else {\n perp = perp / perpLen;\n // Smoothly blend toward the fallback when the billboard perp weakens.\n // The wide range (0..0.7) ensures a gradual transition so the ribbon\n // does not snap abruptly when rotating toward edge-on.\n float blendFactor = smoothstep(0.0, 0.7, perpLen);\n perp = normalize(mix(fallbackPerp, perp, blendFactor));\n }\n\n vec3 offsetPos = position + perp * trailOffset * trailHalfWidth;\n vec4 mvPosition = modelViewMatrix * vec4(offsetPos, 1.0);\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:"\n uniform sampler2D map;\n uniform bool useMap;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying float vAlpha;\n varying vec4 vColor;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n // Soft edge: always fade near ribbon edges\n float edgeDist = 1.0 - abs(vUv.x * 2.0 - 1.0);\n float softEdge = smoothstep(0.0, 0.4, edgeDist);\n\n gl_FragColor = vColor;\n\n if (useMap) {\n // Use texture luminance as brightness modulation on top of soft edge\n vec4 texColor = texture2D(map, vUv);\n float texBrightness = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));\n gl_FragColor.rgb *= (0.5 + texBrightness * 0.5);\n gl_FragColor.a *= texColor.a;\n }\n\n gl_FragColor.a *= vAlpha * softEdge;\n\n if (gl_FragColor.a < 0.001) discard;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n if (discardBackgroundColor && abs(length(gl_FragColor.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n #include <logdepthbuf_fragment>\n }\n",transparent:P.transparent,blending:P.blending,depthTest:P.depthTest,depthWrite:P.depthWrite,side:e.DoubleSide});Ne=new e.Mesh(Fe,x),Ne.frustumCulled=!1;const I=new e.Vector3;Ne.onBeforeRender=(e,t,n)=>{if(n.getWorldPosition(I),$&&n.isPerspectiveCamera){const e=n;x.uniforms.cameraNearFar.value.set(e.near,e.far)}},a.trailCameraPosition=I,ke=D(a.particleSystemId,Z.widthOverTrail),Qe=D(a.particleSystemId,Z.opacityOverTrail),Z.colorOverTrail?.isActive&&(He={r:D(a.particleSystemId,te(Z.colorOverTrail.r,W)),g:D(a.particleSystemId,te(Z.colorOverTrail.g,W)),b:D(a.particleSystemId,te(Z.colorOverTrail.b,W))})}let je=q||j?new e.Mesh(ae,ee):new e.Points(ae,ee);(q||$)&&(je.onBeforeRender=(t,n,r)=>{if(q){const n=t.getSize(new e.Vector2);J.viewportHeight.value=n.y*t.getPixelRatio()}if($&&r.isPerspectiveCamera){const e=r;J.cameraNearFar.value.set(e.near,e.far)}}),H&&Ne&&(ee.visible=!1,je.add(Ne)),je.position.copy(l.position),je.rotation.x=e.MathUtils.degToRad(l.rotation.x),je.rotation.y=e.MathUtils.degToRad(l.rotation.y),je.rotation.z=e.MathUtils.degToRad(l.rotation.z),je.scale.copy(l.scale);const qe={position:Oe,isActive:me,lifetime:Te,startLifetime:Ae,startFrame:Ce,size:Pe,rotation:we,colorR:he,colorG:xe,colorB:Ie,colorA:be,...j?{quat:Se}:{}},Ge=i+1e3*V(a.particleSystemId,f);let We;"WORLD"===o.simulationSpace&&(We=new t,We.add(je));const Ze=Ue.length>0?(e,t,n,r)=>{const i=3*e;ie.set(t[i],t[i+1],t[i+2]),Me(Ue,ie,n,r)}:void 0,Xe=Le.length>0?(e,t,n,r)=>{const i=3*e;ie.set(t[i],t[i+1],t[i+2]),Me(Le,ie,n,r)}:void 0,Ye={particleSystem:je,wrapper:We,mappedAttributes:qe,elapsedUniform:ee.uniforms.elapsed,generalData:a,onUpdate:O,onComplete:S,creationTime:Ge,lastEmissionTime:Ge,duration:c,looping:d,simulationSpace:I,gravity:x,normalizedForceFields:E,emission:C,normalizedConfig:o,iterationCount:0,velocities:R,freeList:B,deactivateParticle:e=>{me.array[e]=0,be.array[e]=0,be.needsUpdate=!0,B.push(e)},activateParticle:({particleIndex:t,activationTime:n,position:r})=>{if(me.array[t]=1,a.creationTimes[t]=n,a.positionHistoryCount){if(a.positionHistoryCount[t]=0,a.positionHistoryIndex[t]=0,a.trailLastSampledPosition){const e=3*t;a.trailLastSampledPosition[e]=0,a.trailLastSampledPosition[e+1]=0,a.trailLastSampledPosition[e+2]=0}if(a.trailPrevNormal){const e=3*t;a.trailPrevNormal[e]=0,a.trailPrevNormal[e+1]=0,a.trailPrevNormal[e+2]=0}}a.noise.offsets&&(a.noise.offsets[t]=100*Math.random());const i=Math.random(),s=o.startColor;if(he.array[t]=s.min.r+i*(s.max.r-s.min.r),he.needsUpdate=!0,xe.array[t]=s.min.g+i*(s.max.g-s.min.g),xe.needsUpdate=!0,Ie.array[t]=s.min.b+i*(s.max.b-s.min.b),Ie.needsUpdate=!0,a.startValues.startColorR[t]=he.array[t],a.startValues.startColorG[t]=xe.array[t],a.startValues.startColorB[t]=Ie.array[t],Ce.array[t]=o.textureSheetAnimation.startFrame?V(a.particleSystemId,o.textureSheetAnimation.startFrame,0):0,Ce.needsUpdate=!0,Ae.array[t]=1e3*V(a.particleSystemId,o.startLifetime,a.normalizedLifetimePercentage),Ae.needsUpdate=!0,a.startValues.startSize[t]=V(a.particleSystemId,o.startSize,a.normalizedLifetimePercentage),Pe.array[t]=a.startValues.startSize[t],Pe.needsUpdate=!0,a.startValues.startOpacity[t]=V(a.particleSystemId,o.startOpacity,a.normalizedLifetimePercentage),be.array[t]=a.startValues.startOpacity[t],be.needsUpdate=!0,we.array[t]=V(a.particleSystemId,o.startRotation,a.normalizedLifetimePercentage),we.needsUpdate=!0,Se){const e=.5*we.array[t],n=4*t;Se.array[n]=0,Se.array[n+1]=0,Se.array[n+2]=Math.sin(e),Se.array[n+3]=Math.cos(e),Se.needsUpdate=!0}o.rotationOverLifetime.isActive&&(a.lifetimeValues.rotationOverLifetime[t]=e.MathUtils.randFloat(o.rotationOverLifetime.min,o.rotationOverLifetime.max)),ye(a,o.shape,o.startSpeed,z[t],R[t]);const l=Math.floor(3*t);Oe.array[l]=r.x+z[t].x,Oe.array[l+1]=r.y+z[t].y,Oe.array[l+2]=r.z+z[t].z,Oe.needsUpdate=!0,a.linearVelocityData&&a.linearVelocityData[t].speed.set(o.velocityOverLifetime.linear.x?V(a.particleSystemId,o.velocityOverLifetime.linear.x,0):0,o.velocityOverLifetime.linear.y?V(a.particleSystemId,o.velocityOverLifetime.linear.y,0):0,o.velocityOverLifetime.linear.z?V(a.particleSystemId,o.velocityOverLifetime.linear.z,0):0),a.orbitalVelocityData&&(a.orbitalVelocityData[t].speed.set(o.velocityOverLifetime.orbital.x?V(a.particleSystemId,o.velocityOverLifetime.orbital.x,0):0,o.velocityOverLifetime.orbital.y?V(a.particleSystemId,o.velocityOverLifetime.orbital.y,0):0,o.velocityOverLifetime.orbital.z?V(a.particleSystemId,o.velocityOverLifetime.orbital.z,0):0),a.orbitalVelocityData[t].positionOffset.set(z[t].x,z[t].y,z[t].z)),Te.array[t]=0,Te.needsUpdate=!0,k({delta:0,generalData:a,normalizedConfig:o,attributes:qe,particleLifetimePercentage:0,particleIndex:t})},onParticleDeath:Ze,onParticleBirth:Xe,...H?{trailMesh:Ne,trailPositionAttr:De,trailAlphaAttr:Ve,trailColorAttr:Re,trailWidthCurveFn:ke,trailOpacityCurveFn:Qe,trailColorOverTrailFns:He,trailConfig:{length:Z.length,width:Z.width,minVertexDistance:Z.minVertexDistance,maxTime:Z.maxTime,smoothing:Z.smoothing,smoothingSubdivisions:Z.smoothingSubdivisions,twistPrevention:Z.twistPrevention,ribbonId:Z.ribbonId}}:{}};re.push(Ye);return{instance:We||je,resumeEmitter:()=>a.isEnabled=!0,pauseEmitter:()=>a.isEnabled=!1,dispose:()=>{for(const e of Ee.values()){for(const t of e)t.dispose();e.length=0}(e=>{re=re.filter(({particleSystem:t,wrapper:n,trailMesh:r,generalData:{particleSystemId:i}})=>t!==e&&n!==e||(u(i),r&&(r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(e=>e.dispose()):r.material.dispose(),r.parent&&r.parent.remove(r)),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),n?.parent&&n.parent.remove(n),!1))})(je)},update:e=>{ge(Ye,e);for(const t of Ee.values())for(const n of t)n.update(e)},updateConfig:e=>{Q.deepMerge(Ye.normalizedConfig,e,{applyToFirstObject:!0,skippedProperties:[]});const t=Ye.normalizedConfig;if(void 0!==e.gravity&&(Ye.gravity=t.gravity,a.lastWorldQuaternion.x=-99999),void 0!==e.duration&&(Ye.duration=t.duration),void 0!==e.looping&&(Ye.looping=t.looping),void 0!==e.simulationSpace&&(Ye.simulationSpace=t.simulationSpace),void 0!==e.emission&&(Ye.emission=t.emission),void 0!==e.forceFields&&(Ye.normalizedForceFields=de(t.forceFields)),void 0!==e.noise){const e=t.noise;a.noise={isActive:e.isActive,strength:e.strength,noisePower:.15*e.strength,positionAmount:e.positionAmount,rotationAmount:e.rotationAmount,sizeAmount:e.sizeAmount,sampler:e.isActive?new Y({seed:Math.random(),scale:e.frequency,octaves:e.octaves}):void 0,offsets:e.useRandomOffset?a.noise.offsets??Array.from({length:b},()=>100*Math.random()):void 0}}}}},ge=(e,{now:t,delta:n,elapsed:r})=>{const{onUpdate:i,generalData:a,onComplete:o,particleSystem:s,wrapper:l,elapsedUniform:c,creationTime:d,lastEmissionTime:f,duration:m,looping:p,emission:u,normalizedConfig:y,iterationCount:v,velocities:g,freeList:h,deactivateParticle:x,activateParticle:I,simulationSpace:b,gravity:C,normalizedForceFields:A,onParticleDeath:P,onParticleBirth:w,mappedAttributes:T}=e,O=A.length>0,S=t-d,_=S%(1e3*m);a.normalizedLifetimePercentage=Math.max(Math.min(_/(1e3*m),1),0);const{lastWorldPosition:U,currentWorldPosition:L,worldPositionChange:E,lastWorldQuaternion:z,worldQuaternion:M,worldEuler:N,gravityVelocity:F,isEnabled:D}=a;l?.parent&&a.wrapperQuaternion.copy(l.parent.quaternion),ae.copy(U),c.value=r,s.getWorldPosition(L),-99999!==U.x&&E.set(L.x-U.x,L.y-U.y,L.z-U.z),D&&(a.distanceFromLastEmitByDistance+=E.length()),s.getWorldPosition(U),s.getWorldQuaternion(M),-99999!==z.x&&z.x===M.x&&z.y===M.y&&z.z===M.z||(N.setFromQuaternion(M),z.copy(M),F.set(U.x,U.y+C,U.z),s.worldToLocal(F));const R=a.creationTimes,B=T.isActive.array,Q=T.startLifetime.array,H=T.position.array,j=T.lifetime.array,q=R.length;let G=!1,W=!1;le.delta=n,le.generalData=a,le.normalizedConfig=y,le.attributes=T;for(let e=0;e<q;e++)if(B[e]){const r=t-R[e];if(r>Q[e])P&&P(e,H,g[e],t),x(e);else{const t=g[e];if(t.x-=F.x*n,t.y-=F.y*n,t.z-=F.z*n,O&&ee({particleSystemId:a.particleSystemId,forceFields:A,velocity:t,positionArr:H,positionIndex:3*e,delta:n,systemLifetimePercentage:a.normalizedLifetimePercentage}),0!==C||0!==t.x||0!==t.y||0!==t.z||0!==E.x||0!==E.y||0!==E.z){const r=3*e;"WORLD"===b&&(H[r]-=E.x,H[r+1]-=E.y,H[r+2]-=E.z),H[r]+=t.x*n,H[r+1]+=t.y*n,H[r+2]+=t.z*n,G=!0}j[e]=r,W=!0,le.particleLifetimePercentage=r/Q[e],le.particleIndex=e,k(le)}}if(G&&(T.position.needsUpdate=!0),W&&(T.lifetime.needsUpdate=!0),D&&(p||S<1e3*m)){const o=t-f,l=u.rateOverTime?Math.floor(V(a.particleSystemId,u.rateOverTime,a.normalizedLifetimePercentage)*(o/1e3)):0,c=u.rateOverDistance?V(a.particleSystemId,u.rateOverDistance,a.normalizedLifetimePercentage):0,d=c>0&&a.distanceFromLastEmitByDistance>0?Math.floor(a.distanceFromLastEmitByDistance/(1/c)):0,m=d>0;m&&(oe.x=(L.x-ae.x)/d,oe.y=(L.y-ae.y)/d,oe.z=(L.z-ae.z)/d);let y=l+d;if(c>0&&d>=1&&(a.distanceFromLastEmitByDistance=0),u.bursts&&a.burstStates){const e=u.bursts,t=a.burstStates,n=_;for(let r=0;r<e.length;r++){const i=e[r],o=t[r],s=1e3*i.time,l=i.cycles??1,c=1e3*(i.interval??0),d=i.probability??1;if(p&&n<s&&o.cyclesExecuted>0&&(o.cyclesExecuted=0,o.lastCycleTime=0,o.probabilityPassed=!1),o.cyclesExecuted>=l)continue;if(n>=s+o.cyclesExecuted*c){if(0===o.cyclesExecuted&&(o.probabilityPassed=Math.random()<d),o.probabilityPassed){y+=Math.floor(V(a.particleSystemId,i.count,a.normalizedLifetimePercentage))}o.cyclesExecuted++,o.lastCycleTime=n}}}if(y>0){let n=0;for(let r=0;r<y&&0!==h.length;r++){const r=h.pop();se.x=0,se.y=0,se.z=0,m&&n<d&&(se.x=oe.x*n,se.y=oe.y*n,se.z=oe.z*n,n++),I({particleIndex:r,activationTime:t,position:se}),w&&w(r,T.position.array,g[r],t),e.lastEmissionTime=t}}i&&i({particleSystem:s,delta:n,elapsed:r,lifetime:S,normalizedLifetime:_,iterationCount:v+1})}else o&&o({particleSystem:s});e.trailMesh&&Se(e,t)},he=(e,t,n,r,i,a,o,s,l,c,d,f,m,p,u)=>{const y=u*u,v=y*u;e[t]=.5*(2*a+(-n+l)*u+(2*n-5*a+4*l-f)*y+(3*a-n-3*l+f)*v),e[t+1]=.5*(2*o+(-r+c)*u+(2*r-5*o+4*c-m)*y+(3*o-r-3*c+m)*v),e[t+2]=.5*(2*s+(-i+d)*u+(2*i-5*s+4*d-p)*y+(3*s-i-3*d+p)*v)},xe=(e,t,n,r,i,a,o,s,l,c,d,f,m)=>{i[e]=d,i[e+1]=f,i[e+2]=m,i[e+3]=d,i[e+4]=f,i[e+5]=m,a[e]=d,a[e+1]=f,a[e+2]=m,a[e+3]=d,a[e+4]=f,a[e+5]=m,o[n]=0,o[n+1]=0,s[r]=0,s[r+1]=0,s[r+2]=0,s[r+3]=0,l[n]=0,l[n+1]=0,c[t]=0,c[t+1]=0,c[t+2]=0,c[t+3]=0,c[t+4]=0,c[t+5]=0,c[t+6]=0,c[t+7]=0},Ie=(e,t,n,r,i,a,o,s,l,c,d,f,m,p,u,y,v,g,h,x,I,b,C)=>{g[e]=i,g[e+1]=a,g[e+2]=o,g[e+3]=i,g[e+4]=a,g[e+5]=o,h[e]=s,h[e+1]=l,h[e+2]=c,h[e+3]=s,h[e+4]=l,h[e+5]=c,x[n]=d,x[n+1]=d,I[r]=0,I[r+1]=f,I[r+2]=1,I[r+3]=f,b[n]=m,b[n+1]=m,C[t]=p,C[t+1]=u,C[t+2]=y,C[t+3]=v,C[t+4]=p,C[t+5]=u,C[t+6]=y,C[t+7]=v},be=null,Ce=0,Ae=null,Pe=0,we=null,Te=0,Oe=0,Se=(e,t)=>{const{generalData:n,trailPositionAttr:r,trailAlphaAttr:i,trailColorAttr:a,trailWidthCurveFn:o,trailOpacityCurveFn:s,trailColorOverTrailFns:l,trailConfig:c,mappedAttributes:d}=e;if(!(r&&i&&a&&o&&s&&c&&n.positionHistory&&n.positionHistoryIndex&&n.positionHistoryCount))return;const f=c.length,m=n.positionHistory,p=n.positionHistoryIndex,u=n.positionHistoryCount,y=n.trailSampleTimes,v=n.trailLastSampledPosition,g=n.trailPrevNormal,h=c.minVertexDistance,x=h*h,I=c.maxTime,b=1e3*I,C=c.smoothing,A=c.smoothingSubdivisions,P=c.twistPrevention,w=c.ribbonId,T=d.isActive.array,O=d.position.array,S=d.colorR.array,_=d.colorG.array,U=d.colorB.array,L=d.colorA.array,E=r.array,z=i.array,M=a.array,N=e.trailMesh,F=N.geometry.getAttribute("trailNext").array,D=N.geometry.getAttribute("trailUV").array,V=N.geometry.getAttribute("trailHalfWidth").array,R=2*f,B=n.creationTimes.length;let k=!1;const Q=void 0!==w;let H=-1;if(Q){(!we||Te<B)&&(we=new Uint16Array(B),Te=B),Oe=0;for(let e=0;e<B;e++)T[e]&&(we[Oe++]=e);for(let e=1;e<Oe;e++){const t=we[e],r=n.creationTimes[t];let i=e-1;for(;i>=0&&n.creationTimes[we[i]]>r;)we[i+1]=we[i],i--;we[i+1]=t}Oe>0&&(H=we[0])}for(let e=0;e<B;e++){const n=e*R;if(T[e]){if(Q&&Oe>=2&&e!==H){const n=3*e,r=O[n],i=O[n+1],a=O[n+2],o=3*(e*f+p[e]);m[o]=r,m[o+1]=i,m[o+2]=a,y&&(y[e*f+p[e]]=t),p[e]=(p[e]+1)%f,u[e]<f&&u[e]++;continue}k=!0;const r=3*e,i=O[r],a=O[r+1],d=O[r+2];let w=!0;if(h>0&&v&&u[e]>0){const t=3*e,n=i-v[t],r=a-v[t+1],o=d-v[t+2];n*n+r*r+o*o<x&&(w=!1)}if(w){const n=3*(e*f+p[e]);if(m[n]=i,m[n+1]=a,m[n+2]=d,y&&(y[e*f+p[e]]=t),p[e]=(p[e]+1)%f,u[e]<f&&u[e]++,v){const t=3*e;v[t]=i,v[t+1]=a,v[t+2]=d}}let T=u[e],N=T;if(I>0&&y&&T>0){const n=e*f;N=0;for(let r=0;r<T;r++){if(!(t-y[n+(p[e]-1-r+2*f)%f]<=b))break;N++}}const R=N,B=c.width,j=S[e],q=_[e],G=U[e],W=L[e],Z=e*f*3,X=3*R;(!be||Ce<X)&&(be=new Float32Array(X),Ce=X);const Y=be;for(let t=0;t<R;t++){const n=(p[e]-1-t+2*f)%f*3+Z;Y[3*t]=m[n],Y[3*t+1]=m[n+1],Y[3*t+2]=m[n+2]}let K,$;if(C&&R>=3){const e=R-1;$=e*A+1;const t=3*$;(!Ae||Pe<t)&&(Ae=new Float32Array(t),Pe=t),K=Ae;for(let t=0;t<e;t++){const e=Math.max(0,t-1),n=t,r=Math.min(R-1,t+1),i=Math.min(R-1,t+2),a=Y[3*e],o=Y[3*e+1],s=Y[3*e+2],l=Y[3*n],c=Y[3*n+1],d=Y[3*n+2],f=Y[3*r],m=Y[3*r+1],p=Y[3*r+2],u=Y[3*i],y=Y[3*i+1],v=Y[3*i+2];for(let e=0;e<A;e++){he(K,3*(t*A+e),a,o,s,l,c,d,f,m,p,u,y,v,e/A)}}const n=3*($-1);K[n]=Y[3*(R-1)],K[n+1]=Y[3*(R-1)+1],K[n+2]=Y[3*(R-1)+2]}else K=Y,$=R;if($>f&&($=f),C&&$>=2){const e=1e-8;for(let t=1;t<$;t++){const n=3*(t-1),r=3*t,i=K[r]-K[n],a=K[r+1]-K[n+1],o=K[r+2]-K[n+2];i*i+a*a+o*o<e&&(K[r]=K[n],K[r+1]=K[n+1],K[r+2]=K[n+2])}}for(let r=0;r<f;r++){const c=3*(n+2*r),m=4*(n+2*r),u=n+2*r,v=2*(n+2*r);if(r>=$){xe(c,m,u,v,E,F,V,D,z,M,i,a,d);continue}const g=K[3*r],h=K[3*r+1],x=K[3*r+2];let A,P,w;if(r>0&&r<$-1){const e=K[3*(r-1)],t=K[3*(r-1)+1],n=K[3*(r-1)+2],i=K[3*(r+1)]-e,a=K[3*(r+1)+1]-t,o=K[3*(r+1)+2]-n,s=Math.sqrt(i*i+a*a+o*o);s>1e-4?(A=g+i/s,P=h+a/s,w=x+o/s):(A=K[3*(r+1)],P=K[3*(r+1)+1],w=K[3*(r+1)+2])}else r<$-1?(A=K[3*(r+1)],P=K[3*(r+1)+1],w=K[3*(r+1)+2]):(A=g,P=h+.001,w=x);const O=$>1?r/($-1):0;let S=1;if(I>0&&y&&N>0){const n=C?Math.min(Math.floor(r/Math.max($-1,1)*(T-1)),T-1):Math.min(r,T-1),i=t-y[e*f+(p[e]-1-n+2*f)%f];S=1-Math.min(i/b,1)}const _=B*o(O)*.5,U=W*s(O)*S,L=l?j*l.r(O):j,R=l?q*l.g(O):q,k=l?G*l.b(O):G;Ie(c,m,u,v,g,h,x,A,P,w,_,O,U,L,R,k,W,E,F,V,D,z,M)}if(P&&g&&$>=2){const t=3*e,r=K[3]-K[0],i=K[4]-K[1],a=K[5]-K[2],o=Math.sqrt(r*r+i*i+a*a);if(o>1e-4){const e=r/o,s=i/o,l=a/o;let c=0,d=1,m=0;const p=e*c+s*d+l*m;Math.abs(p)>.999&&(c=1,d=0,m=0);let u=s*m-l*d,y=l*c-e*m,v=e*d-s*c;const h=Math.sqrt(u*u+y*y+v*v);h>1e-4&&(u/=h,y/=h,v/=h);const x=g[t],I=g[t+1],b=g[t+2];if(0!==x||0!==I||0!==b){if(u*x+y*I+v*b<0){for(let e=0;e<Math.min($,f);e++){const t=n+2*e,r=V[t];V[t]=-r,V[t+1]=-r}u=-u,y=-y,v=-v}}g[t]=u,g[t+1]=y,g[t+2]=v}}}else if(u[e]>0){k=!0,u[e]=0,p[e]=0;for(let e=0;e<f;e++){xe(3*(n+2*e),4*(n+2*e),n+2*e,2*(n+2*e),E,F,V,D,z,M,0,0,0)}}}if(Q&&Oe>=2&&we){k=!0;const e=we[0],t=e*R,n=Oe,r=Math.min(f,Math.max(4*n,n)),i=3*r;if((!be||Ce<i)&&(be=new Float32Array(i),Ce=i),2===n){const e=3*we[0],t=3*we[1];for(let n=0;n<r;n++){const i=n/(r-1);be[3*n]=O[e]+i*(O[t]-O[e]),be[3*n+1]=O[e+1]+i*(O[t+1]-O[e+1]),be[3*n+2]=O[e+2]+i*(O[t+2]-O[e+2])}}else{const e=n-1,t=Math.max(1,Math.floor((r-1)/e));let i=0;for(let a=0;a<e&&i<r;a++){const o=Math.max(0,a-1),s=a,l=Math.min(n-1,a+1),c=Math.min(n-1,a+2),d=3*we[o],f=3*we[s],m=3*we[l],p=3*we[c],u=a===e-1?r-i:t;for(let e=0;e<u&&i<r;e++){const t=e/u;he(be,3*i,O[d],O[d+1],O[d+2],O[f],O[f+1],O[f+2],O[m],O[m+1],O[m+2],O[p],O[p+1],O[p+2],t),i++}}if(i>0){const e=3*we[n-1];be[3*(i-1)]=O[e],be[3*(i-1)+1]=O[e+1],be[3*(i-1)+2]=O[e+2]}}const a=S[e],d=_[e],m=U[e],p=L[e];for(let e=0;e<f;e++){const n=3*(t+2*e),i=4*(t+2*e),f=t+2*e,u=2*(t+2*e);if(e>=r){xe(n,i,f,u,E,F,V,D,z,M,0,0,0);continue}const y=3*e,v=be[y],g=be[y+1],h=be[y+2];let x,I,b;if(e>0&&e<r-1){const t=be[3*(e-1)],n=be[3*(e-1)+1],r=be[3*(e-1)+2],i=be[3*(e+1)]-t,a=be[3*(e+1)+1]-n,o=be[3*(e+1)+2]-r,s=Math.sqrt(i*i+a*a+o*o);s>1e-4?(x=v+i/s,I=g+a/s,b=h+o/s):(x=be[3*(e+1)],I=be[3*(e+1)+1],b=be[3*(e+1)+2])}else e<r-1?(x=be[3*(e+1)],I=be[3*(e+1)+1],b=be[3*(e+1)+2]):(x=v,I=g+.001,b=h);const C=r>1?e/(r-1):0,A=o(C),P=s(C),w=c.width*A*.5,T=p*P,O=l?a*l.r(C):a,S=l?d*l.g(C):d,_=l?m*l.b(C):m;Ie(n,i,f,u,v,g,h,x,I,b,w,C,T,O,S,_,p,E,F,V,D,z,M)}for(let e=1;e<Oe;e++){const t=we[e]*R;for(let e=0;e<f;e++){xe(3*(t+2*e),4*(t+2*e),t+2*e,2*(t+2*e),E,F,V,D,z,M,0,0,0)}}}if(k){r.needsUpdate=!0,i.needsUpdate=!0,a.needsUpdate=!0;const e=N.geometry.getAttribute("trailNext"),t=N.geometry.getAttribute("trailHalfWidth");e.needsUpdate=!0,t.needsUpdate=!0;N.geometry.getAttribute("trailUV").needsUpdate=!0}},_e=e=>{re.forEach(t=>ge(t,e))};export{g as CurveFunctionId,C as EmitFrom,S as ForceFieldFalloff,T as ForceFieldType,P as LifeTimeCurve,O as RendererType,b as Shape,I as SimulationSpace,w as SubEmitterTrigger,A as TimeMode,k as applyModifiers,fe as blendingMap,L as calculateRandomPositionAndVelocityOnBox,E as calculateRandomPositionAndVelocityOnCircle,U as calculateRandomPositionAndVelocityOnCone,z as calculateRandomPositionAndVelocityOnRectangle,_ as calculateRandomPositionAndVelocityOnSphere,V as calculateValue,p as createBezierCurveFunction,M as createDefaultMeshTexture,N as createDefaultParticleTexture,ve as createParticleSystem,h as curveFunctionIdMap,y as getBezierCacheSize,x as getCurveFunction,D as getCurveFunctionFromConfig,me as getDefaultParticleSystemConfig,F as isLifeTimeCurve,u as removeBezierCurveFunction,_e as updateParticleSystems};//# sourceMappingURL=three-particles.min.js.map
|
|
1
|
+
import*as e from"three";import{Gyroscope as t}from"three/examples/jsm/misc/Gyroscope.js";var n,r,i=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,d=(n={"node_modules/easing-functions/index.js"(e,t){var n=e=>e,r={In:e=>e*e,Out:e=>e*(2-e),InOut(e){let t=2*e;return t<1?.5*t*t:(t-=1,-.5*(t*(t-2)-1))}},i={In:e=>e*e*e,Out:e=>--e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t:(t-=2,.5*(t*t*t+2))}},a={In:e=>e*e*e*e,Out:e=>1- --e*e*e*e,InOut(e){let t=2*e;return t<1?.5*t*t*t*t:(t-=2,-.5*(t*t*t*t-2))}},o={In:e=>e*e*e*e*e,Out:e=>--e*e*e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t*t*t:(t-=2,.5*(t*t*t*t*t+2))}},s={In:e=>1-Math.cos(e*Math.PI/2),Out:e=>Math.sin(e*Math.PI/2),InOut:e=>.5*(1-Math.cos(Math.PI*e))},l={In:e=>0===e?0:1024**(e-1),Out:e=>1===e?1:1-2**(-10*e),InOut(e){if(0===e)return 0;if(1===e)return 1;const t=2*e;return t<1?.5*1024**(t-1):.5*(2-2**(-10*(t-1)))}},c={In:e=>1-Math.sqrt(1-e*e),Out:e=>Math.sqrt(1- --e*e),InOut(e){let t=2*e;return t<1?-.5*(Math.sqrt(1-t*t)-1):(t-=2,.5*(Math.sqrt(1-t*t)+1))}},d={In(e){let t,n=.1;return 0===e?0:1===e?1:(n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),-n*2**(10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},Out(e){let t,n=.1;return 0===e?0:1===e?1:(n<1?(n=1,t=.1):t=.4*Math.asin(1/n)/(2*Math.PI),n*2**(-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},InOut(e){let t=.1;const n=.4;let r;if(0===e)return 0;if(1===e)return 1;t<1?(t=1,r=.1):r=n*Math.asin(1/t)/(2*Math.PI);const i=2*e;if(i<1){const e=i-1;return t*2**(10*e)*Math.sin((e-r)*(2*Math.PI)/n)*-.5}const a=i-1;return t*2**(-10*a)*Math.sin((a-r)*(2*Math.PI)/n)*.5+1}},f={In(e){const t=1.70158;return e*e*((t+1)*e-t)},Out(e){const t=1.70158;return--e*e*((t+1)*e+t)+1},InOut(e){const t=2.5949095;let n=2*e;return n<1?n*n*((t+1)*n-t)*.5:(n-=2,.5*(n*n*((t+1)*n+t)+2))}},m={In:e=>1-m.Out(1-e),Out(e){if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const t=e-1.5/2.75;return 7.5625*t*t+.75}if(e<2.5/2.75){const t=e-2.25/2.75;return 7.5625*t*t+.9375}const t=e-2.625/2.75;return 7.5625*t*t+.984375},InOut:e=>e<.5?.5*m.In(2*e):.5*m.Out(2*e-1)+.5},p={Quadratic:r,Cubic:i,Quartic:a,Quintic:o,Sinusoidal:s,Exponential:l,Circular:c,Elastic:d,Back:f,Bounce:m},u=(e,t,n)=>Object.defineProperty(e,t,{value:n});for(const e of Object.keys(p)){const t=p[e],n=e.toLowerCase();u(p,n,t);for(const r of Object.keys(t)){const i=t[r],a=r.toLowerCase();u(p,`${e}.${r}`,i),u(p,`${n}.${a}`,i),u(t,a,i)}}p.Linear=n,u(p,"linear",n),t.exports=p,"undefined"!=typeof window&&(window.Easing=p)}},function(){return r||(0,n[s(n)[0]])((r={exports:{}}).exports,r),r.exports}),f=[],m=(e,t)=>{let n=1;for(let r=1;r<=t;r++)n*=(e+1-r)/r;return n},p=(e,t)=>{const n=f.find(e=>e.bezierPoints===t);if(n)return n.referencedBy.includes(e)||n.referencedBy.push(e),n.curveFunction;const r={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let n=0,r=t.length-1;t.find((t,i)=>{const a=e<(t.percentage??0);return a?r=i:void 0!==t.percentage&&(n=i),a});const i=r-n,a=(e-(t[n].percentage??0))/((t[r].percentage??1)-(t[n].percentage??0));let o=0;for(let e=0;e<=i;e++){const r=t[n+e];o+=m(i,e)*Math.pow(1-a,i-e)*Math.pow(a,e)*r.y}return o}};return f.push(r),r.curveFunction},u=e=>{for(;;){const t=f.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const n=f[t];n.referencedBy=n.referencedBy.filter(t=>t!==e),0===n.referencedBy.length&&f.splice(t,1)}},y=()=>f.length,v=((e,t,n)=>(n=null!=e?i(l(e)):{},((e,t,n,r)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of s(t))c.call(e,i)||i===n||a(e,i,{get:()=>t[i],enumerable:!(r=o(t,i))||r.enumerable});return e})(a(n,"default",{value:e,enumerable:!0}),e)))(d()),g=(e=>(e.BEZIER="BEZIER",e.LINEAR="LINEAR",e.QUADRATIC_IN="QUADRATIC_IN",e.QUADRATIC_OUT="QUADRATIC_OUT",e.QUADRATIC_IN_OUT="QUADRATIC_IN_OUT",e.CUBIC_IN="CUBIC_IN",e.CUBIC_OUT="CUBIC_OUT",e.CUBIC_IN_OUT="CUBIC_IN_OUT",e.QUARTIC_IN="QUARTIC_IN",e.QUARTIC_OUT="QUARTIC_OUT",e.QUARTIC_IN_OUT="QUARTIC_IN_OUT",e.QUINTIC_IN="QUINTIC_IN",e.QUINTIC_OUT="QUINTIC_OUT",e.QUINTIC_IN_OUT="QUINTIC_IN_OUT",e.SINUSOIDAL_IN="SINUSOIDAL_IN",e.SINUSOIDAL_OUT="SINUSOIDAL_OUT",e.SINUSOIDAL_IN_OUT="SINUSOIDAL_IN_OUT",e.EXPONENTIAL_IN="EXPONENTIAL_IN",e.EXPONENTIAL_OUT="EXPONENTIAL_OUT",e.EXPONENTIAL_IN_OUT="EXPONENTIAL_IN_OUT",e.CIRCULAR_IN="CIRCULAR_IN",e.CIRCULAR_OUT="CIRCULAR_OUT",e.CIRCULAR_IN_OUT="CIRCULAR_IN_OUT",e.ELASTIC_IN="ELASTIC_IN",e.ELASTIC_OUT="ELASTIC_OUT",e.ELASTIC_IN_OUT="ELASTIC_IN_OUT",e.BACK_IN="BACK_IN",e.BACK_OUT="BACK_OUT",e.BACK_IN_OUT="BACK_IN_OUT",e.BOUNCE_IN="BOUNCE_IN",e.BOUNCE_OUT="BOUNCE_OUT",e.BOUNCE_IN_OUT="BOUNCE_IN_OUT",e))(g||{}),h={LINEAR:v.default.Linear.None,QUADRATIC_IN:v.default.Quadratic.In,QUADRATIC_OUT:v.default.Quadratic.Out,QUADRATIC_IN_OUT:v.default.Quadratic.InOut,CUBIC_IN:v.default.Cubic.In,CUBIC_OUT:v.default.Cubic.Out,CUBIC_IN_OUT:v.default.Cubic.InOut,QUARTIC_IN:v.default.Quartic.In,QUARTIC_OUT:v.default.Quartic.Out,QUARTIC_IN_OUT:v.default.Quartic.InOut,QUINTIC_IN:v.default.Quintic.In,QUINTIC_OUT:v.default.Quintic.Out,QUINTIC_IN_OUT:v.default.Quintic.InOut,SINUSOIDAL_IN:v.default.Sinusoidal.In,SINUSOIDAL_OUT:v.default.Sinusoidal.Out,SINUSOIDAL_IN_OUT:v.default.Sinusoidal.InOut,EXPONENTIAL_IN:v.default.Exponential.In,EXPONENTIAL_OUT:v.default.Exponential.Out,EXPONENTIAL_IN_OUT:v.default.Exponential.InOut,CIRCULAR_IN:v.default.Circular.In,CIRCULAR_OUT:v.default.Circular.Out,CIRCULAR_IN_OUT:v.default.Circular.InOut,ELASTIC_IN:v.default.Elastic.In,ELASTIC_OUT:v.default.Elastic.Out,ELASTIC_IN_OUT:v.default.Elastic.InOut,BACK_IN:v.default.Back.In,BACK_OUT:v.default.Back.Out,BACK_IN_OUT:v.default.Back.InOut,BOUNCE_IN:v.default.Bounce.In,BOUNCE_OUT:v.default.Bounce.Out,BOUNCE_IN_OUT:v.default.Bounce.InOut},x=e=>"function"==typeof e?e:h[e],I=(e=>(e.LOCAL="LOCAL",e.WORLD="WORLD",e))(I||{}),b=(e=>(e.SPHERE="SPHERE",e.CONE="CONE",e.BOX="BOX",e.CIRCLE="CIRCLE",e.RECTANGLE="RECTANGLE",e))(b||{}),A=(e=>(e.VOLUME="VOLUME",e.SHELL="SHELL",e.EDGE="EDGE",e))(A||{}),C=(e=>(e.LIFETIME="LIFETIME",e.FPS="FPS",e))(C||{}),P=(e=>(e.BEZIER="BEZIER",e.EASING="EASING",e))(P||{}),w=(e=>(e.BIRTH="BIRTH",e.DEATH="DEATH",e))(w||{}),T=(e=>(e.POINT="POINT",e.DIRECTIONAL="DIRECTIONAL",e))(T||{}),O=(e=>(e.POINTS="POINTS",e.INSTANCED="INSTANCED",e.TRAIL="TRAIL",e.MESH="MESH",e))(O||{}),S=(e=>(e.NONE="NONE",e.LINEAR="LINEAR",e.QUADRATIC="QUADRATIC",e))(S||{}),_=(e,t,n,r,{radius:i,radiusThickness:a,arc:o})=>{const s=Math.random()*(o/360),l=Math.random(),c=Math.random(),d=2*Math.PI*s,f=Math.acos(2*l-1),m=Math.sin(f),p=m*Math.cos(d),u=m*Math.sin(d),y=Math.cos(f),v=1-a;e.x=i*v*p+i*a*c*p,e.y=i*v*u+i*a*c*u,e.z=i*v*y+i*a*c*y,e.applyQuaternion(t);const g=1/e.length();n.set(e.x*g*r,e.y*g*r,e.z*g*r),n.applyQuaternion(t)},U=(t,n,r,i,{radius:a,radiusThickness:o,arc:s,angle:l=90})=>{const c=2*Math.PI*Math.random()*(s/360),d=Math.random(),f=Math.cos(c),m=Math.sin(c),p=1-o;t.x=a*p*f+a*o*d*f,t.y=a*p*m+a*o*d*m,t.z=0,t.applyQuaternion(n);const u=t.length(),y=Math.abs(u/a*e.MathUtils.degToRad(l)),v=Math.sin(y),g=1/u;r.set(t.x*v*g*i,t.y*v*g*i,Math.cos(y)*i),r.applyQuaternion(n)},L=(e,t,n,r,{scale:i,emitFrom:a})=>{const o=i;switch(a){case"VOLUME":e.x=Math.random()*o.x-o.x/2,e.y=Math.random()*o.y-o.y/2,e.z=Math.random()*o.z-o.z/2;break;case"SHELL":const t=Math.floor(6*Math.random()),n=t%3,r=[];r[n]=t>2?1:0,r[(n+1)%3]=Math.random(),r[(n+2)%3]=Math.random(),e.x=r[0]*o.x-o.x/2,e.y=r[1]*o.y-o.y/2,e.z=r[2]*o.z-o.z/2;break;case"EDGE":const i=Math.floor(6*Math.random()),a=i%3,s=Math.floor(4*Math.random()),l=[];l[a]=i>2?1:0,l[(a+1)%3]=s<2?Math.random():s-2,l[(a+2)%3]=s<2?s:Math.random(),e.x=l[0]*o.x-o.x/2,e.y=l[1]*o.y-o.y/2,e.z=l[2]*o.z-o.z/2}e.applyQuaternion(t),n.set(0,0,r),n.applyQuaternion(t)},E=(e,t,n,r,{radius:i,radiusThickness:a,arc:o})=>{const s=2*Math.PI*Math.random()*(o/360),l=Math.random(),c=Math.cos(s),d=Math.sin(s),f=1-a;e.x=i*f*c+i*a*l*c,e.y=i*f*d+i*a*l*d,e.z=0,e.applyQuaternion(t);const m=1/e.length();n.set(e.x*m*r,e.y*m*r,0),n.applyQuaternion(t)},z=(t,n,r,i,{rotation:a,scale:o})=>{const s=o,l=a,c=Math.random()*s.x-s.x/2,d=Math.random()*s.y-s.y/2,f=e.MathUtils.degToRad(l.x),m=e.MathUtils.degToRad(l.y);t.x=c*Math.cos(m),t.y=d*Math.cos(f),t.z=c*Math.sin(m)-d*Math.sin(f),t.applyQuaternion(n),r.set(0,0,i),r.applyQuaternion(n)},N=()=>{try{const t=document.createElement("canvas");t.width=1,t.height=1;const n=t.getContext("2d");if(n){n.fillStyle="white",n.fillRect(0,0,1,1);const r=new e.CanvasTexture(t);return r.needsUpdate=!0,r}return null}catch{return null}},M=()=>{try{const t=document.createElement("canvas"),n=64;t.width=n,t.height=n;const r=t.getContext("2d");if(r){const i=n/2,a=n/2,o=n/2-2;r.beginPath(),r.arc(i,a,o,0,2*Math.PI,!1),r.fillStyle="white",r.fill();const s=new e.CanvasTexture(t);return s.needsUpdate=!0,s}return null}catch(e){return null}},F=e=>"number"!=typeof e&&"type"in e,D=(e,t)=>{if("BEZIER"===t.type)return p(e,t.bezierPoints);if("EASING"===t.type)return t.curveFunction;throw new Error(`Unsupported value type: ${t}`)},V=(t,n,r=0)=>{if("number"==typeof n)return n;if("min"in n&&"max"in n)return n.min===n.max?n.min??0:e.MathUtils.randFloat(n.min??0,n.max??1);const i=n;return D(t,i)(r)*(i.scale??1)},R=new e.Vector3(0,0,0),B=new e.Euler,k=({delta:e,generalData:t,normalizedConfig:n,attributes:r,particleLifetimePercentage:i,particleIndex:a})=>{const{particleSystemId:o,startValues:s,lifetimeValues:l,linearVelocityData:c,orbitalVelocityData:d,noise:f}=t,m=3*a,p=r.position.array;if(c){const{speed:t,valueModifiers:n}=c[a],o=n.x?n.x(i):t.x,s=n.y?n.y(i):t.y,l=n.z?n.z(i):t.z;p[m]+=o*e,p[m+1]+=s*e,p[m+2]+=l*e,r.position.needsUpdate=!0}if(d){const{speed:t,positionOffset:n,valueModifiers:o}=d[a];p[m]-=n.x,p[m+1]-=n.y,p[m+2]-=n.z;const s=o.x?o.x(i):t.x,l=o.y?o.y(i):t.y,c=o.z?o.z(i):t.z;B.set(s*e,c*e,l*e),n.applyEuler(B),p[m]+=n.x,p[m+1]+=n.y,p[m+2]+=n.z,r.position.needsUpdate=!0}if(n.sizeOverLifetime.isActive){const e=V(o,n.sizeOverLifetime.lifetimeCurve,i);r.size.array[a]=s.startSize[a]*e,r.size.needsUpdate=!0}if(n.opacityOverLifetime.isActive){const e=V(o,n.opacityOverLifetime.lifetimeCurve,i);r.colorA.array[a]=s.startOpacity[a]*e,r.colorA.needsUpdate=!0}if(n.colorOverLifetime.isActive){const e=V(o,n.colorOverLifetime.r,i),t=V(o,n.colorOverLifetime.g,i),l=V(o,n.colorOverLifetime.b,i);r.colorR.array[a]=s.startColorR[a]*e,r.colorG.array[a]=s.startColorG[a]*t,r.colorB.array[a]=s.startColorB[a]*l,r.colorR.needsUpdate=!0,r.colorG.needsUpdate=!0,r.colorB.needsUpdate=!0}if(l.rotationOverLifetime&&(r.rotation.array[a]+=l.rotationOverLifetime[a]*e*.02,r.rotation.needsUpdate=!0),f.isActive){const{sampler:e,strength:t,noisePower:n,offsets:o,positionAmount:s,rotationAmount:l,sizeAmount:c}=f;let d;const u=10*(i+(o?o[a]:0))*t;R.set(u,0,0),d=e.get3(R),p[m]+=d*n*s,0!==l&&(r.rotation.array[a]+=d*n*l,r.rotation.needsUpdate=!0),0!==c&&(r.size.array[a]+=d*n*c,r.size.needsUpdate=!0),R.set(u,u,0),d=e.get3(R),p[m+1]+=d*n*s,R.set(u,u,u),d=e.get3(R),p[m+2]+=d*n*s,r.position.needsUpdate=!0}if(r.quat){const e=.5*r.rotation.array[a],t=4*a;r.quat.array[t]=0,r.quat.array[t+1]=0,r.quat.array[t+2]=Math.sin(e),r.quat.array[t+3]=Math.cos(e),r.quat.needsUpdate=!0}},Q={};((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})})(Q,{deepMerge:()=>j,getObjectDiff:()=>q,patchObject:()=>H});var H=(e,t,n={skippedProperties:[],applyToFirstObject:!1})=>{const r={};return Object.keys(e).forEach(i=>{n.skippedProperties&&n.skippedProperties.includes(i)||("object"==typeof e[i]&&e[i]&&t[i]&&!Array.isArray(e[i])?r[i]=H(e[i],t[i],n):(r[i]=0===t[i]?0:!1!==t[i]&&(t[i]||e[i]),n.applyToFirstObject&&(e[i]=r[i])))}),r},j=(e,t,n={skippedProperties:[],applyToFirstObject:!1})=>{const r={};return Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})])).forEach(i=>{n.skippedProperties&&n.skippedProperties.includes(i)||("object"==typeof e?.[i]&&e?.[i]&&t?.[i]&&!Array.isArray(e[i])?r[i]=j(e[i],t[i],n):(r[i]=0===t?.[i]?0:!1!==t?.[i]&&(t?.[i]||e?.[i]),n.applyToFirstObject&&(e[i]=r[i])))}),r},q=(e,t,n={skippedProperties:[]})=>{const r={};return Object.keys(e).forEach(i=>{if(!n.skippedProperties||!n.skippedProperties.includes(i))if("object"==typeof e[i]&&e[i]&&t[i]&&!Array.isArray(e[i])){const a=q(e[i],t[i],n);Object.keys(a).length>0&&(r[i]=a)}else{const n=0===t[i]?0:t[i]||e[i];n!==e[i]&&(r[i]=n)}}),r},G=function(){};G.prototype.load=G,G.prototype.parse=G;var W=G;Array.from({length:3},()=>({loader:new W,isUsed:!1})),Array.from({length:3},()=>({loader:new e.TextureLoader,isUsed:!1})),Array.from({length:3},()=>({loader:new e.AudioLoader,isUsed:!1}));var Z=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],X=class{constructor(t){const n=[new e.Vector3(1,1,0),new e.Vector3(-1,1,0),new e.Vector3(1,-1,0),new e.Vector3(-1,-1,0),new e.Vector3(1,0,1),new e.Vector3(-1,0,1),new e.Vector3(1,0,-1),new e.Vector3(-1,0,-1),new e.Vector3(0,1,1),new e.Vector3(0,-1,1),new e.Vector3(0,1,-1),new e.Vector3(0,-1,-1)];var r=new Array(512),i=new Array(512);t||(t=1),t*=65536,(t=Math.floor(t))<256&&(t|=t<<8);for(var a=0;a<256;a++){var o;o=1&a?Z[a]^255&t:Z[a]^t>>8&255,r[a]=r[a+256]=o,i[a]=i[a+256]=n[o%12]}this._seed=t,this._offsetMatrix=[new e.Vector3(0,0,0),new e.Vector3(0,0,1),new e.Vector3(0,1,0),new e.Vector3(0,1,1),new e.Vector3(1,0,0),new e.Vector3(1,0,1),new e.Vector3(1,1,0),new e.Vector3(1,1,1)],this.shaderChunk={defines:"",header:'#define GLSLIFY 1\n// From https://github.com/hughsk/glsl-noise/blob/master/periodic/2d.glsl\n\n//\n// GLSL textureless classic 2D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\n\nvec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }\n\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nvec2 fade(vec2 t) { return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); }\n\nfloat map(float value, float min1, float max1, float min2, float max2) {\n return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin(vec2 P) {\n\n vec2 rep = vec2(255.0, 255.0);\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n vec4 gy = abs(gx) - 0.5;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x, gy.x);\n vec2 g10 = vec2(gx.y, gy.y);\n vec2 g01 = vec2(gx.z, gy.z);\n vec2 g11 = vec2(gx.w, gy.w);\n\n vec4 norm = taylorInvSqrt(\n vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return map(2.3 * n_xy, -1.0, 1.0, 0.0, 1.0);\n}\n\nfloat fbm(vec2 pos, vec4 props) {\n float persistance = props.x;\n float lacunarity = props.y;\n float redistribution = props.z;\n int octaves = int(props.w);\n\n float result = 0.0;\n float amplitude = 1.0;\n float frequency = 1.0;\n float maximum = amplitude;\n\n for (int i = 0; i < 2; i++) {\n\n vec2 p = pos.xy * frequency;\n\n float noiseVal = perlin(p);\n result += noiseVal * amplitude;\n\n frequency *= lacunarity;\n amplitude *= persistance;\n maximum += amplitude;\n }\n\n float redistributed = pow(result, redistribution);\n return redistributed / maximum;\n}\n',main:"",uniforms:[{three_noise_seed:this._seed}]},this.perm=r,this.gradP=i}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,n){return(1-n)*e+n*t}_gradient(t){return t instanceof e.Vector3?t.x+this.perm[t.y+this.perm[t.z]]:t.x+this.perm[t.y]}static map(e,t,n,r,i){return(e-t)*(i-r)/(n-t)+r}get2(t){void 0!==t.z&&(t=new e.Vector2(t.x,t.y));const n=new e.Vector2(Math.floor(t.x),Math.floor(t.y));t.sub(n),n.x&=255,n.y&=255;const r=[];for(let i=0;i<4;i++){const a=this._offsetMatrix[2*i],o=new e.Vector2(a.x,a.y),s=this.gradP[this._gradient((new e.Vector2).addVectors(n,o))],l=new e.Vector2(s.x,s.y),c=(new e.Vector2).subVectors(t,o);r.push(l.dot(c))}const i=this._fade(t.x),a=this._fade(t.y);return this._lerp(this._lerp(r[0],r[2],i),this._lerp(r[1],r[3],i),a)}get3(t){if(void 0===t.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const n=new e.Vector3(Math.floor(t.x),Math.floor(t.y),Math.floor(t.z));t.sub(n),n.x&=255,n.y&=255,n.z&=255;const r=[];for(let i=0;i<8;i++){const a=this._offsetMatrix[i],o=this.gradP[this._gradient((new e.Vector3).addVectors(n,a))],s=(new e.Vector3).subVectors(t,a);r.push(o.dot(s))}const i=this._fade(t.x),a=this._fade(t.y),o=this._fade(t.z);return this._lerp(this._lerp(this._lerp(r[0],r[4],i),this._lerp(r[1],r[5],i),o),this._lerp(this._lerp(r[2],r[6],i),this._lerp(r[3],r[7],i),o),a)}},Y=class{constructor(e){const{seed:t,scale:n,persistance:r,lacunarity:i,octaves:a,redistribution:o}=e;this._noise=new X(t),this._scale=n||1,this._persistance=r||.5,this._lacunarity=i||2,this._octaves=a||6,this._redistribution=o||1}get2(t){let n=0,r=1,i=1,a=r,o=this._noise.get2.bind(this._noise);for(let s=0;s<this._octaves;s++){n+=o(new e.Vector2(t.x*this._scale*i,t.y*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,a+=r}return Math.pow(n,this._redistribution)/a}get3(t){let n=0,r=1,i=1,a=r,o=this._noise.get3.bind(this._noise);for(let s=0;s<this._octaves;s++){n+=o(new e.Vector3(t.x*this._scale*i,t.y*this._scale*i,t.z*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,a+=r}return Math.pow(n,this._redistribution)/a}},K=new e.Vector3,$=(e,t,n,r,i,a)=>{K.set(e.position.x-r[i],e.position.y-r[i+1],e.position.z-r[i+2]);const o=K.length();if(o<1e-4)return;if(e.range!==1/0&&o>e.range)return;K.divideScalar(o);let s=1;if(e.range!==1/0){const t=o/e.range;switch(e.falloff){case"LINEAR":s=1-t;break;case"QUADRATIC":s=1-t*t;break;case"NONE":s=1}}const l=t*s*a;n.x+=K.x*l,n.y+=K.y*l,n.z+=K.z*l},J=(e,t,n,r)=>{const i=t*r;n.x+=e.direction.x*i,n.y+=e.direction.y*i,n.z+=e.direction.z*i},ee=({particleSystemId:e,forceFields:t,velocity:n,positionArr:r,positionIndex:i,delta:a,systemLifetimePercentage:o})=>{for(let s=0;s<t.length;s++){const l=t[s];if(!l.isActive)continue;const c=V(e,l.strength,o);0!==c&&("POINT"===l.type?$(l,c,n,r,i,a):"DIRECTIONAL"===l.type&&J(l,c,n,a))}},te=(e,t)=>{if(!e)return t;const n=e;return!n.type&&Array.isArray(n.bezierPoints)?{type:"BEZIER",...n}:e},ne=0,re=[],ie=new e.Vector3,ae=new e.Vector3,oe=new e.Vector3,se=new e.Vector3,le=new e.Quaternion,ce=[];new e.Vector3,new e.Vector3,new e.Vector3;var de={x:0,y:0,z:0},fe={x:0,y:0,z:0},me={delta:0,generalData:null,normalizedConfig:null,attributes:null,particleLifetimePercentage:0,particleIndex:0},pe=(t,n)=>t?new e.Vector3(t.x??0,t.y??0,t.z??0):n.clone(),ue=t=>(t??[]).map(t=>({isActive:t.isActive??!0,type:t.type??"POINT",position:pe(t.position,new e.Vector3(0,0,0)),direction:pe(t.direction,new e.Vector3(0,1,0)).normalize(),strength:t.strength??1,range:Math.max(0,t.range??1/0),falloff:t.falloff??"LINEAR"})),ye={"THREE.NoBlending":e.NoBlending,"THREE.NormalBlending":e.NormalBlending,"THREE.AdditiveBlending":e.AdditiveBlending,"THREE.SubtractiveBlending":e.SubtractiveBlending,"THREE.MultiplyBlending":e.MultiplyBlending},ve=()=>JSON.parse(JSON.stringify(ge)),ge={transform:{position:new e.Vector3,rotation:new e.Vector3,scale:new e.Vector3(1,1,1)},duration:5,looping:!0,startDelay:0,startLifetime:5,startSpeed:1,startSize:1,startOpacity:1,startRotation:0,startColor:{min:{r:1,g:1,b:1},max:{r:1,g:1,b:1}},gravity:0,simulationSpace:"LOCAL",maxParticles:100,emission:{rateOverTime:10,rateOverDistance:0,bursts:[]},shape:{shape:"SPHERE",sphere:{radius:1,radiusThickness:1,arc:360},cone:{angle:25,radius:1,radiusThickness:1,arc:360},circle:{radius:1,radiusThickness:1,arc:360},rectangle:{rotation:{x:0,y:0},scale:{x:1,y:1}},box:{scale:{x:1,y:1,z:1},emitFrom:"VOLUME"}},map:void 0,renderer:{blending:e.NormalBlending,discardBackgroundColor:!1,backgroundColorTolerance:1,backgroundColor:{r:1,g:1,b:1},transparent:!0,depthTest:!0,depthWrite:!1,softParticles:{enabled:!1,intensity:1}},velocityOverLifetime:{isActive:!1,linear:{x:0,y:0,z:0},orbital:{x:0,y:0,z:0}},sizeOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},colorOverLifetime:{isActive:!1,r:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]},g:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]},b:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]}},opacityOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},rotationOverLifetime:{isActive:!1,min:0,max:0},noise:{isActive:!1,useRandomOffset:!1,strength:1,frequency:.5,octaves:1,positionAmount:1,rotationAmount:0,sizeAmount:0},textureSheetAnimation:{tiles:new e.Vector2(1,1),timeMode:"LIFETIME",fps:30,startFrame:0},forceFields:[]},he=({geometry:t,propertyName:n,maxParticles:r,factory:i,instanced:a})=>{const o=new Float32Array(r);if("function"==typeof i)for(let e=0;e<r;e++)o[e]=i(void 0,e);else o.fill(i);const s=a?new e.InstancedBufferAttribute(o,1):new e.BufferAttribute(o,1);t.setAttribute(n,s)},xe=(e,{shape:t,sphere:n,cone:r,circle:i,rectangle:a,box:o},s,l,c)=>{const d=V(e.particleSystemId,s,e.normalizedLifetimePercentage);switch(t){case"SPHERE":_(l,e.wrapperQuaternion,c,d,n);break;case"CONE":U(l,e.wrapperQuaternion,c,d,r);break;case"CIRCLE":E(l,e.wrapperQuaternion,c,d,i);break;case"RECTANGLE":z(l,e.wrapperQuaternion,c,d,a);break;case"BOX":L(l,e.wrapperQuaternion,c,d,o)}},Ie=(n=ge,r)=>{const i=r||Date.now(),a={particleSystemId:ne++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new e.Vector3(-99999),currentWorldPosition:new e.Vector3(-99999),worldPositionChange:new e.Vector3,worldQuaternion:new e.Quaternion,wrapperQuaternion:new e.Quaternion,lastWorldQuaternion:new e.Quaternion(-99999),worldEuler:new e.Euler,gravityVelocity:new e.Vector3(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,noisePower:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},o=Q.deepMerge(ge,n,{applyToFirstObject:!1,skippedProperties:[]});let s=o.map||("MESH"===o.renderer.rendererType?N():M());const{transform:l,duration:c,looping:d,startDelay:f,startLifetime:m,startSpeed:p,startSize:y,startRotation:v,startColor:g,startOpacity:h,gravity:x,simulationSpace:I,maxParticles:b,emission:A,shape:C,renderer:P,noise:w,velocityOverLifetime:T,onUpdate:O,onComplete:S,textureSheetAnimation:_,subEmitters:U,forceFields:L}=o,E=ue(L);"string"==typeof P?.blending&&(P.blending=ye[P.blending]);const z=Array.from({length:b},()=>new e.Vector3),R=Array.from({length:b},()=>new e.Vector3);a.creationTimes=Array.from({length:b},()=>0);const B=Array.from({length:b},(e,t)=>b-1-t);T.isActive&&(a.linearVelocityData=Array.from({length:b},()=>({speed:new e.Vector3(T.linear.x?V(a.particleSystemId,T.linear.x,0):0,T.linear.y?V(a.particleSystemId,T.linear.y,0):0,T.linear.z?V(a.particleSystemId,T.linear.z,0):0),valueModifiers:{x:F(T.linear.x||0)?D(a.particleSystemId,T.linear.x):void 0,y:F(T.linear.y||0)?D(a.particleSystemId,T.linear.y):void 0,z:F(T.linear.z||0)?D(a.particleSystemId,T.linear.z):void 0}})),a.orbitalVelocityData=Array.from({length:b},()=>({speed:new e.Vector3(T.orbital.x?V(a.particleSystemId,T.orbital.x,0):0,T.orbital.y?V(a.particleSystemId,T.orbital.y,0):0,T.orbital.z?V(a.particleSystemId,T.orbital.z,0):0),valueModifiers:{x:F(T.orbital.x||0)?D(a.particleSystemId,T.orbital.x):void 0,y:F(T.orbital.y||0)?D(a.particleSystemId,T.orbital.y):void 0,z:F(T.orbital.z||0)?D(a.particleSystemId,T.orbital.z):void 0},positionOffset:new e.Vector3})));["startSize","startOpacity"].forEach(e=>{a.startValues[e]=Array.from({length:b},()=>V(a.particleSystemId,o[e],0))}),a.startValues.startColorR=Array.from({length:b},()=>0),a.startValues.startColorG=Array.from({length:b},()=>0),a.startValues.startColorB=Array.from({length:b},()=>0);["rotationOverLifetime"].forEach(t=>{const n=o[t];n.isActive&&(a.lifetimeValues[t]=Array.from({length:b},()=>e.MathUtils.randFloat(n.min,n.max)))}),a.noise={isActive:w.isActive,strength:w.strength,noisePower:.15*w.strength,positionAmount:w.positionAmount,rotationAmount:w.rotationAmount,sizeAmount:w.sizeAmount,sampler:w.isActive?new Y({seed:Math.random(),scale:w.frequency,octaves:w.octaves}):void 0,offsets:w.useRandomOffset?Array.from({length:b},()=>100*Math.random()):void 0},A.bursts&&A.bursts.length>0&&(a.burstStates=A.bursts.map(()=>({cyclesExecuted:0,lastCycleTime:0,probabilityPassed:!1})));const H="TRAIL"===P.rendererType,j="MESH"===P.rendererType,q=!H&&!j&&"INSTANCED"===P.rendererType,G=q||j,W={type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:0,percentage:1}]},Z=H?{length:P.trail?.length??20,width:P.trail?.width??1,widthOverTrail:te(P.trail?.widthOverTrail,W),opacityOverTrail:te(P.trail?.opacityOverTrail,W),colorOverTrail:P.trail?.colorOverTrail,minVertexDistance:P.trail?.minVertexDistance??0,maxTime:P.trail?.maxTime??0,smoothing:P.trail?.smoothing??!1,smoothingSubdivisions:P.trail?.smoothingSubdivisions??3,twistPrevention:P.trail?.twistPrevention??!1,ribbonId:P.trail?.ribbonId}:void 0;if(H&&Z){const e=Z.length;a.trailLength=e,a.positionHistory=new Float32Array(b*e*3),a.positionHistoryIndex=new Uint16Array(b),a.positionHistoryCount=new Uint16Array(b),Z.minVertexDistance>0&&(a.trailLastSampledPosition=new Float32Array(3*b)),Z.maxTime>0&&(a.trailSampleTimes=new Float64Array(b*e)),Z.twistPrevention&&(a.trailPrevNormal=new Float32Array(3*b))}const X=e=>G?`instance${e.charAt(0).toUpperCase()}${e.slice(1)}`:e,K=G?"instanceOffset":"position",$=!(!P.softParticles?.enabled||!P.softParticles?.depthTexture),J={elapsed:{value:0},map:{value:s},tiles:{value:_.tiles},fps:{value:_.fps},useFPSForFrameIndex:{value:"FPS"===_.timeMode},backgroundColor:{value:P.backgroundColor},discardBackgroundColor:{value:P.discardBackgroundColor},backgroundColorTolerance:{value:P.backgroundColorTolerance},...q?{viewportHeight:{value:1}}:{},softParticlesEnabled:{value:$},softParticlesIntensity:{value:Math.max(P.softParticles?.intensity??1,.001)},sceneDepthTexture:{value:P.softParticles?.depthTexture??null},cameraNearFar:{value:new e.Vector2(.1,1e3)}},ee=new e.ShaderMaterial({uniforms:J,vertexShader:j?"\n attribute float instanceSize;\n attribute float instanceColorR;\n attribute float instanceColorG;\n attribute float instanceColorB;\n attribute float instanceColorA;\n attribute float instanceLifetime;\n attribute float instanceStartLifetime;\n attribute float instanceRotation;\n attribute float instanceStartFrame;\n attribute vec3 instanceOffset;\n attribute vec4 instanceQuat;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying vec3 vNormal;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n vec3 applyQuaternion(vec3 v, vec4 q) {\n vec3 t = 2.0 * cross(q.xyz, v);\n return v + q.w * t + cross(q.xyz, t);\n }\n\n void main()\n {\n vColor = vec4(instanceColorR, instanceColorG, instanceColorB, instanceColorA);\n vLifetime = instanceLifetime;\n vStartLifetime = instanceStartLifetime;\n vStartFrame = instanceStartFrame;\n vRotation = instanceRotation;\n\n // Apply quaternion rotation to the mesh vertex position\n vec3 rotatedPosition = applyQuaternion(position, instanceQuat);\n\n // Scale mesh by particle size\n vec3 scaledPosition = rotatedPosition * instanceSize;\n\n // Apply instance offset (particle world position)\n vec3 worldPos = scaledPosition + instanceOffset;\n\n vec4 mvPosition = modelViewMatrix * vec4(worldPos, 1.0);\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n // Transform normal by quaternion for lighting\n vNormal = normalize((modelViewMatrix * vec4(applyQuaternion(normal, instanceQuat), 0.0)).xyz);\n\n // Pass through UVs from the mesh geometry\n vUv = uv;\n\n #include <logdepthbuf_vertex>\n }\n":q?"\n attribute float instanceSize;\n attribute float instanceColorR;\n attribute float instanceColorG;\n attribute float instanceColorB;\n attribute float instanceColorA;\n attribute float instanceLifetime;\n attribute float instanceStartLifetime;\n attribute float instanceRotation;\n attribute float instanceStartFrame;\n attribute vec3 instanceOffset;\n\n uniform float viewportHeight;\n\n varying vec2 vUv;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vColor = vec4(instanceColorR, instanceColorG, instanceColorB, instanceColorA);\n vLifetime = instanceLifetime;\n vStartLifetime = instanceStartLifetime;\n vStartFrame = instanceStartFrame;\n vRotation = instanceRotation;\n\n vec4 mvPosition = modelViewMatrix * vec4(instanceOffset, 1.0);\n\n // Match the Points renderer pixel size: gl_PointSize = size * 100.0 / distance.\n // A view-space offset of d produces d * projectionMatrix[1][1] / w * (viewportHeight/2) pixels,\n // where w = -mvPosition.z for perspective. Solving for d so the result equals\n // the gl_PointSize pixel count:\n // d = size * 100.0 / distance\n // * (-mvPosition.z)\n // / (projectionMatrix[1][1] * viewportHeight * 0.5)\n // Since distance ≈ -mvPosition.z for view-aligned particles the two cancel out,\n // leaving a distance-independent expression. We keep them explicit so particles\n // off the viewing axis still scale correctly.\n float dist = length(mvPosition.xyz);\n float pointSizePx = instanceSize * 100.0 / dist;\n float perspectiveSize = pointSizePx * (-mvPosition.z)\n / (projectionMatrix[1][1] * viewportHeight * 0.5);\n\n // Billboard: offset quad vertices in view space (no rotation here;\n // rotation is applied to UVs in the fragment shader to keep behaviour\n // identical to the Points renderer).\n mvPosition.xy += position.xy * perspectiveSize;\n\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n // Pass UV for texture sampling (quad ranges from -0.5..0.5, map to 0..1).\n // Flip Y to match gl_PointCoord convention (Y runs top-to-bottom).\n vUv = vec2(position.x + 0.5, 0.5 - position.y);\n\n #include <logdepthbuf_vertex>\n }\n":"\n attribute float size;\n attribute float colorR;\n attribute float colorG;\n attribute float colorB;\n attribute float colorA;\n attribute float lifetime;\n attribute float startLifetime;\n attribute float rotation;\n attribute float startFrame;\n\n varying mat4 vPosition;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vColor = vec4(colorR, colorG, colorB, colorA);\n vLifetime = lifetime;\n vStartLifetime = startLifetime;\n vRotation = rotation;\n vStartFrame = startFrame;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_PointSize = size * (100.0 / length(mvPosition.xyz));\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:j?"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying vec3 vNormal;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n gl_FragColor = vColor;\n\n // Use mesh UVs directly for texture sampling\n vec2 uvPoint = vUv;\n\n // Apply texture sheet animation if tiles > 1x1\n if (tiles.x > 1.0 || tiles.y > 1.0) {\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n\n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n uvPoint = vec2(\n vUv.x / tiles.x + spriteXIndex / tiles.x,\n vUv.y / tiles.y + spriteYIndex / tiles.y\n );\n }\n\n vec4 texColor = texture2D(map, uvPoint);\n gl_FragColor = gl_FragColor * texColor;\n\n if (discardBackgroundColor && abs(length(texColor.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n // Simple directional lighting from camera direction\n float lightIntensity = 0.5 + 0.5 * max(dot(vNormal, vec3(0.0, 0.0, 1.0)), 0.0);\n gl_FragColor.rgb *= lightIntensity;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n #include <logdepthbuf_fragment>\n }\n":q?"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying vec2 vUv;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vStartFrame;\n varying float vRotation;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n gl_FragColor = vColor;\n\n // Rotate UV around centre (matches Points renderer behaviour)\n vec2 center = vec2(0.5);\n vec2 centeredPoint = vUv - center;\n\n mat2 rotation = mat2(\n cos(vRotation), sin(vRotation),\n -sin(vRotation), cos(vRotation)\n );\n\n centeredPoint = rotation * centeredPoint;\n vec2 centeredMiddlePoint = centeredPoint + center;\n\n // Discard pixels outside the inscribed circle\n float dist = distance(centeredMiddlePoint, center);\n if (dist > 0.5) discard;\n\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n\n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n vec2 uvPoint = vec2(\n centeredMiddlePoint.x / tiles.x + spriteXIndex / tiles.x,\n centeredMiddlePoint.y / tiles.y + spriteYIndex / tiles.y\n );\n\n vec4 rotatedTexture = texture2D(map, uvPoint);\n\n gl_FragColor = gl_FragColor * rotatedTexture;\n\n if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n #include <logdepthbuf_fragment>\n }\n":"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n gl_FragColor = vColor;\n float mid = 0.5;\n\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n \n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n vec2 frameUV = vec2(\n gl_PointCoord.x / tiles.x + spriteXIndex / tiles.x,\n gl_PointCoord.y / tiles.y + spriteYIndex / tiles.y);\n\n vec2 center = vec2(0.5, 0.5);\n vec2 centeredPoint = gl_PointCoord - center;\n\n mat2 rotation = mat2(\n cos(vRotation), sin(vRotation),\n -sin(vRotation), cos(vRotation)\n );\n\n centeredPoint = rotation * centeredPoint;\n vec2 centeredMiddlePoint = vec2(\n centeredPoint.x + center.x,\n centeredPoint.y + center.y\n );\n\n float dist = distance(centeredMiddlePoint, center);\n if (dist > 0.5) discard;\n\n vec2 uvPoint = vec2(\n centeredMiddlePoint.x / tiles.x + spriteXIndex / tiles.x,\n centeredMiddlePoint.y / tiles.y + spriteYIndex / tiles.y\n );\n\n vec4 rotatedTexture = texture2D(map, uvPoint);\n\n gl_FragColor = gl_FragColor * rotatedTexture;\n\n if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n #include <logdepthbuf_fragment>\n }\n",transparent:P.transparent,blending:P.blending,depthTest:P.depthTest,depthWrite:P.depthWrite});let ae;if(j){const t=P.mesh;if(!t?.geometry)throw new Error("RendererType.MESH requires a mesh configuration with a geometry. Set renderer.mesh.geometry to a THREE.BufferGeometry instance.");const n=new e.InstancedBufferGeometry,r=t.geometry,i=r.getAttribute("position");i&&n.setAttribute("position",i);const a=r.getAttribute("normal");a&&n.setAttribute("normal",a);const o=r.getAttribute("uv");o&&n.setAttribute("uv",o);const s=r.getIndex();s&&n.setIndex(s),n.instanceCount=b,ae=n}else if(q){const t=new e.InstancedBufferGeometry,n=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),r=new Uint16Array([0,1,2,0,2,3]);t.setAttribute("position",new e.BufferAttribute(n,3)),t.setIndex(new e.BufferAttribute(r,1)),t.instanceCount=b,ae=t}else ae=new e.BufferGeometry;for(let e=0;e<b;e++)xe(a,C,p,z[e],R[e]);const oe=new Float32Array(3*b);for(let e=0;e<b;e++)oe[3*e]=z[e].x,oe[3*e+1]=z[e].y,oe[3*e+2]=z[e].z;const se=G?new e.InstancedBufferAttribute(oe,3):new e.BufferAttribute(oe,3);ae.setAttribute(K,se),he({geometry:ae,propertyName:X("isActive"),maxParticles:b,factory:0,instanced:G}),he({geometry:ae,propertyName:X("lifetime"),maxParticles:b,factory:0,instanced:G}),he({geometry:ae,propertyName:X("startLifetime"),maxParticles:b,factory:()=>1e3*V(a.particleSystemId,m,0),instanced:G}),he({geometry:ae,propertyName:X("startFrame"),maxParticles:b,factory:()=>_.startFrame?V(a.particleSystemId,_.startFrame,0):0,instanced:G}),he({geometry:ae,propertyName:X("size"),maxParticles:b,factory:(e,t)=>a.startValues.startSize[t],instanced:G}),he({geometry:ae,propertyName:X("rotation"),maxParticles:b,factory:0,instanced:G});const le=Math.random();if(he({geometry:ae,propertyName:X("colorR"),maxParticles:b,factory:()=>g.min.r+le*(g.max.r-g.min.r),instanced:G}),he({geometry:ae,propertyName:X("colorG"),maxParticles:b,factory:()=>g.min.g+le*(g.max.g-g.min.g),instanced:G}),he({geometry:ae,propertyName:X("colorB"),maxParticles:b,factory:()=>g.min.b+le*(g.max.b-g.min.b),instanced:G}),he({geometry:ae,propertyName:X("colorA"),maxParticles:b,factory:0,instanced:G}),j){const t=new Float32Array(4*b);for(let e=0;e<b;e++)t[4*e+3]=1;ae.setAttribute(X("quat"),new e.InstancedBufferAttribute(t,4))}const ce=ae.attributes,de=ce[X("isActive")],fe=ce[X("colorR")],me=ce[X("colorG")],pe=ce[X("colorB")],ve=ce[X("colorA")],Ae=ce[X("startFrame")],Ce=ce[X("startLifetime")],Pe=ce[X("size")],we=ce[X("rotation")],Te=ce[X("lifetime")],Oe=ce[K],Se=j?ce[X("quat")]:void 0,_e=U??[],Ue=_e.filter(e=>"DEATH"===(e.trigger??"DEATH")),Le=_e.filter(e=>"BIRTH"===e.trigger),Ee=new Map;for(const e of _e)Ee.set(e,[]);const ze=t=>{for(let n=t.length-1;n>=0;n--){const r=t[n],i=r.instance instanceof e.Points||r.instance instanceof e.Mesh?r.instance:r.instance.children[0],a=i?.geometry?.attributes,o=a?a.isActive?.array??a.instanceIsActive?.array:void 0;if(!o){r.dispose(),t.splice(n,1);continue}let s=!1;for(let e=0;e<o.length;e++)if(o[e]){s=!0;break}s||(r.dispose(),t.splice(n,1))}},Ne=(t,n,r,i)=>{for(const a of t){const t=Ee.get(a),o=a.maxInstances??32;if(t.length>=o&&(ze(t),t.length>=o))continue;const s=a.inheritVelocity??0,l=Ie({...a.config,looping:!1,transform:{...a.config.transform,position:new e.Vector3(n.x,n.y,n.z)},renderer:{...a.config.renderer??{},...a.config.renderer?.rendererType||"MESH"===P.rendererType||"TRAIL"===P.rendererType?{}:{rendererType:P.rendererType}},...s>0?{startSpeed:("number"==typeof a.config.startSpeed?a.config.startSpeed:"object"==typeof a.config.startSpeed&&null!==a.config.startSpeed&&"min"in a.config.startSpeed?a.config.startSpeed.min??0:0)+r.length()*s}:{}},i),c=(We||je).parent;c&&c.add(l.instance),t.push(l)}};let Me,Fe,De,Ve,Re,Be,ke,Qe,He;if(H&&Z){const t=Z.length,n=2*t,r=b*n,i=6*(t-1),o=b*i;Fe=new e.BufferGeometry;const l=new Float32Array(3*r),c=new Float32Array(3*r),d=new Float32Array(r),f=new Float32Array(4*r),m=new Float32Array(r),p=new Float32Array(r),u=new Float32Array(2*r),y=new Uint32Array(o);for(let e=0;e<b;e++){const r=e*n,a=e*i;for(let e=0;e<t;e++)m[r+2*e]=-1,m[r+2*e+1]=1;for(let e=0;e<t-1;e++){const t=a+6*e,n=r+2*e;y[t]=n,y[t+1]=n+1,y[t+2]=n+2,y[t+3]=n+1,y[t+4]=n+3,y[t+5]=n+2}}De=new e.BufferAttribute(l,3),De.setUsage(e.DynamicDrawUsage);const v=new e.BufferAttribute(c,3);v.setUsage(e.DynamicDrawUsage),Ve=new e.BufferAttribute(d,1),Ve.setUsage(e.DynamicDrawUsage),Re=new e.BufferAttribute(f,4),Re.setUsage(e.DynamicDrawUsage);const g=new e.BufferAttribute(p,1);g.setUsage(e.DynamicDrawUsage);const h=new e.BufferAttribute(u,2);h.setUsage(e.DynamicDrawUsage),Be=new e.BufferAttribute(y,1),Fe.setAttribute("position",De),Fe.setAttribute("trailNext",v),Fe.setAttribute("trailAlpha",Ve),Fe.setAttribute("trailColor",Re),Fe.setAttribute("trailOffset",new e.BufferAttribute(m,1)),Fe.setAttribute("trailHalfWidth",g),Fe.setAttribute("trailUV",h),Fe.setIndex(Be);const x=new e.ShaderMaterial({uniforms:{map:{value:s},useMap:{value:!!s},discardBackgroundColor:{value:P.discardBackgroundColor},backgroundColor:{value:P.backgroundColor},backgroundColorTolerance:{value:P.backgroundColorTolerance},softParticlesEnabled:{value:$},softParticlesIntensity:{value:Math.max(P.softParticles?.intensity??1,.001)},sceneDepthTexture:{value:P.softParticles?.depthTexture??null},cameraNearFar:{value:new e.Vector2(.1,1e3)}},vertexShader:"\n attribute float trailAlpha;\n attribute vec4 trailColor;\n attribute float trailOffset;\n attribute float trailHalfWidth;\n attribute vec3 trailNext;\n attribute vec2 trailUV;\n\n varying float vAlpha;\n varying vec4 vColor;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vAlpha = trailAlpha;\n vColor = trailColor;\n vUv = trailUV;\n\n // Compute tangent from current position to next sample\n vec3 tangent = trailNext - position;\n float tangentLen = length(tangent);\n if (tangentLen < 0.0001) {\n tangent = vec3(0.0, 1.0, 0.0);\n } else {\n tangent = tangent / tangentLen;\n }\n\n // Billboard: perpendicular = cross(tangent, viewDirection)\n vec3 worldPos = (modelMatrix * vec4(position, 1.0)).xyz;\n vec3 viewDir = normalize(cameraPosition - worldPos);\n vec3 perp = cross(tangent, viewDir);\n float perpLen = length(perp);\n\n // When tangent is nearly parallel to view direction, the cross product\n // collapses and the ribbon becomes edge-on (invisible). Build a stable\n // fallback perpendicular from the camera's right axis — this keeps the\n // ribbon in screen-space and prevents it from flipping into an arbitrary\n // plane when viewed edge-on.\n vec3 camRight = vec3(viewMatrix[0][0], viewMatrix[1][0], viewMatrix[2][0]);\n vec3 fallbackPerp = normalize(camRight - tangent * dot(camRight, tangent));\n\n if (perpLen < 0.0001) {\n perp = fallbackPerp;\n } else {\n perp = perp / perpLen;\n // Smoothly blend toward the fallback when the billboard perp weakens.\n // The wide range (0..0.7) ensures a gradual transition so the ribbon\n // does not snap abruptly when rotating toward edge-on.\n float blendFactor = smoothstep(0.0, 0.7, perpLen);\n perp = normalize(mix(fallbackPerp, perp, blendFactor));\n }\n\n vec3 offsetPos = position + perp * trailOffset * trailHalfWidth;\n vec4 mvPosition = modelViewMatrix * vec4(offsetPos, 1.0);\n vViewZ = -mvPosition.z;\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:"\n uniform sampler2D map;\n uniform bool useMap;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n uniform bool softParticlesEnabled;\n uniform float softParticlesIntensity;\n uniform sampler2D sceneDepthTexture;\n uniform vec2 cameraNearFar;\n\n varying float vAlpha;\n varying vec4 vColor;\n varying vec2 vUv;\n varying float vViewZ;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n float linearizeDepth(float depthSample, float near, float far) {\n float z_ndc = 2.0 * depthSample - 1.0;\n return 2.0 * near * far / (far + near - z_ndc * (far - near));\n }\n\n void main()\n {\n // Soft edge: always fade near ribbon edges\n float edgeDist = 1.0 - abs(vUv.x * 2.0 - 1.0);\n float softEdge = smoothstep(0.0, 0.4, edgeDist);\n\n gl_FragColor = vColor;\n\n if (useMap) {\n // Use texture luminance as brightness modulation on top of soft edge\n vec4 texColor = texture2D(map, vUv);\n float texBrightness = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));\n gl_FragColor.rgb *= (0.5 + texBrightness * 0.5);\n gl_FragColor.a *= texColor.a;\n }\n\n gl_FragColor.a *= vAlpha * softEdge;\n\n if (gl_FragColor.a < 0.001) discard;\n\n if (softParticlesEnabled) {\n vec2 screenUV = gl_FragCoord.xy / vec2(textureSize(sceneDepthTexture, 0));\n float sceneDepthSample = texture2D(sceneDepthTexture, screenUV).r;\n float sceneDepthLinear = linearizeDepth(sceneDepthSample, cameraNearFar.x, cameraNearFar.y);\n float depthDiff = sceneDepthLinear - vViewZ;\n float softFade = smoothstep(0.0, softParticlesIntensity, depthDiff);\n gl_FragColor.a *= softFade;\n if (gl_FragColor.a < 0.001) discard;\n }\n\n if (discardBackgroundColor && abs(length(gl_FragColor.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n\n #include <logdepthbuf_fragment>\n }\n",transparent:P.transparent,blending:P.blending,depthTest:P.depthTest,depthWrite:P.depthWrite,side:e.DoubleSide});Me=new e.Mesh(Fe,x),Me.frustumCulled=!1;const I=new e.Vector3;Me.onBeforeRender=(e,t,n)=>{if(n.getWorldPosition(I),$&&n.isPerspectiveCamera){const e=n;x.uniforms.cameraNearFar.value.set(e.near,e.far)}},a.trailCameraPosition=I,ke=D(a.particleSystemId,Z.widthOverTrail),Qe=D(a.particleSystemId,Z.opacityOverTrail),Z.colorOverTrail?.isActive&&(He={r:D(a.particleSystemId,te(Z.colorOverTrail.r,W)),g:D(a.particleSystemId,te(Z.colorOverTrail.g,W)),b:D(a.particleSystemId,te(Z.colorOverTrail.b,W))})}let je=q||j?new e.Mesh(ae,ee):new e.Points(ae,ee);(q||$)&&(je.onBeforeRender=(t,n,r)=>{if(q){const n=t.getSize(new e.Vector2);J.viewportHeight.value=n.y*t.getPixelRatio()}if($&&r.isPerspectiveCamera){const e=r;J.cameraNearFar.value.set(e.near,e.far)}}),H&&Me&&(ee.visible=!1,je.add(Me)),je.position.copy(l.position),je.rotation.x=e.MathUtils.degToRad(l.rotation.x),je.rotation.y=e.MathUtils.degToRad(l.rotation.y),je.rotation.z=e.MathUtils.degToRad(l.rotation.z),je.scale.copy(l.scale);const qe={position:Oe,isActive:de,lifetime:Te,startLifetime:Ce,startFrame:Ae,size:Pe,rotation:we,colorR:fe,colorG:me,colorB:pe,colorA:ve,...j?{quat:Se}:{}},Ge=i+1e3*V(a.particleSystemId,f);let We;"WORLD"===o.simulationSpace&&(We=new t,We.add(je));const Ze=Ue.length>0?(e,t,n,r)=>{const i=3*e;ie.set(t[i],t[i+1],t[i+2]),Ne(Ue,ie,n,r)}:void 0,Xe=Le.length>0?(e,t,n,r)=>{const i=3*e;ie.set(t[i],t[i+1],t[i+2]),Ne(Le,ie,n,r)}:void 0,Ye={particleSystem:je,wrapper:We,mappedAttributes:qe,elapsedUniform:ee.uniforms.elapsed,generalData:a,onUpdate:O,onComplete:S,creationTime:Ge,lastEmissionTime:Ge,duration:c,looping:d,simulationSpace:I,gravity:x,normalizedForceFields:E,emission:A,normalizedConfig:o,iterationCount:0,velocities:R,freeList:B,deactivateParticle:e=>{de.array[e]=0,ve.array[e]=0,ve.needsUpdate=!0,B.push(e)},activateParticle:({particleIndex:t,activationTime:n,position:r})=>{if(de.array[t]=1,a.creationTimes[t]=n,a.positionHistoryCount){if(a.positionHistoryCount[t]=0,a.positionHistoryIndex[t]=0,a.trailLastSampledPosition){const e=3*t;a.trailLastSampledPosition[e]=0,a.trailLastSampledPosition[e+1]=0,a.trailLastSampledPosition[e+2]=0}if(a.trailPrevNormal){const e=3*t;a.trailPrevNormal[e]=0,a.trailPrevNormal[e+1]=0,a.trailPrevNormal[e+2]=0}}a.noise.offsets&&(a.noise.offsets[t]=100*Math.random());const i=Math.random(),s=o.startColor;if(fe.array[t]=s.min.r+i*(s.max.r-s.min.r),fe.needsUpdate=!0,me.array[t]=s.min.g+i*(s.max.g-s.min.g),me.needsUpdate=!0,pe.array[t]=s.min.b+i*(s.max.b-s.min.b),pe.needsUpdate=!0,a.startValues.startColorR[t]=fe.array[t],a.startValues.startColorG[t]=me.array[t],a.startValues.startColorB[t]=pe.array[t],Ae.array[t]=o.textureSheetAnimation.startFrame?V(a.particleSystemId,o.textureSheetAnimation.startFrame,0):0,Ae.needsUpdate=!0,Ce.array[t]=1e3*V(a.particleSystemId,o.startLifetime,a.normalizedLifetimePercentage),Ce.needsUpdate=!0,a.startValues.startSize[t]=V(a.particleSystemId,o.startSize,a.normalizedLifetimePercentage),Pe.array[t]=a.startValues.startSize[t],Pe.needsUpdate=!0,a.startValues.startOpacity[t]=V(a.particleSystemId,o.startOpacity,a.normalizedLifetimePercentage),ve.array[t]=a.startValues.startOpacity[t],ve.needsUpdate=!0,we.array[t]=V(a.particleSystemId,o.startRotation,a.normalizedLifetimePercentage),we.needsUpdate=!0,Se){const e=.5*we.array[t],n=4*t;Se.array[n]=0,Se.array[n+1]=0,Se.array[n+2]=Math.sin(e),Se.array[n+3]=Math.cos(e),Se.needsUpdate=!0}o.rotationOverLifetime.isActive&&(a.lifetimeValues.rotationOverLifetime[t]=e.MathUtils.randFloat(o.rotationOverLifetime.min,o.rotationOverLifetime.max)),xe(a,o.shape,o.startSpeed,z[t],R[t]);const l=Math.floor(3*t);Oe.array[l]=r.x+z[t].x,Oe.array[l+1]=r.y+z[t].y,Oe.array[l+2]=r.z+z[t].z,Oe.needsUpdate=!0,a.linearVelocityData&&a.linearVelocityData[t].speed.set(o.velocityOverLifetime.linear.x?V(a.particleSystemId,o.velocityOverLifetime.linear.x,0):0,o.velocityOverLifetime.linear.y?V(a.particleSystemId,o.velocityOverLifetime.linear.y,0):0,o.velocityOverLifetime.linear.z?V(a.particleSystemId,o.velocityOverLifetime.linear.z,0):0),a.orbitalVelocityData&&(a.orbitalVelocityData[t].speed.set(o.velocityOverLifetime.orbital.x?V(a.particleSystemId,o.velocityOverLifetime.orbital.x,0):0,o.velocityOverLifetime.orbital.y?V(a.particleSystemId,o.velocityOverLifetime.orbital.y,0):0,o.velocityOverLifetime.orbital.z?V(a.particleSystemId,o.velocityOverLifetime.orbital.z,0):0),a.orbitalVelocityData[t].positionOffset.set(z[t].x,z[t].y,z[t].z)),Te.array[t]=0,Te.needsUpdate=!0,k({delta:0,generalData:a,normalizedConfig:o,attributes:qe,particleLifetimePercentage:0,particleIndex:t})},onParticleDeath:Ze,onParticleBirth:Xe,...H?{trailMesh:Me,trailPositionAttr:De,trailAlphaAttr:Ve,trailColorAttr:Re,trailWidthCurveFn:ke,trailOpacityCurveFn:Qe,trailColorOverTrailFns:He,trailConfig:{length:Z.length,width:Z.width,minVertexDistance:Z.minVertexDistance,maxTime:Z.maxTime,smoothing:Z.smoothing,smoothingSubdivisions:Z.smoothingSubdivisions,twistPrevention:Z.twistPrevention,ribbonId:Z.ribbonId}}:{}};re.push(Ye);return{instance:We||je,resumeEmitter:()=>a.isEnabled=!0,pauseEmitter:()=>a.isEnabled=!1,dispose:()=>{for(const e of Ee.values()){for(const t of e)t.dispose();e.length=0}(e=>{re=re.filter(({particleSystem:t,wrapper:n,trailMesh:r,generalData:{particleSystemId:i}})=>t!==e&&n!==e||(u(i),r&&(r.geometry.dispose(),Array.isArray(r.material)?r.material.forEach(e=>e.dispose()):r.material.dispose(),r.parent&&r.parent.remove(r)),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),n?.parent&&n.parent.remove(n),!1))})(je)},update:e=>{be(Ye,e);for(const t of Ee.values())for(const n of t)n.update(e)},updateConfig:e=>{Q.deepMerge(Ye.normalizedConfig,e,{applyToFirstObject:!0,skippedProperties:[]});const t=Ye.normalizedConfig;if(void 0!==e.gravity&&(Ye.gravity=t.gravity,a.lastWorldQuaternion.x=-99999),void 0!==e.duration&&(Ye.duration=t.duration),void 0!==e.looping&&(Ye.looping=t.looping),void 0!==e.simulationSpace&&(Ye.simulationSpace=t.simulationSpace),void 0!==e.emission&&(Ye.emission=t.emission),void 0!==e.forceFields&&(Ye.normalizedForceFields=ue(t.forceFields)),void 0!==e.noise){const e=t.noise;a.noise={isActive:e.isActive,strength:e.strength,noisePower:.15*e.strength,positionAmount:e.positionAmount,rotationAmount:e.rotationAmount,sizeAmount:e.sizeAmount,sampler:e.isActive?new Y({seed:Math.random(),scale:e.frequency,octaves:e.octaves}):void 0,offsets:e.useRandomOffset?a.noise.offsets??Array.from({length:b},()=>100*Math.random()):void 0}}}}},be=(t,{now:n,delta:r,elapsed:i})=>{const{onUpdate:a,generalData:o,onComplete:s,particleSystem:l,wrapper:c,elapsedUniform:d,creationTime:f,lastEmissionTime:m,duration:p,looping:u,emission:y,normalizedConfig:v,iterationCount:g,velocities:h,freeList:x,deactivateParticle:I,activateParticle:b,simulationSpace:A,gravity:C,normalizedForceFields:P,onParticleDeath:w,onParticleBirth:T,mappedAttributes:O}=t,S=P.length>0,_=n-f,U=_%(1e3*p);o.normalizedLifetimePercentage=Math.max(Math.min(U/(1e3*p),1),0);const{lastWorldPosition:L,currentWorldPosition:E,worldPositionChange:z,lastWorldQuaternion:N,worldQuaternion:M,worldEuler:F,gravityVelocity:D,isEnabled:R}=o;if(c?.parent&&o.wrapperQuaternion.copy(c.parent.quaternion),ae.copy(L),d.value=i,l.getWorldPosition(E),-99999!==L.x&&z.set(E.x-L.x,E.y-L.y,E.z-L.z),R&&(o.distanceFromLastEmitByDistance+=z.length()),l.getWorldPosition(L),l.getWorldQuaternion(M),-99999!==N.x&&N.x===M.x&&N.y===M.y&&N.z===M.z||(F.setFromQuaternion(M),N.copy(M),D.set(L.x,L.y+C,L.z),l.worldToLocal(D)),S){le.copy(M).invert(),ce.length=P.length;for(let t=0;t<P.length;t++){const n=P[t];let r=ce[t];r||(r={isActive:!0,type:"POINT",position:new e.Vector3,direction:new e.Vector3,strength:0,range:0,falloff:"LINEAR"},ce[t]=r),r.isActive=n.isActive,r.type=n.type,r.strength=n.strength,r.range=n.range,r.falloff=n.falloff,oe.copy(n.position),l.worldToLocal(oe),r.position.copy(oe),se.copy(n.direction),se.applyQuaternion(le),r.direction.copy(se)}}const B=o.creationTimes,Q=O.isActive.array,H=O.startLifetime.array,j=O.position.array,q=O.lifetime.array,G=B.length;let W=!1,Z=!1;me.delta=r,me.generalData=o,me.normalizedConfig=v,me.attributes=O;for(let e=0;e<G;e++)if(Q[e]){const t=n-B[e];if(t>H[e])w&&w(e,j,h[e],n),I(e);else{const n=h[e];if(n.x-=D.x*r,n.y-=D.y*r,n.z-=D.z*r,S&&ee({particleSystemId:o.particleSystemId,forceFields:ce,velocity:n,positionArr:j,positionIndex:3*e,delta:r,systemLifetimePercentage:o.normalizedLifetimePercentage}),0!==C||0!==n.x||0!==n.y||0!==n.z||0!==z.x||0!==z.y||0!==z.z){const t=3*e;"WORLD"===A&&(j[t]-=z.x,j[t+1]-=z.y,j[t+2]-=z.z),j[t]+=n.x*r,j[t+1]+=n.y*r,j[t+2]+=n.z*r,W=!0}q[e]=t,Z=!0,me.particleLifetimePercentage=t/H[e],me.particleIndex=e,k(me)}}if(W&&(O.position.needsUpdate=!0),Z&&(O.lifetime.needsUpdate=!0),R&&(u||_<1e3*p)){const e=n-m,s=y.rateOverTime?Math.floor(V(o.particleSystemId,y.rateOverTime,o.normalizedLifetimePercentage)*(e/1e3)):0,c=y.rateOverDistance?V(o.particleSystemId,y.rateOverDistance,o.normalizedLifetimePercentage):0,d=c>0&&o.distanceFromLastEmitByDistance>0?Math.floor(o.distanceFromLastEmitByDistance/(1/c)):0,f=d>0;f&&(de.x=(E.x-ae.x)/d,de.y=(E.y-ae.y)/d,de.z=(E.z-ae.z)/d);let p=s+d;if(c>0&&d>=1&&(o.distanceFromLastEmitByDistance=0),y.bursts&&o.burstStates){const e=y.bursts,t=o.burstStates,n=U;for(let r=0;r<e.length;r++){const i=e[r],a=t[r],s=1e3*i.time,l=i.cycles??1,c=1e3*(i.interval??0),d=i.probability??1;if(u&&n<s&&a.cyclesExecuted>0&&(a.cyclesExecuted=0,a.lastCycleTime=0,a.probabilityPassed=!1),a.cyclesExecuted>=l)continue;if(n>=s+a.cyclesExecuted*c){if(0===a.cyclesExecuted&&(a.probabilityPassed=Math.random()<d),a.probabilityPassed){p+=Math.floor(V(o.particleSystemId,i.count,o.normalizedLifetimePercentage))}a.cyclesExecuted++,a.lastCycleTime=n}}}if(p>0){let e=0;for(let r=0;r<p&&0!==x.length;r++){const r=x.pop();fe.x=0,fe.y=0,fe.z=0,f&&e<d&&(fe.x=de.x*e,fe.y=de.y*e,fe.z=de.z*e,e++),b({particleIndex:r,activationTime:n,position:fe}),T&&T(r,O.position.array,h[r],n),t.lastEmissionTime=n}}a&&a({particleSystem:l,delta:r,elapsed:i,lifetime:_,normalizedLifetime:U,iterationCount:g+1})}else s&&s({particleSystem:l});t.trailMesh&&Ee(t,n)},Ae=(e,t,n,r,i,a,o,s,l,c,d,f,m,p,u)=>{const y=u*u,v=y*u;e[t]=.5*(2*a+(-n+l)*u+(2*n-5*a+4*l-f)*y+(3*a-n-3*l+f)*v),e[t+1]=.5*(2*o+(-r+c)*u+(2*r-5*o+4*c-m)*y+(3*o-r-3*c+m)*v),e[t+2]=.5*(2*s+(-i+d)*u+(2*i-5*s+4*d-p)*y+(3*s-i-3*d+p)*v)},Ce=(e,t,n,r,i,a,o,s,l,c,d,f,m)=>{i[e]=d,i[e+1]=f,i[e+2]=m,i[e+3]=d,i[e+4]=f,i[e+5]=m,a[e]=d,a[e+1]=f,a[e+2]=m,a[e+3]=d,a[e+4]=f,a[e+5]=m,o[n]=0,o[n+1]=0,s[r]=0,s[r+1]=0,s[r+2]=0,s[r+3]=0,l[n]=0,l[n+1]=0,c[t]=0,c[t+1]=0,c[t+2]=0,c[t+3]=0,c[t+4]=0,c[t+5]=0,c[t+6]=0,c[t+7]=0},Pe=(e,t,n,r,i,a,o,s,l,c,d,f,m,p,u,y,v,g,h,x,I,b,A)=>{g[e]=i,g[e+1]=a,g[e+2]=o,g[e+3]=i,g[e+4]=a,g[e+5]=o,h[e]=s,h[e+1]=l,h[e+2]=c,h[e+3]=s,h[e+4]=l,h[e+5]=c,x[n]=d,x[n+1]=d,I[r]=0,I[r+1]=f,I[r+2]=1,I[r+3]=f,b[n]=m,b[n+1]=m,A[t]=p,A[t+1]=u,A[t+2]=y,A[t+3]=v,A[t+4]=p,A[t+5]=u,A[t+6]=y,A[t+7]=v},we=null,Te=0,Oe=null,Se=0,_e=null,Ue=0,Le=0,Ee=(e,t)=>{const{generalData:n,trailPositionAttr:r,trailAlphaAttr:i,trailColorAttr:a,trailWidthCurveFn:o,trailOpacityCurveFn:s,trailColorOverTrailFns:l,trailConfig:c,mappedAttributes:d}=e;if(!(r&&i&&a&&o&&s&&c&&n.positionHistory&&n.positionHistoryIndex&&n.positionHistoryCount))return;const f=c.length,m=n.positionHistory,p=n.positionHistoryIndex,u=n.positionHistoryCount,y=n.trailSampleTimes,v=n.trailLastSampledPosition,g=n.trailPrevNormal,h=c.minVertexDistance,x=h*h,I=c.maxTime,b=1e3*I,A=c.smoothing,C=c.smoothingSubdivisions,P=c.twistPrevention,w=c.ribbonId,T=d.isActive.array,O=d.position.array,S=d.colorR.array,_=d.colorG.array,U=d.colorB.array,L=d.colorA.array,E=r.array,z=i.array,N=a.array,M=e.trailMesh,F=M.geometry.getAttribute("trailNext").array,D=M.geometry.getAttribute("trailUV").array,V=M.geometry.getAttribute("trailHalfWidth").array,R=2*f,B=n.creationTimes.length;let k=!1;const Q=void 0!==w;let H=-1;if(Q){(!_e||Ue<B)&&(_e=new Uint16Array(B),Ue=B),Le=0;for(let e=0;e<B;e++)T[e]&&(_e[Le++]=e);for(let e=1;e<Le;e++){const t=_e[e],r=n.creationTimes[t];let i=e-1;for(;i>=0&&n.creationTimes[_e[i]]>r;)_e[i+1]=_e[i],i--;_e[i+1]=t}Le>0&&(H=_e[0])}for(let e=0;e<B;e++){const n=e*R;if(T[e]){if(Q&&Le>=2&&e!==H){const n=3*e,r=O[n],i=O[n+1],a=O[n+2],o=3*(e*f+p[e]);m[o]=r,m[o+1]=i,m[o+2]=a,y&&(y[e*f+p[e]]=t),p[e]=(p[e]+1)%f,u[e]<f&&u[e]++;continue}k=!0;const r=3*e,i=O[r],a=O[r+1],d=O[r+2];let w=!0;if(h>0&&v&&u[e]>0){const t=3*e,n=i-v[t],r=a-v[t+1],o=d-v[t+2];n*n+r*r+o*o<x&&(w=!1)}if(w){const n=3*(e*f+p[e]);if(m[n]=i,m[n+1]=a,m[n+2]=d,y&&(y[e*f+p[e]]=t),p[e]=(p[e]+1)%f,u[e]<f&&u[e]++,v){const t=3*e;v[t]=i,v[t+1]=a,v[t+2]=d}}let T=u[e],M=T;if(I>0&&y&&T>0){const n=e*f;M=0;for(let r=0;r<T;r++){if(!(t-y[n+(p[e]-1-r+2*f)%f]<=b))break;M++}}const R=M,B=c.width,j=S[e],q=_[e],G=U[e],W=L[e],Z=e*f*3,X=3*R;(!we||Te<X)&&(we=new Float32Array(X),Te=X);const Y=we;for(let t=0;t<R;t++){const n=(p[e]-1-t+2*f)%f*3+Z;Y[3*t]=m[n],Y[3*t+1]=m[n+1],Y[3*t+2]=m[n+2]}let K,$;if(A&&R>=3){const e=R-1;$=e*C+1;const t=3*$;(!Oe||Se<t)&&(Oe=new Float32Array(t),Se=t),K=Oe;for(let t=0;t<e;t++){const e=Math.max(0,t-1),n=t,r=Math.min(R-1,t+1),i=Math.min(R-1,t+2),a=Y[3*e],o=Y[3*e+1],s=Y[3*e+2],l=Y[3*n],c=Y[3*n+1],d=Y[3*n+2],f=Y[3*r],m=Y[3*r+1],p=Y[3*r+2],u=Y[3*i],y=Y[3*i+1],v=Y[3*i+2];for(let e=0;e<C;e++){Ae(K,3*(t*C+e),a,o,s,l,c,d,f,m,p,u,y,v,e/C)}}const n=3*($-1);K[n]=Y[3*(R-1)],K[n+1]=Y[3*(R-1)+1],K[n+2]=Y[3*(R-1)+2]}else K=Y,$=R;if($>f&&($=f),A&&$>=2){const e=1e-8;for(let t=1;t<$;t++){const n=3*(t-1),r=3*t,i=K[r]-K[n],a=K[r+1]-K[n+1],o=K[r+2]-K[n+2];i*i+a*a+o*o<e&&(K[r]=K[n],K[r+1]=K[n+1],K[r+2]=K[n+2])}}for(let r=0;r<f;r++){const c=3*(n+2*r),m=4*(n+2*r),u=n+2*r,v=2*(n+2*r);if(r>=$){Ce(c,m,u,v,E,F,V,D,z,N,i,a,d);continue}const g=K[3*r],h=K[3*r+1],x=K[3*r+2];let C,P,w;if(r>0&&r<$-1){const e=K[3*(r-1)],t=K[3*(r-1)+1],n=K[3*(r-1)+2],i=K[3*(r+1)]-e,a=K[3*(r+1)+1]-t,o=K[3*(r+1)+2]-n,s=Math.sqrt(i*i+a*a+o*o);s>1e-4?(C=g+i/s,P=h+a/s,w=x+o/s):(C=K[3*(r+1)],P=K[3*(r+1)+1],w=K[3*(r+1)+2])}else r<$-1?(C=K[3*(r+1)],P=K[3*(r+1)+1],w=K[3*(r+1)+2]):(C=g,P=h+.001,w=x);const O=$>1?r/($-1):0;let S=1;if(I>0&&y&&M>0){const n=A?Math.min(Math.floor(r/Math.max($-1,1)*(T-1)),T-1):Math.min(r,T-1),i=t-y[e*f+(p[e]-1-n+2*f)%f];S=1-Math.min(i/b,1)}const _=B*o(O)*.5,U=W*s(O)*S,L=l?j*l.r(O):j,R=l?q*l.g(O):q,k=l?G*l.b(O):G;Pe(c,m,u,v,g,h,x,C,P,w,_,O,U,L,R,k,W,E,F,V,D,z,N)}if(P&&g&&$>=2){const t=3*e,r=K[3]-K[0],i=K[4]-K[1],a=K[5]-K[2],o=Math.sqrt(r*r+i*i+a*a);if(o>1e-4){const e=r/o,s=i/o,l=a/o;let c=0,d=1,m=0;const p=e*c+s*d+l*m;Math.abs(p)>.999&&(c=1,d=0,m=0);let u=s*m-l*d,y=l*c-e*m,v=e*d-s*c;const h=Math.sqrt(u*u+y*y+v*v);h>1e-4&&(u/=h,y/=h,v/=h);const x=g[t],I=g[t+1],b=g[t+2];if(0!==x||0!==I||0!==b){if(u*x+y*I+v*b<0){for(let e=0;e<Math.min($,f);e++){const t=n+2*e,r=V[t];V[t]=-r,V[t+1]=-r}u=-u,y=-y,v=-v}}g[t]=u,g[t+1]=y,g[t+2]=v}}}else if(u[e]>0){k=!0,u[e]=0,p[e]=0;for(let e=0;e<f;e++){Ce(3*(n+2*e),4*(n+2*e),n+2*e,2*(n+2*e),E,F,V,D,z,N,0,0,0)}}}if(Q&&Le>=2&&_e){k=!0;const e=_e[0],t=e*R,n=Le,r=Math.min(f,Math.max(4*n,n)),i=3*r;if((!we||Te<i)&&(we=new Float32Array(i),Te=i),2===n){const e=3*_e[0],t=3*_e[1];for(let n=0;n<r;n++){const i=n/(r-1);we[3*n]=O[e]+i*(O[t]-O[e]),we[3*n+1]=O[e+1]+i*(O[t+1]-O[e+1]),we[3*n+2]=O[e+2]+i*(O[t+2]-O[e+2])}}else{const e=n-1,t=Math.max(1,Math.floor((r-1)/e));let i=0;for(let a=0;a<e&&i<r;a++){const o=Math.max(0,a-1),s=a,l=Math.min(n-1,a+1),c=Math.min(n-1,a+2),d=3*_e[o],f=3*_e[s],m=3*_e[l],p=3*_e[c],u=a===e-1?r-i:t;for(let e=0;e<u&&i<r;e++){const t=e/u;Ae(we,3*i,O[d],O[d+1],O[d+2],O[f],O[f+1],O[f+2],O[m],O[m+1],O[m+2],O[p],O[p+1],O[p+2],t),i++}}if(i>0){const e=3*_e[n-1];we[3*(i-1)]=O[e],we[3*(i-1)+1]=O[e+1],we[3*(i-1)+2]=O[e+2]}}const a=S[e],d=_[e],m=U[e],p=L[e];for(let e=0;e<f;e++){const n=3*(t+2*e),i=4*(t+2*e),f=t+2*e,u=2*(t+2*e);if(e>=r){Ce(n,i,f,u,E,F,V,D,z,N,0,0,0);continue}const y=3*e,v=we[y],g=we[y+1],h=we[y+2];let x,I,b;if(e>0&&e<r-1){const t=we[3*(e-1)],n=we[3*(e-1)+1],r=we[3*(e-1)+2],i=we[3*(e+1)]-t,a=we[3*(e+1)+1]-n,o=we[3*(e+1)+2]-r,s=Math.sqrt(i*i+a*a+o*o);s>1e-4?(x=v+i/s,I=g+a/s,b=h+o/s):(x=we[3*(e+1)],I=we[3*(e+1)+1],b=we[3*(e+1)+2])}else e<r-1?(x=we[3*(e+1)],I=we[3*(e+1)+1],b=we[3*(e+1)+2]):(x=v,I=g+.001,b=h);const A=r>1?e/(r-1):0,C=o(A),P=s(A),w=c.width*C*.5,T=p*P,O=l?a*l.r(A):a,S=l?d*l.g(A):d,_=l?m*l.b(A):m;Pe(n,i,f,u,v,g,h,x,I,b,w,A,T,O,S,_,p,E,F,V,D,z,N)}for(let e=1;e<Le;e++){const t=_e[e]*R;for(let e=0;e<f;e++){Ce(3*(t+2*e),4*(t+2*e),t+2*e,2*(t+2*e),E,F,V,D,z,N,0,0,0)}}}if(k){r.needsUpdate=!0,i.needsUpdate=!0,a.needsUpdate=!0;const e=M.geometry.getAttribute("trailNext"),t=M.geometry.getAttribute("trailHalfWidth");e.needsUpdate=!0,t.needsUpdate=!0;M.geometry.getAttribute("trailUV").needsUpdate=!0}},ze=e=>{re.forEach(t=>be(t,e))};export{g as CurveFunctionId,A as EmitFrom,S as ForceFieldFalloff,T as ForceFieldType,P as LifeTimeCurve,O as RendererType,b as Shape,I as SimulationSpace,w as SubEmitterTrigger,C as TimeMode,k as applyModifiers,ye as blendingMap,L as calculateRandomPositionAndVelocityOnBox,E as calculateRandomPositionAndVelocityOnCircle,U as calculateRandomPositionAndVelocityOnCone,z as calculateRandomPositionAndVelocityOnRectangle,_ as calculateRandomPositionAndVelocityOnSphere,V as calculateValue,p as createBezierCurveFunction,N as createDefaultMeshTexture,M as createDefaultParticleTexture,Ie as createParticleSystem,h as curveFunctionIdMap,y as getBezierCacheSize,x as getCurveFunction,D as getCurveFunctionFromConfig,ve as getDefaultParticleSystemConfig,F as isLifeTimeCurve,u as removeBezierCurveFunction,ze as updateParticleSystems};//# sourceMappingURL=three-particles.min.js.map
|