@newkrok/three-particles 2.10.4 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.d.ts +58 -7
- package/dist/index.js +303 -111
- 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/llms-full.txt +14 -3
- package/llms.txt +6 -0
- 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 r,i,a=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,l=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,d=(r={"node_modules/easing-functions/index.js"(e,t){var r=e=>e,i={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))}},a={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))}},n={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,r=.1;return 0===e?0:1===e?1:(r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),-r*2**(10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/.4))},Out(e){let t,r=.1;return 0===e?0:1===e?1:(r<1?(r=1,t=.1):t=.4*Math.asin(1/r)/(2*Math.PI),r*2**(-10*e)*Math.sin((e-t)*(2*Math.PI)/.4)+1)},InOut(e){let t=.1;const r=.4;let i;if(0===e)return 0;if(1===e)return 1;t<1?(t=1,i=.1):i=r*Math.asin(1/t)/(2*Math.PI);const a=2*e;if(a<1){const e=a-1;return t*2**(10*e)*Math.sin((e-i)*(2*Math.PI)/r)*-.5}const n=a-1;return t*2**(-10*n)*Math.sin((n-i)*(2*Math.PI)/r)*.5+1}},u={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 r=2*e;return r<1?r*r*((t+1)*r-t)*.5:(r-=2,.5*(r*r*((t+1)*r+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:i,Cubic:a,Quartic:n,Quintic:o,Sinusoidal:s,Exponential:l,Circular:c,Elastic:d,Back:u,Bounce:m},f=(e,t,r)=>Object.defineProperty(e,t,{value:r});for(const e of Object.keys(p)){const t=p[e],r=e.toLowerCase();f(p,r,t);for(const i of Object.keys(t)){const a=t[i],n=i.toLowerCase();f(p,`${e}.${i}`,a),f(p,`${r}.${n}`,a),f(t,n,a)}}p.Linear=r,f(p,"linear",r),t.exports=p,"undefined"!=typeof window&&(window.Easing=p)}},function(){return i||(0,r[s(r)[0]])((i={exports:{}}).exports,i),i.exports}),u=[],m=(e,t)=>{let r=1;for(let i=1;i<=t;i++)r*=(e+1-i)/i;return r},p=(e,t)=>{const r=u.find(e=>e.bezierPoints===t);if(r)return r.referencedBy.includes(e)||r.referencedBy.push(e),r.curveFunction;const i={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let r=0,i=t.length-1;t.find((t,a)=>{const n=e<(t.percentage??0);return n?i=a:void 0!==t.percentage&&(r=a),n});const a=i-r,n=(e-(t[r].percentage??0))/((t[i].percentage??1)-(t[r].percentage??0));let o=0;for(let e=0;e<=a;e++){const i=t[r+e];o+=m(a,e)*Math.pow(1-n,a-e)*Math.pow(n,e)*i.y}return o}};return u.push(i),i.curveFunction},f=e=>{for(;;){const t=u.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const r=u[t];r.referencedBy=r.referencedBy.filter(t=>t!==e),0===r.referencedBy.length&&u.splice(t,1)}},y=()=>u.length,I=((e,t,r)=>(r=null!=e?a(l(e)):{},((e,t,r,i)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let a of s(t))c.call(e,a)||a===r||n(e,a,{get:()=>t[a],enumerable:!(i=o(t,a))||i.enumerable});return e})(n(r,"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:I.default.Linear.None,QUADRATIC_IN:I.default.Quadratic.In,QUADRATIC_OUT:I.default.Quadratic.Out,QUADRATIC_IN_OUT:I.default.Quadratic.InOut,CUBIC_IN:I.default.Cubic.In,CUBIC_OUT:I.default.Cubic.Out,CUBIC_IN_OUT:I.default.Cubic.InOut,QUARTIC_IN:I.default.Quartic.In,QUARTIC_OUT:I.default.Quartic.Out,QUARTIC_IN_OUT:I.default.Quartic.InOut,QUINTIC_IN:I.default.Quintic.In,QUINTIC_OUT:I.default.Quintic.Out,QUINTIC_IN_OUT:I.default.Quintic.InOut,SINUSOIDAL_IN:I.default.Sinusoidal.In,SINUSOIDAL_OUT:I.default.Sinusoidal.Out,SINUSOIDAL_IN_OUT:I.default.Sinusoidal.InOut,EXPONENTIAL_IN:I.default.Exponential.In,EXPONENTIAL_OUT:I.default.Exponential.Out,EXPONENTIAL_IN_OUT:I.default.Exponential.InOut,CIRCULAR_IN:I.default.Circular.In,CIRCULAR_OUT:I.default.Circular.Out,CIRCULAR_IN_OUT:I.default.Circular.InOut,ELASTIC_IN:I.default.Elastic.In,ELASTIC_OUT:I.default.Elastic.Out,ELASTIC_IN_OUT:I.default.Elastic.InOut,BACK_IN:I.default.Back.In,BACK_OUT:I.default.Back.Out,BACK_IN_OUT:I.default.Back.InOut,BOUNCE_IN:I.default.Bounce.In,BOUNCE_OUT:I.default.Bounce.Out,BOUNCE_IN_OUT:I.default.Bounce.InOut},v=e=>"function"==typeof e?e:h[e],x=(e=>(e.LOCAL="LOCAL",e.WORLD="WORLD",e))(x||{}),O=(e=>(e.SPHERE="SPHERE",e.CONE="CONE",e.BOX="BOX",e.CIRCLE="CIRCLE",e.RECTANGLE="RECTANGLE",e))(O||{}),b=(e=>(e.VOLUME="VOLUME",e.SHELL="SHELL",e.EDGE="EDGE",e))(b||{}),A=(e=>(e.LIFETIME="LIFETIME",e.FPS="FPS",e))(A||{}),_=(e=>(e.BEZIER="BEZIER",e.EASING="EASING",e))(_||{}),T=(e=>(e.BIRTH="BIRTH",e.DEATH="DEATH",e))(T||{}),C=(e=>(e.POINT="POINT",e.DIRECTIONAL="DIRECTIONAL",e))(C||{}),E=(e=>(e.NONE="NONE",e.LINEAR="LINEAR",e.QUADRATIC="QUADRATIC",e))(E||{}),U=(e,t,r,i,{radius:a,radiusThickness:n,arc:o})=>{const s=Math.random()*(o/360),l=Math.random(),c=Math.random(),d=2*Math.PI*s,u=Math.acos(2*l-1),m=Math.sin(u),p=m*Math.cos(d),f=m*Math.sin(d),y=Math.cos(u),I=1-n;e.x=a*I*p+a*n*c*p,e.y=a*I*f+a*n*c*f,e.z=a*I*y+a*n*c*y,e.applyQuaternion(t);const g=1/e.length();r.set(e.x*g*i,e.y*g*i,e.z*g*i),r.applyQuaternion(t)},L=(t,r,i,a,{radius:n,radiusThickness:o,arc:s,angle:l=90})=>{const c=2*Math.PI*Math.random()*(s/360),d=Math.random(),u=Math.cos(c),m=Math.sin(c),p=1-o;t.x=n*p*u+n*o*d*u,t.y=n*p*m+n*o*d*m,t.z=0,t.applyQuaternion(r);const f=t.length(),y=Math.abs(f/n*e.MathUtils.degToRad(l)),I=Math.sin(y),g=1/f;i.set(t.x*I*g*a,t.y*I*g*a,Math.cos(y)*a),i.applyQuaternion(r)},P=(e,t,r,i,{scale:a,emitFrom:n})=>{const o=a;switch(n){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()),r=t%3,i=[];i[r]=t>2?1:0,i[(r+1)%3]=Math.random(),i[(r+2)%3]=Math.random(),e.x=i[0]*o.x-o.x/2,e.y=i[1]*o.y-o.y/2,e.z=i[2]*o.z-o.z/2;break;case"EDGE":const a=Math.floor(6*Math.random()),n=a%3,s=Math.floor(4*Math.random()),l=[];l[n]=a>2?1:0,l[(n+1)%3]=s<2?Math.random():s-2,l[(n+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),r.set(0,0,i),r.applyQuaternion(t)},N=(e,t,r,i,{radius:a,radiusThickness:n,arc:o})=>{const s=2*Math.PI*Math.random()*(o/360),l=Math.random(),c=Math.cos(s),d=Math.sin(s),u=1-n;e.x=a*u*c+a*n*l*c,e.y=a*u*d+a*n*l*d,e.z=0,e.applyQuaternion(t);const m=1/e.length();r.set(e.x*m*i,e.y*m*i,0),r.applyQuaternion(t)},S=(t,r,i,a,{rotation:n,scale:o})=>{const s=o,l=n,c=Math.random()*s.x-s.x/2,d=Math.random()*s.y-s.y/2,u=e.MathUtils.degToRad(l.x),m=e.MathUtils.degToRad(l.y);t.x=c*Math.cos(m),t.y=d*Math.cos(u),t.z=c*Math.sin(m)-d*Math.sin(u),t.applyQuaternion(r),i.set(0,0,a),i.applyQuaternion(r)},z=()=>{try{const t=document.createElement("canvas"),r=64;t.width=r,t.height=r;const i=t.getContext("2d");if(i){const a=r/2,n=r/2,o=r/2-2;i.beginPath(),i.arc(a,n,o,0,2*Math.PI,!1),i.fillStyle="white",i.fill();const s=new e.CanvasTexture(t);return s.needsUpdate=!0,s}return null}catch(e){return null}},w=e=>"number"!=typeof e&&"type"in e,M=(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}`)},R=(t,r,i=0)=>{if("number"==typeof r)return r;if("min"in r&&"max"in r)return r.min===r.max?r.min??0:e.MathUtils.randFloat(r.min??0,r.max??1);const a=r;return M(t,a)(i)*(a.scale??1)},V=new e.Vector3(0,0,0),B=new e.Euler,D=({delta:e,generalData:t,normalizedConfig:r,attributes:i,particleLifetimePercentage:a,particleIndex:n})=>{const{particleSystemId:o,startValues:s,lifetimeValues:l,linearVelocityData:c,orbitalVelocityData:d,noise:u}=t,m=3*n,p=i.position.array;if(c){const{speed:t,valueModifiers:r}=c[n],o=r.x?r.x(a):t.x,s=r.y?r.y(a):t.y,l=r.z?r.z(a):t.z;p[m]+=o*e,p[m+1]+=s*e,p[m+2]+=l*e,i.position.needsUpdate=!0}if(d){const{speed:t,positionOffset:r,valueModifiers:o}=d[n];p[m]-=r.x,p[m+1]-=r.y,p[m+2]-=r.z;const s=o.x?o.x(a):t.x,l=o.y?o.y(a):t.y,c=o.z?o.z(a):t.z;B.set(s*e,c*e,l*e),r.applyEuler(B),p[m]+=r.x,p[m+1]+=r.y,p[m+2]+=r.z,i.position.needsUpdate=!0}if(r.sizeOverLifetime.isActive){const e=R(o,r.sizeOverLifetime.lifetimeCurve,a);i.size.array[n]=s.startSize[n]*e,i.size.needsUpdate=!0}if(r.opacityOverLifetime.isActive){const e=R(o,r.opacityOverLifetime.lifetimeCurve,a);i.colorA.array[n]=s.startOpacity[n]*e,i.colorA.needsUpdate=!0}if(r.colorOverLifetime.isActive){const e=R(o,r.colorOverLifetime.r,a),t=R(o,r.colorOverLifetime.g,a),l=R(o,r.colorOverLifetime.b,a);i.colorR.array[n]=s.startColorR[n]*e,i.colorG.array[n]=s.startColorG[n]*t,i.colorB.array[n]=s.startColorB[n]*l,i.colorR.needsUpdate=!0,i.colorG.needsUpdate=!0,i.colorB.needsUpdate=!0}if(l.rotationOverLifetime&&(i.rotation.array[n]+=l.rotationOverLifetime[n]*e*.02,i.rotation.needsUpdate=!0),u.isActive){const{sampler:e,strength:t,noisePower:r,offsets:o,positionAmount:s,rotationAmount:l,sizeAmount:c}=u;let d;const f=10*(a+(o?o[n]:0))*t;V.set(f,0,0),d=e.get3(V),p[m]+=d*r*s,0!==l&&(i.rotation.array[n]+=d*r*l,i.rotation.needsUpdate=!0),0!==c&&(i.size.array[n]+=d*r*c,i.size.needsUpdate=!0),V.set(f,f,0),d=e.get3(V),p[m+1]+=d*r*s,V.set(f,f,f),d=e.get3(V),p[m+2]+=d*r*s,i.position.needsUpdate=!0}},Q={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(Q,{deepMerge:()=>k,getObjectDiff:()=>j,patchObject:()=>F});var F=(e,t,r={skippedProperties:[],applyToFirstObject:!1})=>{const i={};return Object.keys(e).forEach(a=>{r.skippedProperties&&r.skippedProperties.includes(a)||("object"==typeof e[a]&&e[a]&&t[a]&&!Array.isArray(e[a])?i[a]=F(e[a],t[a],r):(i[a]=0===t[a]?0:!1!==t[a]&&(t[a]||e[a]),r.applyToFirstObject&&(e[a]=i[a])))}),i},k=(e,t,r={skippedProperties:[],applyToFirstObject:!1})=>{const i={};return Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})])).forEach(a=>{r.skippedProperties&&r.skippedProperties.includes(a)||("object"==typeof e?.[a]&&e?.[a]&&t?.[a]&&!Array.isArray(e[a])?i[a]=k(e[a],t[a],r):(i[a]=0===t?.[a]?0:!1!==t?.[a]&&(t?.[a]||e?.[a]),r.applyToFirstObject&&(e[a]=i[a])))}),i},j=(e,t,r={skippedProperties:[]})=>{const i={};return Object.keys(e).forEach(a=>{if(!r.skippedProperties||!r.skippedProperties.includes(a))if("object"==typeof e[a]&&e[a]&&t[a]&&!Array.isArray(e[a])){const n=j(e[a],t[a],r);Object.keys(n).length>0&&(i[a]=n)}else{const r=0===t[a]?0:t[a]||e[a];r!==e[a]&&(i[a]=r)}}),i},G=function(){};G.prototype.load=G,G.prototype.parse=G;var H=G;Array.from({length:3},()=>({loader:new H,isUsed:!1})),Array.from({length:3},()=>({loader:new e.TextureLoader,isUsed:!1})),Array.from({length:3},()=>({loader:new e.AudioLoader,isUsed:!1}));var W=[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 r=[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 i=new Array(512),a=new Array(512);t||(t=1),t*=65536,(t=Math.floor(t))<256&&(t|=t<<8);for(var n=0;n<256;n++){var o;o=1&n?W[n]^255&t:W[n]^t>>8&255,i[n]=i[n+256]=o,a[n]=a[n+256]=r[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=i,this.gradP=a}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,r){return(1-r)*e+r*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,r,i,a){return(e-t)*(a-i)/(r-t)+i}get2(t){void 0!==t.z&&(t=new e.Vector2(t.x,t.y));const r=new e.Vector2(Math.floor(t.x),Math.floor(t.y));t.sub(r),r.x&=255,r.y&=255;const i=[];for(let a=0;a<4;a++){const n=this._offsetMatrix[2*a],o=new e.Vector2(n.x,n.y),s=this.gradP[this._gradient((new e.Vector2).addVectors(r,o))],l=new e.Vector2(s.x,s.y),c=(new e.Vector2).subVectors(t,o);i.push(l.dot(c))}const a=this._fade(t.x),n=this._fade(t.y);return this._lerp(this._lerp(i[0],i[2],a),this._lerp(i[1],i[3],a),n)}get3(t){if(void 0===t.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const r=new e.Vector3(Math.floor(t.x),Math.floor(t.y),Math.floor(t.z));t.sub(r),r.x&=255,r.y&=255,r.z&=255;const i=[];for(let a=0;a<8;a++){const n=this._offsetMatrix[a],o=this.gradP[this._gradient((new e.Vector3).addVectors(r,n))],s=(new e.Vector3).subVectors(t,n);i.push(o.dot(s))}const a=this._fade(t.x),n=this._fade(t.y),o=this._fade(t.z);return this._lerp(this._lerp(this._lerp(i[0],i[4],a),this._lerp(i[1],i[5],a),o),this._lerp(this._lerp(i[2],i[6],a),this._lerp(i[3],i[7],a),o),n)}},q=class{constructor(e){const{seed:t,scale:r,persistance:i,lacunarity:a,octaves:n,redistribution:o}=e;this._noise=new X(t),this._scale=r||1,this._persistance=i||.5,this._lacunarity=a||2,this._octaves=n||6,this._redistribution=o||1}get2(t){let r=0,i=1,a=1,n=i,o=this._noise.get2.bind(this._noise);for(let s=0;s<this._octaves;s++){r+=o(new e.Vector2(t.x*this._scale*a,t.y*this._scale*a))*i,a*=this._lacunarity,i*=this._persistance,n+=i}return Math.pow(r,this._redistribution)/n}get3(t){let r=0,i=1,a=1,n=i,o=this._noise.get3.bind(this._noise);for(let s=0;s<this._octaves;s++){r+=o(new e.Vector3(t.x*this._scale*a,t.y*this._scale*a,t.z*this._scale*a))*i,a*=this._lacunarity,i*=this._persistance,n+=i}return Math.pow(r,this._redistribution)/n}},Z=new e.Vector3,K=(e,t,r,i,a,n)=>{Z.set(e.position.x-i[a],e.position.y-i[a+1],e.position.z-i[a+2]);const o=Z.length();if(o<1e-4)return;if(e.range!==1/0&&o>e.range)return;Z.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*n;r.x+=Z.x*l,r.y+=Z.y*l,r.z+=Z.z*l},$=(e,t,r,i)=>{const a=t*i;r.x+=e.direction.x*a,r.y+=e.direction.y*a,r.z+=e.direction.z*a},Y=({particleSystemId:e,forceFields:t,velocity:r,positionArr:i,positionIndex:a,delta:n,systemLifetimePercentage:o})=>{for(let s=0;s<t.length;s++){const l=t[s];if(!l.isActive)continue;const c=R(e,l.strength,o);0!==c&&("POINT"===l.type?K(l,c,r,i,a,n):"DIRECTIONAL"===l.type&&$(l,c,r,n))}},J=0,ee=[],te=new e.Vector3,re=new e.Vector3,ie={x:0,y:0,z:0},ae={x:0,y:0,z:0},ne={delta:0,generalData:null,normalizedConfig:null,attributes:null,particleLifetimePercentage:0,particleIndex:0},oe={"THREE.NoBlending":e.NoBlending,"THREE.NormalBlending":e.NormalBlending,"THREE.AdditiveBlending":e.AdditiveBlending,"THREE.SubtractiveBlending":e.SubtractiveBlending,"THREE.MultiplyBlending":e.MultiplyBlending},se=()=>JSON.parse(JSON.stringify(le)),le={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},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:[]},ce=({geometry:t,propertyName:r,maxParticles:i,factory:a})=>{const n=new Float32Array(i);if("function"==typeof a)for(let e=0;e<i;e++)n[e]=a(void 0,e);else n.fill(a);t.setAttribute(r,new e.BufferAttribute(n,1))},de=(e,{shape:t,sphere:r,cone:i,circle:a,rectangle:n,box:o},s,l,c)=>{const d=R(e.particleSystemId,s,e.normalizedLifetimePercentage);switch(t){case"SPHERE":U(l,e.wrapperQuaternion,c,d,r);break;case"CONE":L(l,e.wrapperQuaternion,c,d,i);break;case"CIRCLE":N(l,e.wrapperQuaternion,c,d,a);break;case"RECTANGLE":S(l,e.wrapperQuaternion,c,d,n);break;case"BOX":P(l,e.wrapperQuaternion,c,d,o)}},ue=(r=le,i)=>{const a=i||Date.now(),n={particleSystemId:J++,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(le,r,{applyToFirstObject:!1,skippedProperties:[]});let s=o.map||z();const{transform:l,duration:c,looping:d,startDelay:u,startLifetime:m,startSpeed:p,startSize:y,startRotation:I,startColor:g,startOpacity:h,gravity:v,simulationSpace:x,maxParticles:O,emission:b,shape:A,renderer:_,noise:T,velocityOverLifetime:C,onUpdate:E,onComplete:U,textureSheetAnimation:L,subEmitters:P,forceFields:N}=o,S=(t,r)=>t?new e.Vector3(t.x??0,t.y??0,t.z??0):r.clone(),V=(N??[]).map(t=>({isActive:t.isActive??!0,type:t.type??"POINT",position:S(t.position,new e.Vector3(0,0,0)),direction:S(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"}));"string"==typeof _?.blending&&(_.blending=oe[_.blending]);const B=Array.from({length:O},()=>new e.Vector3),F=Array.from({length:O},()=>new e.Vector3);n.creationTimes=Array.from({length:O},()=>0);const k=Array.from({length:O},(e,t)=>O-1-t);C.isActive&&(n.linearVelocityData=Array.from({length:O},()=>({speed:new e.Vector3(C.linear.x?R(n.particleSystemId,C.linear.x,0):0,C.linear.y?R(n.particleSystemId,C.linear.y,0):0,C.linear.z?R(n.particleSystemId,C.linear.z,0):0),valueModifiers:{x:w(C.linear.x||0)?M(n.particleSystemId,C.linear.x):void 0,y:w(C.linear.y||0)?M(n.particleSystemId,C.linear.y):void 0,z:w(C.linear.z||0)?M(n.particleSystemId,C.linear.z):void 0}})),n.orbitalVelocityData=Array.from({length:O},()=>({speed:new e.Vector3(C.orbital.x?R(n.particleSystemId,C.orbital.x,0):0,C.orbital.y?R(n.particleSystemId,C.orbital.y,0):0,C.orbital.z?R(n.particleSystemId,C.orbital.z,0):0),valueModifiers:{x:w(C.orbital.x||0)?M(n.particleSystemId,C.orbital.x):void 0,y:w(C.orbital.y||0)?M(n.particleSystemId,C.orbital.y):void 0,z:w(C.orbital.z||0)?M(n.particleSystemId,C.orbital.z):void 0},positionOffset:new e.Vector3})));["startSize","startOpacity"].forEach(e=>{n.startValues[e]=Array.from({length:O},()=>R(n.particleSystemId,o[e],0))}),n.startValues.startColorR=Array.from({length:O},()=>0),n.startValues.startColorG=Array.from({length:O},()=>0),n.startValues.startColorB=Array.from({length:O},()=>0);["rotationOverLifetime"].forEach(t=>{const r=o[t];r.isActive&&(n.lifetimeValues[t]=Array.from({length:O},()=>e.MathUtils.randFloat(r.min,r.max)))}),n.noise={isActive:T.isActive,strength:T.strength,noisePower:.15*T.strength,positionAmount:T.positionAmount,rotationAmount:T.rotationAmount,sizeAmount:T.sizeAmount,sampler:T.isActive?new q({seed:Math.random(),scale:T.frequency,octaves:T.octaves}):void 0,offsets:T.useRandomOffset?Array.from({length:O},()=>100*Math.random()):void 0},b.bursts&&b.bursts.length>0&&(n.burstStates=b.bursts.map(()=>({cyclesExecuted:0,lastCycleTime:0,probabilityPassed:!1})));const j=new e.ShaderMaterial({uniforms:{elapsed:{value:0},map:{value:s},tiles:{value:L.tiles},fps:{value:L.fps},useFPSForFrameIndex:{value:"FPS"===L.timeMode},backgroundColor:{value:_.backgroundColor},discardBackgroundColor:{value:_.discardBackgroundColor},backgroundColorTolerance:{value:_.backgroundColorTolerance}},vertexShader:"\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\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 gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:"\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\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\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 #include <logdepthbuf_fragment>\n }\n",transparent:_.transparent,blending:_.blending,depthTest:_.depthTest,depthWrite:_.depthWrite}),G=new e.BufferGeometry;for(let e=0;e<O;e++)de(n,A,p,B[e],F[e]);const H=new Float32Array(3*O);for(let e=0;e<O;e++)H[3*e]=B[e].x,H[3*e+1]=B[e].y,H[3*e+2]=B[e].z;G.setAttribute("position",new e.BufferAttribute(H,3)),ce({geometry:G,propertyName:"isActive",maxParticles:O,factory:0}),ce({geometry:G,propertyName:"lifetime",maxParticles:O,factory:0}),ce({geometry:G,propertyName:"startLifetime",maxParticles:O,factory:()=>1e3*R(n.particleSystemId,m,0)}),ce({geometry:G,propertyName:"startFrame",maxParticles:O,factory:()=>L.startFrame?R(n.particleSystemId,L.startFrame,0):0}),ce({geometry:G,propertyName:"opacity",maxParticles:O,factory:()=>R(n.particleSystemId,h,0)}),ce({geometry:G,propertyName:"rotation",maxParticles:O,factory:()=>R(n.particleSystemId,I,0)}),ce({geometry:G,propertyName:"size",maxParticles:O,factory:(e,t)=>n.startValues.startSize[t]}),ce({geometry:G,propertyName:"rotation",maxParticles:O,factory:0});const W=Math.random();ce({geometry:G,propertyName:"colorR",maxParticles:O,factory:()=>g.min.r+W*(g.max.r-g.min.r)}),ce({geometry:G,propertyName:"colorG",maxParticles:O,factory:()=>g.min.g+W*(g.max.g-g.min.g)}),ce({geometry:G,propertyName:"colorB",maxParticles:O,factory:()=>g.min.b+W*(g.max.b-g.min.b)}),ce({geometry:G,propertyName:"colorA",maxParticles:O,factory:0});const X=P??[],Z=X.filter(e=>"DEATH"===(e.trigger??"DEATH")),K=X.filter(e=>"BIRTH"===e.trigger),$=new Map;for(const e of X)$.set(e,[]);const Y=t=>{for(let r=t.length-1;r>=0;r--){const i=t[r],a=i.instance instanceof e.Points?i.instance:i.instance.children[0],n=a?.geometry?.attributes?.isActive?.array;if(!n){i.dispose(),t.splice(r,1);continue}let o=!1;for(let e=0;e<n.length;e++)if(n[e]){o=!0;break}o||(i.dispose(),t.splice(r,1))}},re=(t,r,i,a)=>{for(const n of t){const t=$.get(n),o=n.maxInstances??32;if(t.length>=o&&(Y(t),t.length>=o))continue;const s=n.inheritVelocity??0,l=ue({...n.config,looping:!1,transform:{...n.config.transform,position:new e.Vector3(r.x,r.y,r.z)},...s>0?{startSpeed:("number"==typeof n.config.startSpeed?n.config.startSpeed:"object"==typeof n.config.startSpeed&&null!==n.config.startSpeed&&"min"in n.config.startSpeed?n.config.startSpeed.min??0:0)+i.length()*s}:{}},a),c=(ne||ie).parent;c&&c.add(l.instance),t.push(l)}};let ie=new e.Points(G,j);ie.position.copy(l.position),ie.rotation.x=e.MathUtils.degToRad(l.rotation.x),ie.rotation.y=e.MathUtils.degToRad(l.rotation.y),ie.rotation.z=e.MathUtils.degToRad(l.rotation.z),ie.scale.copy(l.scale);const ae=a+1e3*R(n.particleSystemId,u);let ne;"WORLD"===o.simulationSpace&&(ne=new t,ne.add(ie));const se=Z.length>0?(e,t,r,i)=>{const a=3*e;te.set(t[a],t[a+1],t[a+2]),re(Z,te,r,i)}:void 0,pe=K.length>0?(e,t,r,i)=>{const a=3*e;te.set(t[a],t[a+1],t[a+2]),re(K,te,r,i)}:void 0,fe={particleSystem:ie,wrapper:ne,elapsedUniform:j.uniforms.elapsed,generalData:n,onUpdate:E,onComplete:U,creationTime:ae,lastEmissionTime:ae,duration:c,looping:d,simulationSpace:x,gravity:v,normalizedForceFields:V,emission:b,normalizedConfig:o,iterationCount:0,velocities:F,freeList:k,deactivateParticle:e=>{G.attributes.isActive.array[e]=0,G.attributes.colorA.array[e]=0,G.attributes.colorA.needsUpdate=!0,k.push(e)},activateParticle:({particleIndex:t,activationTime:r,position:i})=>{G.attributes.isActive.array[t]=1,n.creationTimes[t]=r,n.noise.offsets&&(n.noise.offsets[t]=100*Math.random());const a=Math.random();G.attributes.colorR.array[t]=g.min.r+a*(g.max.r-g.min.r),G.attributes.colorR.needsUpdate=!0,G.attributes.colorG.array[t]=g.min.g+a*(g.max.g-g.min.g),G.attributes.colorG.needsUpdate=!0,G.attributes.colorB.array[t]=g.min.b+a*(g.max.b-g.min.b),G.attributes.colorB.needsUpdate=!0,n.startValues.startColorR[t]=G.attributes.colorR.array[t],n.startValues.startColorG[t]=G.attributes.colorG.array[t],n.startValues.startColorB[t]=G.attributes.colorB.array[t],G.attributes.startFrame.array[t]=L.startFrame?R(n.particleSystemId,L.startFrame,0):0,G.attributes.startFrame.needsUpdate=!0,G.attributes.startLifetime.array[t]=1e3*R(n.particleSystemId,m,n.normalizedLifetimePercentage),G.attributes.startLifetime.needsUpdate=!0,n.startValues.startSize[t]=R(n.particleSystemId,y,n.normalizedLifetimePercentage),G.attributes.size.array[t]=n.startValues.startSize[t],G.attributes.size.needsUpdate=!0,n.startValues.startOpacity[t]=R(n.particleSystemId,h,n.normalizedLifetimePercentage),G.attributes.colorA.array[t]=n.startValues.startOpacity[t],G.attributes.colorA.needsUpdate=!0,G.attributes.rotation.array[t]=R(n.particleSystemId,I,n.normalizedLifetimePercentage),G.attributes.rotation.needsUpdate=!0,o.rotationOverLifetime.isActive&&(n.lifetimeValues.rotationOverLifetime[t]=e.MathUtils.randFloat(o.rotationOverLifetime.min,o.rotationOverLifetime.max)),de(n,A,p,B[t],F[t]);const s=Math.floor(3*t);G.attributes.position.array[s]=i.x+B[t].x,G.attributes.position.array[s+1]=i.y+B[t].y,G.attributes.position.array[s+2]=i.z+B[t].z,G.attributes.position.needsUpdate=!0,n.linearVelocityData&&n.linearVelocityData[t].speed.set(o.velocityOverLifetime.linear.x?R(n.particleSystemId,o.velocityOverLifetime.linear.x,0):0,o.velocityOverLifetime.linear.y?R(n.particleSystemId,o.velocityOverLifetime.linear.y,0):0,o.velocityOverLifetime.linear.z?R(n.particleSystemId,o.velocityOverLifetime.linear.z,0):0),n.orbitalVelocityData&&(n.orbitalVelocityData[t].speed.set(o.velocityOverLifetime.orbital.x?R(n.particleSystemId,o.velocityOverLifetime.orbital.x,0):0,o.velocityOverLifetime.orbital.y?R(n.particleSystemId,o.velocityOverLifetime.orbital.y,0):0,o.velocityOverLifetime.orbital.z?R(n.particleSystemId,o.velocityOverLifetime.orbital.z,0):0),n.orbitalVelocityData[t].positionOffset.set(B[t].x,B[t].y,B[t].z)),G.attributes.lifetime.array[t]=0,G.attributes.lifetime.needsUpdate=!0,D({delta:0,generalData:n,normalizedConfig:o,attributes:ie.geometry.attributes,particleLifetimePercentage:0,particleIndex:t})},onParticleDeath:se,onParticleBirth:pe};ee.push(fe);return{instance:ne||ie,resumeEmitter:()=>n.isEnabled=!0,pauseEmitter:()=>n.isEnabled=!1,dispose:()=>{for(const e of $.values()){for(const t of e)t.dispose();e.length=0}(e=>{ee=ee.filter(({particleSystem:t,wrapper:r,generalData:{particleSystemId:i}})=>t!==e&&r!==e||(f(i),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),r?.parent&&r.parent.remove(r),!1))})(ie)},update:e=>{me(fe,e);for(const t of $.values())for(const r of t)r.update(e)}}},me=(e,{now:t,delta:r,elapsed:i})=>{const{onUpdate:a,generalData:n,onComplete:o,particleSystem:s,wrapper:l,elapsedUniform:c,creationTime:d,lastEmissionTime:u,duration:m,looping:p,emission:f,normalizedConfig:y,iterationCount:I,velocities:g,freeList:h,deactivateParticle:v,activateParticle:x,simulationSpace:O,gravity:b,normalizedForceFields:A,onParticleDeath:_,onParticleBirth:T}=e,C=A.length>0,E=t-d,U=E%(1e3*m);n.normalizedLifetimePercentage=Math.max(Math.min(U/(1e3*m),1),0);const{lastWorldPosition:L,currentWorldPosition:P,worldPositionChange:N,lastWorldQuaternion:S,worldQuaternion:z,worldEuler:w,gravityVelocity:M,isEnabled:V}=n;l?.parent&&n.wrapperQuaternion.copy(l.parent.quaternion),re.copy(L),c.value=i,s.getWorldPosition(P),-99999!==L.x&&N.set(P.x-L.x,P.y-L.y,P.z-L.z),V&&(n.distanceFromLastEmitByDistance+=N.length()),s.getWorldPosition(L),s.getWorldQuaternion(z),-99999!==S.x&&S.x===z.x&&S.y===z.y&&S.z===z.z||(w.setFromQuaternion(z),S.copy(z),M.set(L.x,L.y+b,L.z),s.worldToLocal(M));const B=n.creationTimes,Q=s.geometry.attributes,F=Q.isActive.array,k=Q.startLifetime.array,j=Q.position.array,G=Q.lifetime.array,H=B.length;let W=!1,X=!1;ne.delta=r,ne.generalData=n,ne.normalizedConfig=y,ne.attributes=Q;for(let e=0;e<H;e++)if(F[e]){const i=t-B[e];if(i>k[e])_&&_(e,j,g[e],t),v(e);else{const t=g[e];if(t.x-=M.x*r,t.y-=M.y*r,t.z-=M.z*r,C&&Y({particleSystemId:n.particleSystemId,forceFields:A,velocity:t,positionArr:j,positionIndex:3*e,delta:r,systemLifetimePercentage:n.normalizedLifetimePercentage}),0!==b||0!==t.x||0!==t.y||0!==t.z||0!==N.x||0!==N.y||0!==N.z){const i=3*e;"WORLD"===O&&(j[i]-=N.x,j[i+1]-=N.y,j[i+2]-=N.z),j[i]+=t.x*r,j[i+1]+=t.y*r,j[i+2]+=t.z*r,W=!0}G[e]=i,X=!0,ne.particleLifetimePercentage=i/k[e],ne.particleIndex=e,D(ne)}}if(W&&(Q.position.needsUpdate=!0),X&&(Q.lifetime.needsUpdate=!0),V&&(p||E<1e3*m)){const o=t-u,l=f.rateOverTime?Math.floor(R(n.particleSystemId,f.rateOverTime,n.normalizedLifetimePercentage)*(o/1e3)):0,c=f.rateOverDistance?R(n.particleSystemId,f.rateOverDistance,n.normalizedLifetimePercentage):0,d=c>0&&n.distanceFromLastEmitByDistance>0?Math.floor(n.distanceFromLastEmitByDistance/(1/c)):0,m=d>0;m&&(ie.x=(P.x-re.x)/d,ie.y=(P.y-re.y)/d,ie.z=(P.z-re.z)/d);let y=l+d;if(c>0&&d>=1&&(n.distanceFromLastEmitByDistance=0),f.bursts&&n.burstStates){const e=f.bursts,t=n.burstStates,r=U;for(let i=0;i<e.length;i++){const a=e[i],o=t[i],s=1e3*a.time,l=a.cycles??1,c=1e3*(a.interval??0),d=a.probability??1;if(p&&r<s&&o.cyclesExecuted>0&&(o.cyclesExecuted=0,o.lastCycleTime=0,o.probabilityPassed=!1),o.cyclesExecuted>=l)continue;if(r>=s+o.cyclesExecuted*c){if(0===o.cyclesExecuted&&(o.probabilityPassed=Math.random()<d),o.probabilityPassed){y+=Math.floor(R(n.particleSystemId,a.count,n.normalizedLifetimePercentage))}o.cyclesExecuted++,o.lastCycleTime=r}}}if(y>0){let r=0;for(let i=0;i<y&&0!==h.length;i++){const i=h.pop();ae.x=0,ae.y=0,ae.z=0,m&&r<d&&(ae.x=ie.x*r,ae.y=ie.y*r,ae.z=ie.z*r,r++),x({particleIndex:i,activationTime:t,position:ae}),T&&T(i,Q.position.array,g[i],t),e.lastEmissionTime=t}}a&&a({particleSystem:s,delta:r,elapsed:i,lifetime:E,normalizedLifetime:U,iterationCount:I+1})}else o&&o({particleSystem:s})},pe=e=>{ee.forEach(t=>me(t,e))};export{g as CurveFunctionId,b as EmitFrom,E as ForceFieldFalloff,C as ForceFieldType,_ as LifeTimeCurve,O as Shape,x as SimulationSpace,T as SubEmitterTrigger,A as TimeMode,D as applyModifiers,oe as blendingMap,P as calculateRandomPositionAndVelocityOnBox,N as calculateRandomPositionAndVelocityOnCircle,L as calculateRandomPositionAndVelocityOnCone,S as calculateRandomPositionAndVelocityOnRectangle,U as calculateRandomPositionAndVelocityOnSphere,R as calculateValue,p as createBezierCurveFunction,z as createDefaultParticleTexture,ue as createParticleSystem,h as curveFunctionIdMap,y as getBezierCacheSize,v as getCurveFunction,M as getCurveFunctionFromConfig,se as getDefaultParticleSystemConfig,w as isLifeTimeCurve,f as removeBezierCurveFunction,pe 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||{}),I={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},h=e=>"function"==typeof e?e:I[e],x=(e=>(e.LOCAL="LOCAL",e.WORLD="WORLD",e))(x||{}),O=(e=>(e.SPHERE="SPHERE",e.CONE="CONE",e.BOX="BOX",e.CIRCLE="CIRCLE",e.RECTANGLE="RECTANGLE",e))(O||{}),b=(e=>(e.VOLUME="VOLUME",e.SHELL="SHELL",e.EDGE="EDGE",e))(b||{}),C=(e=>(e.LIFETIME="LIFETIME",e.FPS="FPS",e))(C||{}),A=(e=>(e.BEZIER="BEZIER",e.EASING="EASING",e))(A||{}),_=(e=>(e.BIRTH="BIRTH",e.DEATH="DEATH",e))(_||{}),T=(e=>(e.POINT="POINT",e.DIRECTIONAL="DIRECTIONAL",e))(T||{}),P=(e=>(e.POINTS="POINTS",e.INSTANCED="INSTANCED",e))(P||{}),U=(e=>(e.NONE="NONE",e.LINEAR="LINEAR",e.QUADRATIC="QUADRATIC",e))(U||{}),E=(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)},L=(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)},S=(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)},N=(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)},w=()=>{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}},M=e=>"number"!=typeof e&&"type"in e,R=(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}`)},B=(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 R(t,i)(r)*(i.scale??1)},V=new e.Vector3(0,0,0),F=new e.Euler,D=({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;F.set(s*e,c*e,l*e),n.applyEuler(F),p[m]+=n.x,p[m+1]+=n.y,p[m+2]+=n.z,r.position.needsUpdate=!0}if(n.sizeOverLifetime.isActive){const e=B(o,n.sizeOverLifetime.lifetimeCurve,i);r.size.array[a]=s.startSize[a]*e,r.size.needsUpdate=!0}if(n.opacityOverLifetime.isActive){const e=B(o,n.opacityOverLifetime.lifetimeCurve,i);r.colorA.array[a]=s.startOpacity[a]*e,r.colorA.needsUpdate=!0}if(n.colorOverLifetime.isActive){const e=B(o,n.colorOverLifetime.r,i),t=B(o,n.colorOverLifetime.g,i),l=B(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;V.set(u,0,0),d=e.get3(V),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),V.set(u,u,0),d=e.get3(V),p[m+1]+=d*n*s,V.set(u,u,u),d=e.get3(V),p[m+2]+=d*n*s,r.position.needsUpdate=!0}},Q={};((e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})})(Q,{deepMerge:()=>j,getObjectDiff:()=>G,patchObject:()=>k});var k=(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]=k(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},G=(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=G(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},H=function(){};H.prototype.load=H,H.prototype.parse=H;var W=H;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 X=[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],q=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?X[a]^255&t:X[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)}},Z=class{constructor(e){const{seed:t,scale:n,persistance:r,lacunarity:i,octaves:a,redistribution:o}=e;this._noise=new q(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,Y=(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},$=(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},J=({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=B(e,l.strength,o);0!==c&&("POINT"===l.type?Y(l,c,n,r,i,a):"DIRECTIONAL"===l.type&&$(l,c,n,a))}},ee=0,te=[],ne=new e.Vector3,re=new e.Vector3,ie={x:0,y:0,z:0},ae={x:0,y:0,z:0},oe={delta:0,generalData:null,normalizedConfig:null,attributes:null,particleLifetimePercentage:0,particleIndex:0},se={"THREE.NoBlending":e.NoBlending,"THREE.NormalBlending":e.NormalBlending,"THREE.AdditiveBlending":e.AdditiveBlending,"THREE.SubtractiveBlending":e.SubtractiveBlending,"THREE.MultiplyBlending":e.MultiplyBlending},le=()=>JSON.parse(JSON.stringify(ce)),ce={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},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:[]},de=({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)},fe=(e,{shape:t,sphere:n,cone:r,circle:i,rectangle:a,box:o},s,l,c)=>{const d=B(e.particleSystemId,s,e.normalizedLifetimePercentage);switch(t){case"SPHERE":E(l,e.wrapperQuaternion,c,d,n);break;case"CONE":L(l,e.wrapperQuaternion,c,d,r);break;case"CIRCLE":N(l,e.wrapperQuaternion,c,d,i);break;case"RECTANGLE":z(l,e.wrapperQuaternion,c,d,a);break;case"BOX":S(l,e.wrapperQuaternion,c,d,o)}},me=(n=ce,r)=>{const i=r||Date.now(),a={particleSystemId:ee++,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(ce,n,{applyToFirstObject:!1,skippedProperties:[]});let s=o.map||w();const{transform:l,duration:c,looping:d,startDelay:f,startLifetime:m,startSpeed:p,startSize:y,startRotation:v,startColor:g,startOpacity:I,gravity:h,simulationSpace:x,maxParticles:O,emission:b,shape:C,renderer:A,noise:_,velocityOverLifetime:T,onUpdate:P,onComplete:U,textureSheetAnimation:E,subEmitters:L,forceFields:S}=o,N=(t,n)=>t?new e.Vector3(t.x??0,t.y??0,t.z??0):n.clone(),z=(S??[]).map(t=>({isActive:t.isActive??!0,type:t.type??"POINT",position:N(t.position,new e.Vector3(0,0,0)),direction:N(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"}));"string"==typeof A?.blending&&(A.blending=se[A.blending]);const V=Array.from({length:O},()=>new e.Vector3),F=Array.from({length:O},()=>new e.Vector3);a.creationTimes=Array.from({length:O},()=>0);const k=Array.from({length:O},(e,t)=>O-1-t);T.isActive&&(a.linearVelocityData=Array.from({length:O},()=>({speed:new e.Vector3(T.linear.x?B(a.particleSystemId,T.linear.x,0):0,T.linear.y?B(a.particleSystemId,T.linear.y,0):0,T.linear.z?B(a.particleSystemId,T.linear.z,0):0),valueModifiers:{x:M(T.linear.x||0)?R(a.particleSystemId,T.linear.x):void 0,y:M(T.linear.y||0)?R(a.particleSystemId,T.linear.y):void 0,z:M(T.linear.z||0)?R(a.particleSystemId,T.linear.z):void 0}})),a.orbitalVelocityData=Array.from({length:O},()=>({speed:new e.Vector3(T.orbital.x?B(a.particleSystemId,T.orbital.x,0):0,T.orbital.y?B(a.particleSystemId,T.orbital.y,0):0,T.orbital.z?B(a.particleSystemId,T.orbital.z,0):0),valueModifiers:{x:M(T.orbital.x||0)?R(a.particleSystemId,T.orbital.x):void 0,y:M(T.orbital.y||0)?R(a.particleSystemId,T.orbital.y):void 0,z:M(T.orbital.z||0)?R(a.particleSystemId,T.orbital.z):void 0},positionOffset:new e.Vector3})));["startSize","startOpacity"].forEach(e=>{a.startValues[e]=Array.from({length:O},()=>B(a.particleSystemId,o[e],0))}),a.startValues.startColorR=Array.from({length:O},()=>0),a.startValues.startColorG=Array.from({length:O},()=>0),a.startValues.startColorB=Array.from({length:O},()=>0);["rotationOverLifetime"].forEach(t=>{const n=o[t];n.isActive&&(a.lifetimeValues[t]=Array.from({length:O},()=>e.MathUtils.randFloat(n.min,n.max)))}),a.noise={isActive:_.isActive,strength:_.strength,noisePower:.15*_.strength,positionAmount:_.positionAmount,rotationAmount:_.rotationAmount,sizeAmount:_.sizeAmount,sampler:_.isActive?new Z({seed:Math.random(),scale:_.frequency,octaves:_.octaves}):void 0,offsets:_.useRandomOffset?Array.from({length:O},()=>100*Math.random()):void 0},b.bursts&&b.bursts.length>0&&(a.burstStates=b.bursts.map(()=>({cyclesExecuted:0,lastCycleTime:0,probabilityPassed:!1})));const j="INSTANCED"===A.rendererType,G=e=>j?`instance${e.charAt(0).toUpperCase()}${e.slice(1)}`:e,H=j?"instanceOffset":"position",W={elapsed:{value:0},map:{value:s},tiles:{value:E.tiles},fps:{value:E.fps},useFPSForFrameIndex:{value:"FPS"===E.timeMode},backgroundColor:{value:A.backgroundColor},discardBackgroundColor:{value:A.discardBackgroundColor},backgroundColorTolerance:{value:A.backgroundColorTolerance},...j?{viewportHeight:{value:1}}:{}},X=new e.ShaderMaterial({uniforms:W,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\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\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 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\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 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\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\n #include <common>\n #include <logdepthbuf_pars_fragment>\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 #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\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\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 #include <logdepthbuf_fragment>\n }\n",transparent:A.transparent,blending:A.blending,depthTest:A.depthTest,depthWrite:A.depthWrite});let q;if(j){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=O,q=t}else q=new e.BufferGeometry;for(let e=0;e<O;e++)fe(a,C,p,V[e],F[e]);const K=new Float32Array(3*O);for(let e=0;e<O;e++)K[3*e]=V[e].x,K[3*e+1]=V[e].y,K[3*e+2]=V[e].z;const Y=j?new e.InstancedBufferAttribute(K,3):new e.BufferAttribute(K,3);q.setAttribute(H,Y),de({geometry:q,propertyName:G("isActive"),maxParticles:O,factory:0,instanced:j}),de({geometry:q,propertyName:G("lifetime"),maxParticles:O,factory:0,instanced:j}),de({geometry:q,propertyName:G("startLifetime"),maxParticles:O,factory:()=>1e3*B(a.particleSystemId,m,0),instanced:j}),de({geometry:q,propertyName:G("startFrame"),maxParticles:O,factory:()=>E.startFrame?B(a.particleSystemId,E.startFrame,0):0,instanced:j}),de({geometry:q,propertyName:G("size"),maxParticles:O,factory:(e,t)=>a.startValues.startSize[t],instanced:j}),de({geometry:q,propertyName:G("rotation"),maxParticles:O,factory:0,instanced:j});const $=Math.random();de({geometry:q,propertyName:G("colorR"),maxParticles:O,factory:()=>g.min.r+$*(g.max.r-g.min.r),instanced:j}),de({geometry:q,propertyName:G("colorG"),maxParticles:O,factory:()=>g.min.g+$*(g.max.g-g.min.g),instanced:j}),de({geometry:q,propertyName:G("colorB"),maxParticles:O,factory:()=>g.min.b+$*(g.max.b-g.min.b),instanced:j}),de({geometry:q,propertyName:G("colorA"),maxParticles:O,factory:0,instanced:j});const J=q.attributes,re=J[G("isActive")],ie=J[G("colorR")],ae=J[G("colorG")],oe=J[G("colorB")],le=J[G("colorA")],ue=J[G("startFrame")],ye=J[G("startLifetime")],ve=J[G("size")],ge=J[G("rotation")],Ie=J[G("lifetime")],he=J[H],xe=L??[],Oe=xe.filter(e=>"DEATH"===(e.trigger??"DEATH")),be=xe.filter(e=>"BIRTH"===e.trigger),Ce=new Map;for(const e of xe)Ce.set(e,[]);const Ae=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))}},_e=(t,n,r,i)=>{for(const a of t){const t=Ce.get(a),o=a.maxInstances??32;if(t.length>=o&&(Ae(t),t.length>=o))continue;const s=a.inheritVelocity??0,l=me({...a.config,looping:!1,transform:{...a.config.transform,position:new e.Vector3(n.x,n.y,n.z)},renderer:{...a.config.renderer??{},rendererType:A.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=(Ee||Te).parent;c&&c.add(l.instance),t.push(l)}};let Te=j?new e.Mesh(q,X):new e.Points(q,X);j&&(Te.onBeforeRender=t=>{const n=t.getSize(new e.Vector2);W.viewportHeight.value=n.y*t.getPixelRatio()}),Te.position.copy(l.position),Te.rotation.x=e.MathUtils.degToRad(l.rotation.x),Te.rotation.y=e.MathUtils.degToRad(l.rotation.y),Te.rotation.z=e.MathUtils.degToRad(l.rotation.z),Te.scale.copy(l.scale);const Pe={position:he,isActive:re,lifetime:Ie,startLifetime:ye,startFrame:ue,size:ve,rotation:ge,colorR:ie,colorG:ae,colorB:oe,colorA:le},Ue=i+1e3*B(a.particleSystemId,f);let Ee;"WORLD"===o.simulationSpace&&(Ee=new t,Ee.add(Te));const Le=Oe.length>0?(e,t,n,r)=>{const i=3*e;ne.set(t[i],t[i+1],t[i+2]),_e(Oe,ne,n,r)}:void 0,Se=be.length>0?(e,t,n,r)=>{const i=3*e;ne.set(t[i],t[i+1],t[i+2]),_e(be,ne,n,r)}:void 0,Ne={particleSystem:Te,wrapper:Ee,mappedAttributes:Pe,elapsedUniform:X.uniforms.elapsed,generalData:a,onUpdate:P,onComplete:U,creationTime:Ue,lastEmissionTime:Ue,duration:c,looping:d,simulationSpace:x,gravity:h,normalizedForceFields:z,emission:b,normalizedConfig:o,iterationCount:0,velocities:F,freeList:k,deactivateParticle:e=>{re.array[e]=0,le.array[e]=0,le.needsUpdate=!0,k.push(e)},activateParticle:({particleIndex:t,activationTime:n,position:r})=>{re.array[t]=1,a.creationTimes[t]=n,a.noise.offsets&&(a.noise.offsets[t]=100*Math.random());const i=Math.random();ie.array[t]=g.min.r+i*(g.max.r-g.min.r),ie.needsUpdate=!0,ae.array[t]=g.min.g+i*(g.max.g-g.min.g),ae.needsUpdate=!0,oe.array[t]=g.min.b+i*(g.max.b-g.min.b),oe.needsUpdate=!0,a.startValues.startColorR[t]=ie.array[t],a.startValues.startColorG[t]=ae.array[t],a.startValues.startColorB[t]=oe.array[t],ue.array[t]=E.startFrame?B(a.particleSystemId,E.startFrame,0):0,ue.needsUpdate=!0,ye.array[t]=1e3*B(a.particleSystemId,m,a.normalizedLifetimePercentage),ye.needsUpdate=!0,a.startValues.startSize[t]=B(a.particleSystemId,y,a.normalizedLifetimePercentage),ve.array[t]=a.startValues.startSize[t],ve.needsUpdate=!0,a.startValues.startOpacity[t]=B(a.particleSystemId,I,a.normalizedLifetimePercentage),le.array[t]=a.startValues.startOpacity[t],le.needsUpdate=!0,ge.array[t]=B(a.particleSystemId,v,a.normalizedLifetimePercentage),ge.needsUpdate=!0,o.rotationOverLifetime.isActive&&(a.lifetimeValues.rotationOverLifetime[t]=e.MathUtils.randFloat(o.rotationOverLifetime.min,o.rotationOverLifetime.max)),fe(a,C,p,V[t],F[t]);const s=Math.floor(3*t);he.array[s]=r.x+V[t].x,he.array[s+1]=r.y+V[t].y,he.array[s+2]=r.z+V[t].z,he.needsUpdate=!0,a.linearVelocityData&&a.linearVelocityData[t].speed.set(o.velocityOverLifetime.linear.x?B(a.particleSystemId,o.velocityOverLifetime.linear.x,0):0,o.velocityOverLifetime.linear.y?B(a.particleSystemId,o.velocityOverLifetime.linear.y,0):0,o.velocityOverLifetime.linear.z?B(a.particleSystemId,o.velocityOverLifetime.linear.z,0):0),a.orbitalVelocityData&&(a.orbitalVelocityData[t].speed.set(o.velocityOverLifetime.orbital.x?B(a.particleSystemId,o.velocityOverLifetime.orbital.x,0):0,o.velocityOverLifetime.orbital.y?B(a.particleSystemId,o.velocityOverLifetime.orbital.y,0):0,o.velocityOverLifetime.orbital.z?B(a.particleSystemId,o.velocityOverLifetime.orbital.z,0):0),a.orbitalVelocityData[t].positionOffset.set(V[t].x,V[t].y,V[t].z)),Ie.array[t]=0,Ie.needsUpdate=!0,D({delta:0,generalData:a,normalizedConfig:o,attributes:Pe,particleLifetimePercentage:0,particleIndex:t})},onParticleDeath:Le,onParticleBirth:Se};te.push(Ne);return{instance:Ee||Te,resumeEmitter:()=>a.isEnabled=!0,pauseEmitter:()=>a.isEnabled=!1,dispose:()=>{for(const e of Ce.values()){for(const t of e)t.dispose();e.length=0}(e=>{te=te.filter(({particleSystem:t,wrapper:n,generalData:{particleSystemId:r}})=>t!==e&&n!==e||(u(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))})(Te)},update:e=>{pe(Ne,e);for(const t of Ce.values())for(const n of t)n.update(e)}}},pe=(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:I,deactivateParticle:h,activateParticle:x,simulationSpace:O,gravity:b,normalizedForceFields:C,onParticleDeath:A,onParticleBirth:_,mappedAttributes:T}=e,P=C.length>0,U=t-d,E=U%(1e3*m);a.normalizedLifetimePercentage=Math.max(Math.min(E/(1e3*m),1),0);const{lastWorldPosition:L,currentWorldPosition:S,worldPositionChange:N,lastWorldQuaternion:z,worldQuaternion:w,worldEuler:M,gravityVelocity:R,isEnabled:V}=a;l?.parent&&a.wrapperQuaternion.copy(l.parent.quaternion),re.copy(L),c.value=r,s.getWorldPosition(S),-99999!==L.x&&N.set(S.x-L.x,S.y-L.y,S.z-L.z),V&&(a.distanceFromLastEmitByDistance+=N.length()),s.getWorldPosition(L),s.getWorldQuaternion(w),-99999!==z.x&&z.x===w.x&&z.y===w.y&&z.z===w.z||(M.setFromQuaternion(w),z.copy(w),R.set(L.x,L.y+b,L.z),s.worldToLocal(R));const F=a.creationTimes,Q=T.isActive.array,k=T.startLifetime.array,j=T.position.array,G=T.lifetime.array,H=F.length;let W=!1,X=!1;oe.delta=n,oe.generalData=a,oe.normalizedConfig=y,oe.attributes=T;for(let e=0;e<H;e++)if(Q[e]){const r=t-F[e];if(r>k[e])A&&A(e,j,g[e],t),h(e);else{const t=g[e];if(t.x-=R.x*n,t.y-=R.y*n,t.z-=R.z*n,P&&J({particleSystemId:a.particleSystemId,forceFields:C,velocity:t,positionArr:j,positionIndex:3*e,delta:n,systemLifetimePercentage:a.normalizedLifetimePercentage}),0!==b||0!==t.x||0!==t.y||0!==t.z||0!==N.x||0!==N.y||0!==N.z){const r=3*e;"WORLD"===O&&(j[r]-=N.x,j[r+1]-=N.y,j[r+2]-=N.z),j[r]+=t.x*n,j[r+1]+=t.y*n,j[r+2]+=t.z*n,W=!0}G[e]=r,X=!0,oe.particleLifetimePercentage=r/k[e],oe.particleIndex=e,D(oe)}}if(W&&(T.position.needsUpdate=!0),X&&(T.lifetime.needsUpdate=!0),V&&(p||U<1e3*m)){const o=t-f,l=u.rateOverTime?Math.floor(B(a.particleSystemId,u.rateOverTime,a.normalizedLifetimePercentage)*(o/1e3)):0,c=u.rateOverDistance?B(a.particleSystemId,u.rateOverDistance,a.normalizedLifetimePercentage):0,d=c>0&&a.distanceFromLastEmitByDistance>0?Math.floor(a.distanceFromLastEmitByDistance/(1/c)):0,m=d>0;m&&(ie.x=(S.x-re.x)/d,ie.y=(S.y-re.y)/d,ie.z=(S.z-re.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=E;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(B(a.particleSystemId,i.count,a.normalizedLifetimePercentage))}o.cyclesExecuted++,o.lastCycleTime=n}}}if(y>0){let n=0;for(let r=0;r<y&&0!==I.length;r++){const r=I.pop();ae.x=0,ae.y=0,ae.z=0,m&&n<d&&(ae.x=ie.x*n,ae.y=ie.y*n,ae.z=ie.z*n,n++),x({particleIndex:r,activationTime:t,position:ae}),_&&_(r,T.position.array,g[r],t),e.lastEmissionTime=t}}i&&i({particleSystem:s,delta:n,elapsed:r,lifetime:U,normalizedLifetime:E,iterationCount:v+1})}else o&&o({particleSystem:s})},ue=e=>{te.forEach(t=>pe(t,e))};export{g as CurveFunctionId,b as EmitFrom,U as ForceFieldFalloff,T as ForceFieldType,A as LifeTimeCurve,P as RendererType,O as Shape,x as SimulationSpace,_ as SubEmitterTrigger,C as TimeMode,D as applyModifiers,se as blendingMap,S as calculateRandomPositionAndVelocityOnBox,N as calculateRandomPositionAndVelocityOnCircle,L as calculateRandomPositionAndVelocityOnCone,z as calculateRandomPositionAndVelocityOnRectangle,E as calculateRandomPositionAndVelocityOnSphere,B as calculateValue,p as createBezierCurveFunction,w as createDefaultParticleTexture,me as createParticleSystem,I as curveFunctionIdMap,y as getBezierCacheSize,h as getCurveFunction,R as getCurveFunctionFromConfig,le as getDefaultParticleSystemConfig,M as isLifeTimeCurve,u as removeBezierCurveFunction,ue as updateParticleSystems};//# sourceMappingURL=three-particles.min.js.map
|