text: import{Color as t,NoBlending as e,AdditiveBlending as i,MultiplyBlending as o,NormalBlending as r,BufferGeometry as s,BufferAttribute as n,Points as a,Vector3 as l,ShaderMaterial as h,VertexColors as p}from"three";var c={getRandomBetween:function(t,e){return Math.random()*(e-t)+t},getRandomWithSpread:function(t,e){return e?this.getRandomBetween(t,t+e):t},getRandomColorBetween:function(e,i){return i?new t(this.getRandomBetween(e.r,i.r),this.getRandomBetween(e.g,i.g),this.getRandomBetween(e.b,i.b)):e?e.clone():new t},getRandomVectorBetween:function(t,e){return e?new l(this.getRandomBetween(t.x,e.x),this.getRandomBetween(t.y,e.y),this.getRandomBetween(t.z,e.z)):t?t.clone():new l},lerpColors:function(t,e,i){return t.clone().lerp(e,i)},lerp:function(t,e,i){return t*(1-i)+e*i},randomizerOrValue:function(t){return(t.generate?t.generate():t)||0}},d=function(t){this.system=t,this.reset()},u={worldPosition:{configurable:!0}};function m(t,e){return t?t.generate?t.generate():t.clone():e?null:new l}function f(e,i){return e?e.generate?e.generate():e.clone():i?null:new t(1,1,1)}d.prototype.reset=function(){var t=this.system.options.particles;this.age=0,this.finished=!1,this.gravity=t.gravity,this.velocity=m(t.velocity),t.velocityBonus&&this.velocity.add(t.velocityBonus),this.acceleration=m(t.acceleration,!0),this.position=m(t.offset),this.ttl=c.getRandomWithSpread(t.ttl||1,t.ttlExtra)||1,this.alpha=this.startAlpha=this.endAlpha=null,this.startAlphaChangeAt=(t.startAlphaChangeAt||0)/this.ttl,t.fade&&(void 0!==t.alpha?this.alpha=c.randomizerOrValue(t.alpha):(this.startAlpha=c.randomizerOrValue(t.startAlpha),this.endAlpha=c.randomizerOrValue(t.endAlpha))),this.colorize=Boolean(t.colorize),this.color=this.startColor=this.endColor=null,this.startColorChangeAt=(t.startColorChangeAt||0)/this.ttl,this.colorize&&(t.color?this.color=f(t.color):(this.startColor=f(t.startColor),this.endColor=f(t.endColor))),this.size=this.startSize=this.endSize=null,this.startSizeChangeAt=(t.startSizeChangeAt||0)/this.ttl,t.scaling&&(void 0!==t.size?this.size=c.randomizerOrValue(t.size):(this.startSize=c.randomizerOrValue(t.startSize),this.endSize=c.randomizerOrValue(t.endSize))),this.rotation=this.rotationSpeed=null,t.rotating&&(this.rotation=c.randomizerOrValue(t.rotation||0),this.rotationSpeed=c.randomizerOrValue(t.rotationSpeed||0)),this.startWorldPosition=null,this.onUpdate=t.onUpdate,t.onSpawn&&t.onSpawn(this)},d.prototype.update=function(t,e){if(!this.finished){0===this.age?(this.system.options.particles.worldPosition&&(this.startWorldPosition=this.system.getWorldPosition()),null===this.alpha&&null===this.startAlpha||this.system.setAlpha(t,this.alpha||this.startAlpha),null===this.color&&null===this.startColor||this.system.setColor(t,this.color||this.startColor),null===this.size&&null===this.startSize||this.system.setSize(t,this.size||this.startSize),null!==this.rotation&&this.system.setRotation(t,this.rotation)):(this.startColor&&this.age>=this.startColorChangeAt&&this.system.setColor(t,c.lerpColors(this.startColor,this.endColor,this.startColorChangeAt?(this.age-this.startColorChangeAt)/(1-this.startColorChangeAt):this.age)),null!=this.startAlpha&&this.age>=this.startAlphaChangeAt&&this.system.setAlpha(t,c.lerp(this.startAlpha,this.endAlpha,this.startAlphaChangeAt?(this.age-this.startAlphaChangeAt)/(1-this.startAlphaChangeAt):this.age)),null!=this.startSize&&this.age>=this.startSizeChangeAt&&this.system.setSize(t,c.lerp(this.startSize,this.endSize,this.startSizeChangeAt?(this.age-this.startSizeChangeAt)/(1-this.startSizeChangeAt):this.age))),this.gravity&&this.velocity&&(this.velocity.y+=this.gravity*e),this.rotationSpeed&&(this.rotation+=this.rotationSpeed*e,this.system.setRotation(t,this.rotation)),this.velocity&&(this.position.x+=this.velocity.x*e,this.position.y+=this.velocity.y*e,this.position.z+=this.velocity.z*e);var i=this.position;if(this.startWorldPosition){var o=this.system.getWorldPosition();o.sub(this.startWorldPosition),i=i.clone().sub(o)}this.system.setPosition(t,i),this.acceleration&&this.velocity&&(this.velocity.x+=this.acceleration.x*e,this.velocity.y+=this.acceleration.y*e,this.velocity.z+=this.acceleration.z*e),this.age+=e/this.ttl,this.onUpdate&&this.onUpdate(this),this.age>1&&(this.age=1,this.finished=!0)}},u.worldPosition.get=function(){return this.system.getWorldPosition().add(this.position)},Object.defineProperties(d.prototype,u);var y=function(e){this.options=e;var i={globalColor:{value:new t(e.color||16777215)},rendererScale:{value:1}},o="";e.perspective&&(o+="#define PERSPECTIVE\n"),e.map&&(o+="#define TEXTURE\n",i.texture={value:e.map}),e.perParticleColor&&(o+="#define COLORING\n"),e.perParticleRotation&&(o+="#define ROTATION\n"),e.constSize&&(o+="#define CONST_SIZE\n",i.constSize={value:e.constSize}),e.alphaTest&&(o+="#define ALPHA_TEST\n");var r=new h({uniforms:i,vertexShader:(o+="\n")+"\n// attributes we get from geometry\nattribute float alpha;\n\n// per-particle size\n#ifdef CONST_SIZE\n    uniform float constSize;\n#else\n    attribute float size;\n#endif\n\n// per-particle rotation\n#ifdef ROTATION\n    attribute float rotation;\n#endif\n\n// system scale when using perspective mode\n#ifdef PERSPECTIVE\n    uniform float rendererScale;\n#endif\n\n// output params for fragment shader\nvarying float vAlpha;\n\n// set per-particle color\n#ifdef COLORING\n    varying vec3 vColor;\n#endif\n\n// get per-particle rotation\n#ifdef ROTATION\n    varying float vRotation;\n#endif\n\n// vertex shader main\nvoid main() \n{\n    // alpha and color\n    vAlpha = alpha;\n\n    // set color\n    #ifdef COLORING\n        vColor = color;\n    #endif\n\n    // set const size\n    #ifdef CONST_SIZE\n        float size = constSize;\n    #endif\n\n    // set position\n    vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n    gl_Position = projectionMatrix * mvPosition;\n\n    // apply rotation\n    #ifdef ROTATION\n        vRotation = rotation;\n    #endif\n    \n    // set size - either perspective or constant\n    #ifdef PERSPECTIVE\n        gl_PointSize = size * (rendererScale / length(mvPosition.xyz));\n    #else\n        gl_PointSize = size;\n    #endif\n}\n",fragmentShader:o+"\n// material uniforms\nuniform vec3 globalColor;\n\n// params we get from vertex shader\nvarying float vAlpha;\n\n// per-particle color from vertex shader\n#ifdef COLORING\n    varying vec3 vColor;\n#endif\n\n// per-particle rotation from vertex shader\n#ifdef ROTATION\n    varying float vRotation;\n#endif\n\n// diffuse texture\n#ifdef TEXTURE\n    uniform sampler2D texture;\n#endif\n\n// fragment shader main\nvoid main() \n{\n    // set default color if don't have per-particle colors\n    #ifndef COLORING\n        vec3 vColor = vec3(1,1,1);\n    #endif\n\n    // texture\n    #ifdef TEXTURE\n\n        // use rotation (rotate texture)\n        #ifdef ROTATION\n            float mid = 0.5;\n            vec2 rotated = vec2(cos(vRotation) * (gl_PointCoord.x - mid) + sin(vRotation) * (gl_PointCoord.y - mid) + mid,\n                          cos(vRotation) * (gl_PointCoord.y - mid) - sin(vRotation) * (gl_PointCoord.x - mid) + mid);\n            vec4 texture = texture2D(texture,  rotated);\n        // no rotation\n        #else\n            vec2 coords = vec2((gl_PointCoord.x - 0.5) + 0.5, (gl_PointCoord.y - 0.5) + 0.5);\n            vec4 texture = texture2D(texture, coords);\n        #endif\n\n        // get color with texture\n        gl_FragColor = vec4( globalColor * vColor, vAlpha ) * texture;\n        \n    // no texture (colors only)\n    #else\n        gl_FragColor = vec4( globalColor * vColor, vAlpha );\n    #endif\n\n    // check if need to discard pixel\n    #ifdef ALPHA_TEST\n        if (gl_FragColor.a < 0.00001) { discard; }\n    #endif\n}\n",transparent:Boolean(e.transparent),blending:e.blending,vertexColors:p,depthWrite:Boolean(e.depthWrite),depthTest:Boolean(e.depthTest)});this.material=r};y.prototype.dispose=function(){this.material.dispose()},y.prototype.setBaseScale=function(t){this.options.perspective&&(this.material.uniforms.rendererScale.value=t)};var g=function(l){l.particles=l.particles||{worldPosition:!0},l.system=l.system||{},this.options=l;var h=function(t){return null!=t},p=l.particles;if("number"==typeof l.particles.size&&(console.warn("Note: replaced 'size' with 'globalSize' property since its more efficient and provided size value was constant anyway."),l.particles.globalSize=l.particles.size,delete l.particles.size),l.particles.color instanceof t&&(console.warn("Note: replaced 'color' with 'globalColor' property since its more efficient and you provided color value was constant anyway."),l.particles.globalColor=l.particles.color,delete l.particles.color),l.particles.fade=h(p.startAlpha)||h(p.alpha),l.particles.rotating=h(p.rotationSpeed)||h(p.rotation),l.particles.colorize=h(p.color)||h(p.startColor),l.particles.scaling=h(p.size)||h(p.startSize),h(p.startAlpha)&&!h(p.endAlpha))throw new Error("When providing 'startAlpha' you must also provide 'endAlpha'!");if(h(p.startAlpha)&&h(p.alpha))throw new Error("When providing 'alpha' you can't also provide 'startAlpha'!");if(h(p.startColor)&&!h(p.endColor))throw new Error("When providing 'startColor' you must also provide 'endColor'!");if(h(p.startColor)&&h(p.color))throw new Error("When providing 'color' you can't also provide 'startColor'!");if(h(p.startSize)&&!h(p.endSize))throw new Error("When providing 'startSize' you must also provide 'endSize'!");if(h(p.startSize)&&h(p.size))throw new Error("When providing 'size' you can't also provide 'startSize'!");var c=l.system.particlesCount||10,u=l.particles.blending||"opaque",m={opaque:e,additive:i,multiply:o,blend:r}[u];if(this._emitters=[],l.system.emitters)if(l.system.emitters instanceof Array)for(var f=0;f<l.system.emitters.length;++f)this.addEmitter(l.system.emitters[f]);else this.addEmitter(l.system.emitters);var g="opaque"!==u;this.particlesGeometry=new s;var v=void 0===l.system.perspective||Boolean(l.system.perspective),z=new y({size:l.particles.size||10,color:l.particles.globalColor||16777215,blending:m,perspective:v,transparent:g,map:l.particles.texture,perParticleColor:Boolean(l.particles.colorize),alphaTest:"blend"===u&&h(l.particles.texture),constSize:h(l.particles.globalSize)?l.particles.globalSize:null,depthWrite:!h(l.system.depthWrite)||l.system.depthWrite,depthTest:!h(l.system.depthTest)||l.system.depthTest,perParticleRotation:l.particles.rotating});this.material=z,this.speed=l.system.speed||1,this.reset(),this._aliveParticles=[],this._deadParticles=[];for(var C=new Float32Array(3*c),S=l.particles.colorize?new Float32Array(3*c):null,w=l.particles.fade?new Float32Array(1*c):null,_=l.particles.scaling?new Float32Array(1*c):null,A=l.particles.rotating?new Float32Array(1*c):null,P=0;P<c;P++){var x=3*P;C[x]=C[x+1]=C[x+2]=0,S&&(S[x]=S[x+1]=S[x+2]=1),w&&(w[P]=1),_&&(_[P]=1),A&&(A[P]=0),this._deadParticles.push(new d(this))}this.particlesGeometry.setAttribute("position",new n(C,3)),w&&this.particlesGeometry.setAttribute("alpha",new n(w,1)),S&&this.particlesGeometry.setAttribute("color",new n(S,3)),_&&this.particlesGeometry.setAttribute("size",new n(_,1)),A&&this.particlesGeometry.setAttribute("rotation",new n(A,1)),this.particlesGeometry.setDrawRange(0,0),this.material.setBaseScale(l.system.scale||400);var R=new a(this.particlesGeometry,this.material.material);R.sortParticles=g,this.particleSystem=R,this._positionDirty=!0,this._colorsDirty=Boolean(S),this._alphaDirty=Boolean(w),this._rotateDirty=Boolean(A),l.container&&this.addTo(l.container)},v={finished:{configurable:!0},ttlExpired:{configurable:!0},particlesCount:{configurable:!0},maxParticlesCount:{configurable:!0}};g.prototype.addEmitter=function(t){this._emitters.push(t)},g.prototype.dispose=function(){this.particlesGeometry.dispose(),this.material.dispose()},v.finished.get=function(){return this.ttlExpired&&0===this.particlesCount},v.ttlExpired.get=function(){return void 0!==this.ttl&&this.ttl<=0},g.prototype.reset=function(){this.ttl=this.options.system.ttl,this.age=0,this._timeToUpdateBS=0},g.prototype.getWorldPosition=function(){var t=new l;return this.particleSystem.getWorldPosition(t),t},g.prototype.addTo=function(t){t.add(this.particleSystem)},g.prototype.setColor=function(t,e){var i=this.particlesGeometry.attributes.color.array;i[t*=3]=e.r,i[t+1]=e.g,i[t+2]=e.b,this._colorsDirty=!0},g.prototype.setPosition=function(t,e){var i=this.particlesGeometry.attributes.position.array;i[t*=3]=e.x,i[t+1]=e.y,i[t+2]=e.z,this._positionDirty=!0},g.prototype.setAlpha=function(t,e){this.particlesGeometry.attributes.alpha.array[t]=e,this._alphaDirty=!0},g.prototype.setRotation=function(t,e){this.particlesGeometry.attributes.rotation.array[t]=e,this._rotateDirty=!0},g.prototype.setSize=function(t,e){this.particlesGeometry.attributes.size.array[t]=e,this._sizeDirty=!0},v.particlesCount.get=function(){return this._aliveParticles.length},v.maxParticlesCount.get=function(){return this._aliveParticles.length+this._deadParticles.length},g.prototype.removeAndDisposeIfFinished=function(){return!!this.finished&&(this.removeSelf(),this.dispose(),!0)},g.prototype.update=function(t){if(void 0===t){var e=(new Date).getTime()/1e3;t=e-this._lastTime||0,this._lastTime=e}if(0!==t){void 0!==this.ttl&&this.ttl>0&&(this.ttl-=t),this.dt=t*=this.speed,this.age+=t;var i=this._aliveParticles.length;if(!this.ttlExpired)for(var o=0;o<this._emitters.length;++o){var r=this._emitters[o].update(t,this);r&&this.spawnParticles(r)}for(o=this._aliveParticles.length-1;o>=0;--o){var s=this._aliveParticles[o];s.update(o,t),s.finished&&(this._aliveParticles.splice(o,1),this._deadParticles.push(s))}i!==this._aliveParticles.length&&this.particlesGeometry.setDrawRange(0,this._aliveParticles.length),this.particlesGeometry.attributes.position.needsUpdate=this._positionDirty,this._needBoundingSphereUpdate=this._needBoundingSphereUpdate||this._positionDirty,this._positionDirty=!1,this._colorsDirty&&(this.particlesGeometry.attributes.color.needsUpdate=!0,this._colorsDirty=!1),this._alphaDirty&&(this.particlesGeometry.attributes.alpha.needsUpdate=!0,this._alphaDirty=!1),this._sizeDirty&&(this.particlesGeometry.attributes.size.needsUpdate=!0,this._sizeDirty=!1),this._rotateDirty&&(this.particlesGeometry.attributes.rotation.needsUpdate=!0,this._rotateDirty=!1),this._needBoundingSphereUpdate&&(this._timeToUpdateBS-=t,this._timeToUpdateBS<=0&&(this._timeToUpdateBS=.2,this.particlesGeometry.computeBoundingSphere())),this.finished||this.options.system.onUpdate&&this.options.system.onUpdate(this)}},g.prototype.spawnParticles=function(t){for(var e=0;e<t;++e){if(0===this._deadParticles.length)return;var i=this._deadParticles.pop();i.reset(),this._aliveParticles.push(i)}},g.prototype.removeSelf=function(){this.particleSystem.parent&&this.particleSystem.parent.remove(this.particleSystem)},Object.defineProperties(g.prototype,v);var z=c.randomizerOrValue,C=function(t){this.options=t,t.interval=t.interval||1,this.age=0,this.timeToSpawn=Math.random()*z(t.interval)};C.prototype.update=function(t,e){var i=0;return 0===this.age&&this.options.onSpawnBurst&&(i+=z(this.options.onSpawnBurst)),this.age+=t,this.options.onInterval?(this.timeToSpawn-=t,this.timeToSpawn<=0&&(this.timeToSpawn=z(this.options.interval),i+=z(this.options.onInterval)),this.options.detoretingMinTtl&&e.ttl<this.options.detoretingMinTtl&&(i*=e.ttl/this.options.detoretingMinTtl),i):i};var S=function(){};function w(){return 2*Math.random()-1}S.prototype.generate=function(){throw new Error("Not implemented.")};var _={Randomizer:S,BoxRandomizer:function(t){function e(e,i){t.call(this),this.min=e||new l(-1,-1,-1),this.max=i||new l(1,1,1)}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.generate=function(){return c.getRandomVectorBetween(this.min,this.max)},e}(S),SphereRandomizer:function(t){function e(e,i,o,r,s){t.call(this),this.maxRadius=e||1,this.minRadius=i||0,this.scaler=o,this.minVector=r,this.maxVector=s}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.generate=function(){var t=new l(w(),w(),w());return(this.minVector||this.maxVector)&&t.clamp(this.minVector||new l(-1,-1,-1),this.maxVector||new l(1,1,1)),t.normalize().multiplyScalar(c.getRandomBetween(this.minRadius,this.maxRadius)),this.scaler&&t.multiply(this.scaler),t},e}(S),ColorsRandomizer:function(e){function i(i,o){e.call(this),this.min=i||new t(0,0,0),this.max=o||new t(1,1,1)}return e&&(i.__proto__=e),(i.prototype=Object.create(e&&e.prototype)).constructor=i,i.prototype.generate=function(){return c.getRandomColorBetween(this.min,this.max)},i}(S),MinMaxRandomizer:function(t){function e(e,i){t.call(this),this.min=e,this.max=i}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.generate=function(){return c.getRandomBetween(this.min,this.max)},e}(S)};export{g as ParticlesSystem,d as Particle,C as Emitter,c as Utils,_ as Randomizers};
  //# sourceMappingURL=partykals.module.js.map
  