@newkrok/three-particles 2.0.2 → 2.1.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 +6 -1
- package/dist/bundle-report.json +1 -1
- package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts +1 -1
- package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts.map +1 -1
- package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.js +6 -1
- package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.d.ts +1 -1
- package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.d.ts.map +1 -1
- package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.js +5 -0
- package/dist/js/effects/three-particles/three-particles-utils.d.ts +1 -1
- package/dist/js/effects/three-particles/three-particles-utils.js +9 -9
- package/dist/js/effects/three-particles/three-particles.js +1 -1
- package/dist/three-particles.min.js +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/images/logo-colorful.png" alt="THREE Particles Logo" width="150" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
# THREE Particles
|
|
2
6
|
[](https://github.com/NewKrok/three-particles/actions/workflows/test.yml)
|
|
3
7
|
[](https://www.npmjs.com/package/@newkrok/three-particles)
|
|
@@ -18,6 +22,8 @@ Particle system for ThreeJS.
|
|
|
18
22
|
|
|
19
23
|
* **Editor & Live Demo:** [https://newkrok.com/three-particles-editor/index.html](https://newkrok.com/three-particles-editor/index.html)
|
|
20
24
|
* **CodePen Basic Example:** [https://codepen.io/NewKrok/pen/GgRzEmP](https://codepen.io/NewKrok/pen/GgRzEmP)
|
|
25
|
+
* **CodePen Fire Animation:** [https://codepen.io/NewKrok/pen/ByabNRJ](https://codepen.io/NewKrok/pen/ByabNRJ)
|
|
26
|
+
* **CodePen Projectile Simulation:** [https://codepen.io/NewKrok/pen/jEEErZy](https://codepen.io/NewKrok/pen/jEEErZy)
|
|
21
27
|
* **Video - Projectiles:** [https://youtu.be/Q352JuxON04](https://youtu.be/Q352JuxON04)
|
|
22
28
|
* **Video - First Preview:** [https://youtu.be/dtN_bndvoGU](https://youtu.be/dtN_bndvoGU)
|
|
23
29
|
|
|
@@ -34,7 +40,6 @@ npm install @newkrok/three-particles
|
|
|
34
40
|
Include the script directly in your HTML:
|
|
35
41
|
|
|
36
42
|
```html
|
|
37
|
-
<!-- Please verify this path points to the correct UMD/IIFE bundle -->
|
|
38
43
|
<script src="https://cdn.jsdelivr.net/npm/@newkrok/three-particles@latest/dist/three-particles.min.js"></script>
|
|
39
44
|
<!-- or -->
|
|
40
45
|
<script src="https://unpkg.com/@newkrok/three-particles@latest/dist/three-particles.min.js"></script>
|
package/dist/bundle-report.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
[{"label":"three-particles.min.js","isAsset":true,"statSize":
|
|
1
|
+
[{"label":"three-particles.min.js","isAsset":true,"statSize":82622,"groups":[{"label":"dist","path":"./dist","statSize":72757,"groups":[{"id":69,"label":"index.js + 14 modules (concatenated)","path":"./dist/index.js + 14 modules (concatenated)","statSize":72757,"parsedSize":0,"gzipSize":0,"concatenated":true,"groups":[{"label":"dist","path":"./dist/index.js + 14 modules (concatenated)/dist","statSize":52974,"groups":[{"id":null,"label":"index.js","path":"./dist/index.js + 14 modules (concatenated)/dist/index.js","statSize":426,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"label":"js/effects/three-particles","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles","statSize":52548,"groups":[{"id":null,"label":"three-particles-bezier.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/three-particles-bezier.js","statSize":2350,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"three-particles-curves.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/three-particles-curves.js","statSize":2628,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"three-particles-modifiers.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/three-particles-modifiers.js","statSize":4748,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"three-particles-utils.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/three-particles-utils.js","statSize":8634,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"three-particles.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/three-particles.js","statSize":31198,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"label":"shaders","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/shaders","statSize":2990,"groups":[{"id":null,"label":"particle-system-fragment-shader.glsl.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.js","statSize":2039,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"particle-system-vertex-shader.glsl.js","path":"./dist/index.js + 14 modules (concatenated)/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.js","statSize":951,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"label":"node_modules","path":"./dist/index.js + 14 modules (concatenated)/node_modules","statSize":19741,"groups":[{"label":"@newkrok/three-utils/src/js/newkrok/three-utils","path":"./dist/index.js + 14 modules (concatenated)/node_modules/@newkrok/three-utils/src/js/newkrok/three-utils","statSize":5203,"groups":[{"id":null,"label":"index.js","path":"./dist/index.js + 14 modules (concatenated)/node_modules/@newkrok/three-utils/src/js/newkrok/three-utils/index.js","statSize":349,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"callback-utils.js","path":"./dist/index.js + 14 modules (concatenated)/node_modules/@newkrok/three-utils/src/js/newkrok/three-utils/callback-utils.js","statSize":1350,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"object-utils.js","path":"./dist/index.js + 14 modules (concatenated)/node_modules/@newkrok/three-utils/src/js/newkrok/three-utils/object-utils.js","statSize":2458,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"id":null,"label":"time-utils.js","path":"./dist/index.js + 14 modules (concatenated)/node_modules/@newkrok/three-utils/src/js/newkrok/three-utils/time-utils.js","statSize":1046,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"label":"three/examples/jsm/misc","path":"./dist/index.js + 14 modules (concatenated)/node_modules/three/examples/jsm/misc","statSize":1617,"groups":[{"id":null,"label":"Gyroscope.js","path":"./dist/index.js + 14 modules (concatenated)/node_modules/three/examples/jsm/misc/Gyroscope.js","statSize":1617,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true},{"label":"three-noise/build","path":"./dist/index.js + 14 modules (concatenated)/node_modules/three-noise/build","statSize":12921,"groups":[{"id":null,"label":"three-noise.module.js","path":"./dist/index.js + 14 modules (concatenated)/node_modules/three-noise/build/three-noise.module.js","statSize":12921,"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}],"parsedSize":0,"gzipSize":0,"inaccurateSizes":true}]}],"parsedSize":0,"gzipSize":0},{"label":"node_modules/easing-functions","path":"./node_modules/easing-functions","statSize":9865,"groups":[{"id":300,"label":"index.js","path":"./node_modules/easing-functions/index.js","statSize":9865}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"main":true}}]
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const ParticleSystemFragmentShader = "\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 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
|
|
1
|
+
declare const ParticleSystemFragmentShader = "\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";
|
|
2
2
|
export default ParticleSystemFragmentShader;
|
|
3
3
|
//# sourceMappingURL=particle-system-fragment-shader.glsl.d.ts.map
|
package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle-system-fragment-shader.glsl.d.ts","sourceRoot":"","sources":["../../../../../src/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"particle-system-fragment-shader.glsl.d.ts","sourceRoot":"","sources":["../../../../../src/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,4BAA4B,2+DAqEjC,CAAC;AAEF,eAAe,4BAA4B,CAAC"}
|
|
@@ -14,6 +14,9 @@ const ParticleSystemFragmentShader = `
|
|
|
14
14
|
varying float vRotation;
|
|
15
15
|
varying float vStartFrame;
|
|
16
16
|
|
|
17
|
+
#include <common>
|
|
18
|
+
#include <logdepthbuf_pars_fragment>
|
|
19
|
+
|
|
17
20
|
void main()
|
|
18
21
|
{
|
|
19
22
|
gl_FragColor = vColor;
|
|
@@ -60,7 +63,9 @@ const ParticleSystemFragmentShader = `
|
|
|
60
63
|
|
|
61
64
|
gl_FragColor = gl_FragColor * rotatedTexture;
|
|
62
65
|
|
|
63
|
-
if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance
|
|
66
|
+
if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;
|
|
67
|
+
|
|
68
|
+
#include <logdepthbuf_fragment>
|
|
64
69
|
}
|
|
65
70
|
`;
|
|
66
71
|
export default ParticleSystemFragmentShader;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const ParticleSystemVertexShader = "\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 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";
|
|
1
|
+
declare const ParticleSystemVertexShader = "\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";
|
|
2
2
|
export default ParticleSystemVertexShader;
|
|
3
3
|
//# sourceMappingURL=particle-system-vertex-shader.glsl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle-system-vertex-shader.glsl.d.ts","sourceRoot":"","sources":["../../../../../src/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"particle-system-vertex-shader.glsl.d.ts","sourceRoot":"","sources":["../../../../../src/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,0BAA0B,64BAmC/B,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
|
@@ -16,6 +16,9 @@ const ParticleSystemVertexShader = `
|
|
|
16
16
|
varying float vRotation;
|
|
17
17
|
varying float vStartFrame;
|
|
18
18
|
|
|
19
|
+
#include <common>
|
|
20
|
+
#include <logdepthbuf_pars_vertex>
|
|
21
|
+
|
|
19
22
|
void main()
|
|
20
23
|
{
|
|
21
24
|
vColor = vec4(colorR, colorG, colorB, colorA);
|
|
@@ -27,6 +30,8 @@ const ParticleSystemVertexShader = `
|
|
|
27
30
|
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
28
31
|
gl_PointSize = size * (100.0 / length(mvPosition.xyz));
|
|
29
32
|
gl_Position = projectionMatrix * mvPosition;
|
|
33
|
+
|
|
34
|
+
#include <logdepthbuf_vertex>
|
|
30
35
|
}
|
|
31
36
|
`;
|
|
32
37
|
export default ParticleSystemVertexShader;
|
|
@@ -31,6 +31,6 @@ export declare const calculateRandomPositionAndVelocityOnRectangle: (position: T
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const createDefaultParticleTexture: () => THREE.CanvasTexture | null;
|
|
33
33
|
export declare const isLifeTimeCurve: (value: Constant | RandomBetweenTwoConstants | LifetimeCurve) => value is LifetimeCurve;
|
|
34
|
-
export declare const getCurveFunctionFromConfig: (particleSystemId: number,
|
|
34
|
+
export declare const getCurveFunctionFromConfig: (particleSystemId: number, lifetimeCurve: LifetimeCurve) => import("./types.js").CurveFunction;
|
|
35
35
|
export declare const calculateValue: (particleSystemId: number, value: Constant | RandomBetweenTwoConstants | LifetimeCurve, time?: number) => number;
|
|
36
36
|
//# sourceMappingURL=three-particles-utils.d.ts.map
|
|
@@ -154,14 +154,14 @@ export const createDefaultParticleTexture = () => {
|
|
|
154
154
|
export const isLifeTimeCurve = (value) => {
|
|
155
155
|
return typeof value !== 'number' && 'type' in value;
|
|
156
156
|
};
|
|
157
|
-
export const getCurveFunctionFromConfig = (particleSystemId,
|
|
158
|
-
if (
|
|
159
|
-
return createBezierCurveFunction(particleSystemId,
|
|
157
|
+
export const getCurveFunctionFromConfig = (particleSystemId, lifetimeCurve) => {
|
|
158
|
+
if (lifetimeCurve.type === "BEZIER" /* LifeTimeCurve.BEZIER */) {
|
|
159
|
+
return createBezierCurveFunction(particleSystemId, lifetimeCurve.bezierPoints); // Bézier curve
|
|
160
160
|
}
|
|
161
|
-
if (
|
|
162
|
-
return
|
|
161
|
+
if (lifetimeCurve.type === "EASING" /* LifeTimeCurve.EASING */) {
|
|
162
|
+
return lifetimeCurve.curveFunction; // Easing curve
|
|
163
163
|
}
|
|
164
|
-
throw new Error(`Unsupported value type: ${
|
|
164
|
+
throw new Error(`Unsupported value type: ${lifetimeCurve}`);
|
|
165
165
|
};
|
|
166
166
|
export const calculateValue = (particleSystemId, value, time = 0) => {
|
|
167
167
|
if (typeof value === 'number') {
|
|
@@ -173,7 +173,7 @@ export const calculateValue = (particleSystemId, value, time = 0) => {
|
|
|
173
173
|
}
|
|
174
174
|
return THREE.MathUtils.randFloat(value.min ?? 0, value.max ?? 1); // Random range
|
|
175
175
|
}
|
|
176
|
-
const
|
|
177
|
-
return (getCurveFunctionFromConfig(particleSystemId,
|
|
178
|
-
(
|
|
176
|
+
const lifetimeCurve = value;
|
|
177
|
+
return (getCurveFunctionFromConfig(particleSystemId, lifetimeCurve)(time) *
|
|
178
|
+
(lifetimeCurve.scale ?? 1));
|
|
179
179
|
};
|
|
@@ -213,7 +213,7 @@ export const createParticleSystem = (config = DEFAULT_PARTICLE_SYSTEM_CONFIG, ex
|
|
|
213
213
|
},
|
|
214
214
|
isEnabled: true,
|
|
215
215
|
};
|
|
216
|
-
const normalizedConfig = ObjectUtils.
|
|
216
|
+
const normalizedConfig = ObjectUtils.deepMerge(DEFAULT_PARTICLE_SYSTEM_CONFIG, config, { applyToFirstObject: false, skippedProperties: [] });
|
|
217
217
|
let particleMap = normalizedConfig.map || createDefaultParticleTexture();
|
|
218
218
|
const { transform, duration, looping, startDelay, startLifetime, startSpeed, startSize, startRotation, startColor, startOpacity, gravity, simulationSpace, maxParticles, emission, shape, renderer, noise, velocityOverLifetime, onUpdate, onComplete, textureSheetAnimation, } = normalizedConfig;
|
|
219
219
|
if (typeof renderer?.blending === 'string')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"THREE";var e={300:t=>{const e=t=>t,r={In:t=>t*t,Out:t=>t*(2-t),InOut(t){let e=2*t;return e<1?.5*e*e:(e-=1,-.5*(e*(e-2)-1))}},i={In:t=>t*t*t,Out:t=>--t*t*t+1,InOut(t){let e=2*t;return e<1?.5*e*e*e:(e-=2,.5*(e*e*e+2))}},a={In:t=>t*t*t*t,Out:t=>1- --t*t*t*t,InOut(t){let e=2*t;return e<1?.5*e*e*e*e:(e-=2,-.5*(e*e*e*e-2))}},n={In:t=>t*t*t*t*t,Out:t=>--t*t*t*t*t+1,InOut(t){let e=2*t;return e<1?.5*e*e*e*e*e:(e-=2,.5*(e*e*e*e*e+2))}},o={In:t=>1-Math.cos(t*Math.PI/2),Out:t=>Math.sin(t*Math.PI/2),InOut:t=>.5*(1-Math.cos(Math.PI*t))},s={In:t=>0===t?0:1024**(t-1),Out:t=>1===t?1:1-2**(-10*t),InOut(t){if(0===t)return 0;if(1===t)return 1;const e=2*t;return e<1?.5*1024**(e-1):.5*(2-2**(-10*(e-1)))}},l={In:t=>1-Math.sqrt(1-t*t),Out:t=>Math.sqrt(1- --t*t),InOut(t){let e=2*t;return e<1?-.5*(Math.sqrt(1-e*e)-1):(e-=2,.5*(Math.sqrt(1-e*e)+1))}},c={In(t){let e=.1;let r;return 0===t?0:1===t?1:(e<1?(e=1,r=.1):r=.4*Math.asin(1/e)/(2*Math.PI),-e*2**(10*(t-=1))*Math.sin((t-r)*(2*Math.PI)/.4))},Out(t){let e=.1;let r;return 0===t?0:1===t?1:(e<1?(e=1,r=.1):r=.4*Math.asin(1/e)/(2*Math.PI),e*2**(-10*t)*Math.sin((t-r)*(2*Math.PI)/.4)+1)},InOut(t){let e=.1;const r=.4;let i;if(0===t)return 0;if(1===t)return 1;e<1?(e=1,i=.1):i=r*Math.asin(1/e)/(2*Math.PI);const a=2*t;if(a<1){const t=a-1;return e*2**(10*t)*Math.sin((t-i)*(2*Math.PI)/r)*-.5}const n=a-1;return e*2**(-10*n)*Math.sin((n-i)*(2*Math.PI)/r)*.5+1}},d={In(t){const e=1.70158;return t*t*((e+1)*t-e)},Out(t){const e=1.70158;return--t*t*((e+1)*t+e)+1},InOut(t){const e=2.5949095;let r=2*t;return r<1?r*r*((e+1)*r-e)*.5:(r-=2,.5*(r*r*((e+1)*r+e)+2))}},u={In:t=>1-u.Out(1-t),Out(t){if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const e=t-1.5/2.75;return 7.5625*e*e+.75}if(t<2.5/2.75){const e=t-2.25/2.75;return 7.5625*e*e+.9375}const e=t-2.625/2.75;return 7.5625*e*e+.984375},InOut:t=>t<.5?.5*u.In(2*t):.5*u.Out(2*t-1)+.5},m={Quadratic:r,Cubic:i,Quartic:a,Quintic:n,Sinusoidal:o,Exponential:s,Circular:l,Elastic:c,Back:d,Bounce:u},y=(t,e,r)=>Object.defineProperty(t,e,{value:r});for(const t of Object.keys(m)){const e=m[t],r=t.toLowerCase();y(m,r,e);for(const i of Object.keys(e)){const a=e[i],n=i.toLowerCase();y(m,`${t}.${i}`,a),y(m,`${r}.${n}`,a),y(e,n,a)}}m.Linear=e,y(m,"linear",e),t.exports=m,"undefined"!=typeof window&&(window.Easing=m)}},r={};function i(t){var a=r[t];if(void 0!==a)return a.exports;var n=r[t]={exports:{}};return e[t](n,n.exports,i),n.exports}i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var a={};i.d(a,{pB:()=>P,U_:()=>F,rU:()=>v,M4:()=>h,$H:()=>f,hp:()=>g,l$:()=>p,Y$:()=>O,Tt:()=>s,JP:()=>x,eL:()=>W,Hc:()=>c,Ao:()=>m,iy:()=>I,Px:()=>Q,rJ:()=>b,Pj:()=>l,YR:()=>j});const n=[],o=(t,e)=>{let r=1;for(let i=1;i<=e;i++)r*=(t+1-i)/i;return r},s=(t,e)=>{const r=n.find((t=>t.bezierPoints===e));if(r)return r.referencedBy.includes(t)||r.referencedBy.push(t),r.curveFunction;const i={referencedBy:[t],bezierPoints:e,curveFunction:t=>{if(t<0)return e[0].y;if(t>1)return e[e.length-1].y;let r=0,i=e.length-1;e.find(((e,a)=>{const n=t<(e.percentage??0);return n?i=a:void 0!==e.percentage&&(r=a),n}));const a=i-r,n=(t-(e[r].percentage??0))/((e[i].percentage??1)-(e[r].percentage??0));let s=0;for(let t=0;t<=a;t++){const i=e[r+t];s+=o(a,t)*Math.pow(1-n,a-t)*Math.pow(n,t)*i.y}return s}};return n.push(i),i.curveFunction},l=t=>{for(;;){const e=n.findIndex((e=>e.referencedBy.includes(t)));if(-1===e)break;const r=n[e];r.referencedBy=r.referencedBy.filter((e=>e!==t)),0===r.referencedBy.length&&n.splice(e,1)}},c=()=>n.length;var d=i(300);const u={LINEAR:d.Linear.None,QUADRATIC_IN:d.Quadratic.In,QUADRATIC_OUT:d.Quadratic.Out,QUADRATIC_IN_OUT:d.Quadratic.InOut,CUBIC_IN:d.Cubic.In,CUBIC_OUT:d.Cubic.Out,CUBIC_IN_OUT:d.Cubic.InOut,QUARTIC_IN:d.Quartic.In,QUARTIC_OUT:d.Quartic.Out,QUARTIC_IN_OUT:d.Quartic.InOut,QUINTIC_IN:d.Quintic.In,QUINTIC_OUT:d.Quintic.Out,QUINTIC_IN_OUT:d.Quintic.InOut,SINUSOIDAL_IN:d.Sinusoidal.In,SINUSOIDAL_OUT:d.Sinusoidal.Out,SINUSOIDAL_IN_OUT:d.Sinusoidal.InOut,EXPONENTIAL_IN:d.Exponential.In,EXPONENTIAL_OUT:d.Exponential.Out,EXPONENTIAL_IN_OUT:d.Exponential.InOut,CIRCULAR_IN:d.Circular.In,CIRCULAR_OUT:d.Circular.Out,CIRCULAR_IN_OUT:d.Circular.InOut,ELASTIC_IN:d.Elastic.In,ELASTIC_OUT:d.Elastic.Out,ELASTIC_IN_OUT:d.Elastic.InOut,BACK_IN:d.Back.In,BACK_OUT:d.Back.Out,BACK_IN_OUT:d.Back.InOut,BOUNCE_IN:d.Bounce.In,BOUNCE_OUT:d.Bounce.Out,BOUNCE_IN_OUT:d.Bounce.InOut},m=t=>"function"==typeof t?t:u[t];const y=(t=>{var e={};return i.d(e,t),e})({AdditiveBlending:()=>t.AdditiveBlending,BufferAttribute:()=>t.BufferAttribute,BufferGeometry:()=>t.BufferGeometry,CanvasTexture:()=>t.CanvasTexture,Euler:()=>t.Euler,MathUtils:()=>t.MathUtils,MultiplyBlending:()=>t.MultiplyBlending,NoBlending:()=>t.NoBlending,NormalBlending:()=>t.NormalBlending,Object3D:()=>t.Object3D,Points:()=>t.Points,Quaternion:()=>t.Quaternion,ShaderMaterial:()=>t.ShaderMaterial,SubtractiveBlending:()=>t.SubtractiveBlending,Vector2:()=>t.Vector2,Vector3:()=>t.Vector3}),p=(t,e,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),y=m*Math.cos(d),p=m*Math.sin(d),f=Math.cos(u),v=1-n;t.x=a*v*y+a*n*c*y,t.y=a*v*p+a*n*c*p,t.z=a*v*f+a*n*c*f,t.applyQuaternion(e);const h=1/t.length();r.set(t.x*h*i,t.y*h*i,t.z*h*i),r.applyQuaternion(e)},f=(t,e,r,i,{radius:a,radiusThickness:n,arc:o,angle:s=90})=>{const l=2*Math.PI*Math.random()*(o/360),c=Math.random(),d=Math.cos(l),u=Math.sin(l),m=1-n;t.x=a*m*d+a*n*c*d,t.y=a*m*u+a*n*c*u,t.z=0,t.applyQuaternion(e);const p=t.length(),f=Math.abs(p/a*y.MathUtils.degToRad(s)),v=Math.sin(f),h=1/p;r.set(t.x*v*h*i,t.y*v*h*i,Math.cos(f)*i),r.applyQuaternion(e)},v=(t,e,r,i,{scale:a,emitFrom:n})=>{const o=a;switch(n){case"VOLUME":t.x=Math.random()*o.x-o.x/2,t.y=Math.random()*o.y-o.y/2,t.z=Math.random()*o.z-o.z/2;break;case"SHELL":const e=Math.floor(6*Math.random()),r=e%3,i=[];i[r]=e>2?1:0,i[(r+1)%3]=Math.random(),i[(r+2)%3]=Math.random(),t.x=i[0]*o.x-o.x/2,t.y=i[1]*o.y-o.y/2,t.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(),t.x=l[0]*o.x-o.x/2,t.y=l[1]*o.y-o.y/2,t.z=l[2]*o.z-o.z/2}t.applyQuaternion(e),r.set(0,0,i),r.applyQuaternion(e)},h=(t,e,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;t.x=a*u*c+a*n*l*c,t.y=a*u*d+a*n*l*d,t.z=0,t.applyQuaternion(e);const m=1/t.length();r.set(t.x*m*i,t.y*m*i,0),r.applyQuaternion(e)},g=(t,e,r,i,{rotation:a,scale:n})=>{const o=n,s=a,l=Math.random()*o.x-o.x/2,c=Math.random()*o.y-o.y/2,d=y.MathUtils.degToRad(s.x),u=y.MathUtils.degToRad(s.y);t.x=l*Math.cos(u),t.y=c*Math.cos(d),t.z=l*Math.sin(u)-c*Math.sin(d),t.applyQuaternion(e),r.set(0,0,i),r.applyQuaternion(e)},x=()=>{try{const t=document.createElement("canvas"),e=64;t.width=e,t.height=e;const r=t.getContext("2d");if(r){const i=e/2,a=e/2,n=e/2-2;r.beginPath(),r.arc(i,a,n,0,2*Math.PI,!1),r.fillStyle="white",r.fill();const o=new y.CanvasTexture(t);return o.needsUpdate=!0,o}return null}catch(t){return null}},b=t=>"number"!=typeof t&&"type"in t,I=(t,e)=>{if("BEZIER"===e.type)return s(t,e.bezierPoints);if("EASING"===e.type)return e.curveFunction;throw new Error(`Unsupported value type: ${e}`)},O=(t,e,r=0)=>{if("number"==typeof e)return e;if("min"in e&&"max"in e)return e.min===e.max?e.min??0:y.MathUtils.randFloat(e.min??0,e.max??1);const i=e;return I(t,i)(r)*(i.scale??1)},M=new y.Vector3(0,0,0),z=new y.Euler,P=({delta:t,generalData:e,normalizedConfig:r,attributes:i,particleLifetimePercentage:a,particleIndex:n})=>{const{particleSystemId:o,startValues:s,lifetimeValues:l,linearVelocityData:c,orbitalVelocityData:d,noise:u}=e,m=3*n,y=i.position.array;if(c){const{speed:e,valueModifiers:r}=c[n],o=r.x?r.x(a):e.x,s=r.y?r.y(a):e.y,l=r.z?r.z(a):e.z;y[m]+=o*t,y[m+1]+=s*t,y[m+2]+=l*t,i.position.needsUpdate=!0}if(d){const{speed:e,positionOffset:r,valueModifiers:o}=d[n];y[m]-=r.x,y[m+1]-=r.y,y[m+2]-=r.z;const s=o.x?o.x(a):e.x,l=o.y?o.y(a):e.y,c=o.z?o.z(a):e.z;z.set(s*t,c*t,l*t),r.applyEuler(z),y[m]+=r.x,y[m+1]+=r.y,y[m+2]+=r.z,i.position.needsUpdate=!0}if(r.sizeOverLifetime.isActive){const t=O(o,r.sizeOverLifetime.lifetimeCurve,a);i.size.array[n]=s.startSize[n]*t,i.size.needsUpdate=!0}if(r.opacityOverLifetime.isActive){const t=O(o,r.opacityOverLifetime.lifetimeCurve,a);i.colorA.array[n]=s.startOpacity[n]*t,i.colorA.needsUpdate=!0}if(l.rotationOverLifetime&&(i.rotation.array[n]+=l.rotationOverLifetime[n]*t*.02,i.rotation.needsUpdate=!0),u.isActive){const{sampler:t,strength:e,offsets:r,positionAmount:o,rotationAmount:s,sizeAmount:l}=u;let c;const d=10*(a+(r?r[n]:0))*e,p=.15*e;M.set(d,0,0),c=t.get3(M),y[m]+=c*p*o,0!==s&&(i.rotation.array[n]+=c*p*s,i.rotation.needsUpdate=!0),0!==l&&(i.size.array[n]+=c*p*l,i.size.needsUpdate=!0),M.set(d,d,0),c=t.get3(M),y[m+1]+=c*p*o,M.set(d,d,d),c=t.get3(M),y[m+2]+=c*p*o,i.position.needsUpdate=!0}};const w=(t,e,r={skippedProperties:[],applyToFirstObject:!1})=>{const i={};return Object.keys(t).forEach((a=>{r.skippedProperties&&r.skippedProperties.includes(a)||("object"==typeof t[a]&&t[a]&&e[a]&&!Array.isArray(t[a])?i[a]=w(t[a],e[a],r):(i[a]=0===e[a]?0:!1!==e[a]&&(e[a]||t[a]),r.applyToFirstObject&&(t[a]=i[a])))})),i},A=new y.Vector3,S=new y.Quaternion,_=new y.Vector3,C=new y.Vector3,L=new y.Quaternion,V=new y.Vector3;class T extends y.Object3D{constructor(){super()}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null!==this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(C,L,V),this.matrix.decompose(A,S,_),this.matrixWorld.compose(C,S,V)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let e=0,r=this.children.length;e<r;e++)this.children[e].updateMatrixWorld(t)}}var E=[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];class U{constructor(t){const e=[new y.Vector3(1,1,0),new y.Vector3(-1,1,0),new y.Vector3(1,-1,0),new y.Vector3(-1,-1,0),new y.Vector3(1,0,1),new y.Vector3(-1,0,1),new y.Vector3(1,0,-1),new y.Vector3(-1,0,-1),new y.Vector3(0,1,1),new y.Vector3(0,-1,1),new y.Vector3(0,1,-1),new y.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 n;n=1&a?E[a]^255&t:E[a]^t>>8&255,r[a]=r[a+256]=n,i[a]=i[a+256]=e[n%12]}this._seed=t,this._offsetMatrix=[new y.Vector3(0,0,0),new y.Vector3(0,0,1),new y.Vector3(0,1,0),new y.Vector3(0,1,1),new y.Vector3(1,0,0),new y.Vector3(1,0,1),new y.Vector3(1,1,0),new y.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(t){return t*t*t*(t*(6*t-15)+10)}_lerp(t,e,r){return(1-r)*t+r*e}_gradient(t){return t instanceof y.Vector3?t.x+this.perm[t.y+this.perm[t.z]]:t.x+this.perm[t.y]}static map(t,e,r,i,a){return(t-e)*(a-i)/(r-e)+i}get2(t){void 0!==t.z&&(t=new y.Vector2(t.x,t.y));const e=new y.Vector2(Math.floor(t.x),Math.floor(t.y));t.sub(e),e.x&=255,e.y&=255;const r=[];for(let i=0;i<4;i++){const a=this._offsetMatrix[2*i],n=new y.Vector2(a.x,a.y),o=this.gradP[this._gradient((new y.Vector2).addVectors(e,n))],s=new y.Vector2(o.x,o.y),l=(new y.Vector2).subVectors(t,n);r.push(s.dot(l))}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 e=new y.Vector3(Math.floor(t.x),Math.floor(t.y),Math.floor(t.z));t.sub(e),e.x&=255,e.y&=255,e.z&=255;const r=[];for(let i=0;i<8;i++){const a=this._offsetMatrix[i],n=this.gradP[this._gradient((new y.Vector3).addVectors(e,a))],o=(new y.Vector3).subVectors(t,a);r.push(n.dot(o))}const i=this._fade(t.x),a=this._fade(t.y),n=this._fade(t.z);return this._lerp(this._lerp(this._lerp(r[0],r[4],i),this._lerp(r[1],r[5],i),n),this._lerp(this._lerp(r[2],r[6],i),this._lerp(r[3],r[7],i),n),a)}}class B{constructor(t){const{seed:e,scale:r,persistance:i,lacunarity:a,octaves:n,redistribution:o}=t;this._noise=new U(e),this._scale=r||1,this._persistance=i||.5,this._lacunarity=a||2,this._octaves=n||6,this._redistribution=o||1}get2(t){let e=0,r=1,i=1,a=r,n=this._noise.get2.bind(this._noise);for(let o=0;o<this._octaves;o++){e+=n(new y.Vector2(t.x*this._scale*i,t.y*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,a+=r}return Math.pow(e,this._redistribution)/a}get3(t){let e=0,r=1,i=1,a=r,n=this._noise.get3.bind(this._noise);for(let o=0;o<this._octaves;o++){e+=n(new y.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(e,this._redistribution)/a}}let R=0,N=[];const F={"THREE.NoBlending":y.NoBlending,"THREE.NormalBlending":y.NormalBlending,"THREE.AdditiveBlending":y.AdditiveBlending,"THREE.SubtractiveBlending":y.SubtractiveBlending,"THREE.MultiplyBlending":y.MultiplyBlending},Q=()=>JSON.parse(JSON.stringify(D)),D={transform:{position:new y.Vector3,rotation:new y.Vector3,scale:new y.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},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:y.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}]}},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 y.Vector2(1,1),timeMode:"LIFETIME",fps:30,startFrame:0}},k=(t,{shape:e,sphere:r,cone:i,circle:a,rectangle:n,box:o},s,l,c)=>{const d=O(t.particleSystemId,s,t.normalizedLifetimePercentage);switch(e){case"SPHERE":p(l,t.wrapperQuaternion,c,d,r);break;case"CONE":f(l,t.wrapperQuaternion,c,d,i);break;case"CIRCLE":h(l,t.wrapperQuaternion,c,d,a);break;case"RECTANGLE":g(l,t.wrapperQuaternion,c,d,n);break;case"BOX":v(l,t.wrapperQuaternion,c,d,o)}},W=(t=D,e)=>{const r=e||Date.now(),i={particleSystemId:R++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new y.Vector3(-99999),currentWorldPosition:new y.Vector3(-99999),worldPositionChange:new y.Vector3,worldQuaternion:new y.Quaternion,wrapperQuaternion:new y.Quaternion,lastWorldQuaternion:new y.Quaternion(-99999),worldEuler:new y.Euler,gravityVelocity:new y.Vector3(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},a=w(D,t);let n=a.map||x();const{transform:o,duration:s,looping:c,startDelay:d,startLifetime:u,startSpeed:m,startSize:p,startRotation:f,startColor:v,startOpacity:h,gravity:g,simulationSpace:M,maxParticles:z,emission:A,shape:S,renderer:_,noise:C,velocityOverLifetime:L,onUpdate:V,onComplete:E,textureSheetAnimation:U}=a;"string"==typeof _?.blending&&(_.blending=F[_.blending]);const Q=Array.from({length:z},(()=>new y.Vector3)),W=Array.from({length:z},(()=>new y.Vector3));i.creationTimes=Array.from({length:z},(()=>0)),L.isActive&&(i.linearVelocityData=Array.from({length:z},(()=>({speed:new y.Vector3(L.linear.x?O(i.particleSystemId,L.linear.x,0):0,L.linear.y?O(i.particleSystemId,L.linear.y,0):0,L.linear.z?O(i.particleSystemId,L.linear.z,0):0),valueModifiers:{x:b(L.linear.x||0)?I(i.particleSystemId,L.linear.x):void 0,y:b(L.linear.y||0)?I(i.particleSystemId,L.linear.y):void 0,z:b(L.linear.z||0)?I(i.particleSystemId,L.linear.z):void 0}}))),i.orbitalVelocityData=Array.from({length:z},(()=>({speed:new y.Vector3(L.orbital.x?O(i.particleSystemId,L.orbital.x,0):0,L.orbital.y?O(i.particleSystemId,L.orbital.y,0):0,L.orbital.z?O(i.particleSystemId,L.orbital.z,0):0),valueModifiers:{x:b(L.orbital.x||0)?I(i.particleSystemId,L.orbital.x):void 0,y:b(L.orbital.y||0)?I(i.particleSystemId,L.orbital.y):void 0,z:b(L.orbital.z||0)?I(i.particleSystemId,L.orbital.z):void 0},positionOffset:new y.Vector3}))));["startSize","startOpacity"].forEach((t=>{i.startValues[t]=Array.from({length:z},(()=>O(i.particleSystemId,a[t],0)))}));["rotationOverLifetime"].forEach((t=>{const e=a[t];e.isActive&&(i.lifetimeValues[t]=Array.from({length:z},(()=>y.MathUtils.randFloat(e.min,e.max))))})),i.noise={isActive:C.isActive,strength:C.strength,positionAmount:C.positionAmount,rotationAmount:C.rotationAmount,sizeAmount:C.sizeAmount,sampler:C.isActive?new B({seed:Math.random(),scale:C.frequency,octaves:C.octaves}):void 0,offsets:C.useRandomOffset?Array.from({length:z},(()=>100*Math.random())):void 0};const j=new y.ShaderMaterial({uniforms:{elapsed:{value:0},map:{value:n},tiles:{value:U.tiles},fps:{value:U.fps},useFPSForFrameIndex:{value:"FPS"===U.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 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",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 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",transparent:_.transparent,blending:_.blending,depthTest:_.depthTest,depthWrite:_.depthWrite}),G=new y.BufferGeometry;for(let t=0;t<z;t++)k(i,S,m,Q[t],W[t]);G.setFromPoints(Array.from({length:z},((t,e)=>Q[e].clone())));const H=(t,e)=>{(({geometry:t,propertyName:e,maxParticles:r,factory:i})=>{t.setAttribute(e,new y.BufferAttribute(new Float32Array(Array.from({length:r},"function"==typeof i?i:()=>i)),1))})({geometry:G,propertyName:t,maxParticles:z,factory:e})};H("isActive",0),H("lifetime",0),H("startLifetime",(()=>1e3*O(i.particleSystemId,u,0))),H("startFrame",(()=>U.startFrame?O(i.particleSystemId,U.startFrame,0):0)),H("opacity",(()=>O(i.particleSystemId,h,0))),H("rotation",(()=>O(i.particleSystemId,f,0))),H("size",((t,e)=>i.startValues.startSize[e])),H("rotation",0);const q=Math.random();H("colorR",(()=>v.min.r+q*(v.max.r-v.min.r))),H("colorG",(()=>v.min.g+q*(v.max.g-v.min.g))),H("colorB",(()=>v.min.b+q*(v.max.b-v.min.b))),H("colorA",0);let $=new y.Points(G,j);$.position.copy(o.position),$.rotation.x=y.MathUtils.degToRad(o.rotation.x),$.rotation.y=y.MathUtils.degToRad(o.rotation.y),$.rotation.z=y.MathUtils.degToRad(o.rotation.z),$.scale.copy(o.scale);const Y=r+1e3*O(i.particleSystemId,d);let X;"WORLD"===a.simulationSpace&&(X=new T,X.add($)),N.push({particleSystem:$,wrapper:X,generalData:i,onUpdate:V,onComplete:E,creationTime:Y,lastEmissionTime:Y,duration:s,looping:c,simulationSpace:M,gravity:g,emission:A,normalizedConfig:a,iterationCount:0,velocities:W,deactivateParticle:t=>{G.attributes.isActive.array[t]=0,G.attributes.colorA.array[t]=0,G.attributes.colorA.needsUpdate=!0},activateParticle:({particleIndex:t,activationTime:e,position:r})=>{G.attributes.isActive.array[t]=1,i.creationTimes[t]=e,i.noise.offsets&&(i.noise.offsets[t]=100*Math.random());const n=Math.random();G.attributes.colorR.array[t]=v.min.r+n*(v.max.r-v.min.r),G.attributes.colorR.needsUpdate=!0,G.attributes.colorG.array[t]=v.min.g+n*(v.max.g-v.min.g),G.attributes.colorG.needsUpdate=!0,G.attributes.colorB.array[t]=v.min.b+n*(v.max.b-v.min.b),G.attributes.colorB.needsUpdate=!0,G.attributes.startFrame.array[t]=U.startFrame?O(i.particleSystemId,U.startFrame,0):0,G.attributes.startFrame.needsUpdate=!0,G.attributes.startLifetime.array[t]=1e3*O(i.particleSystemId,u,i.normalizedLifetimePercentage),G.attributes.startLifetime.needsUpdate=!0,i.startValues.startSize[t]=O(i.particleSystemId,p,i.normalizedLifetimePercentage),G.attributes.size.array[t]=i.startValues.startSize[t],G.attributes.size.needsUpdate=!0,i.startValues.startOpacity[t]=O(i.particleSystemId,h,i.normalizedLifetimePercentage),G.attributes.colorA.array[t]=i.startValues.startOpacity[t],G.attributes.colorA.needsUpdate=!0,G.attributes.rotation.array[t]=O(i.particleSystemId,f,i.normalizedLifetimePercentage),G.attributes.rotation.needsUpdate=!0,a.rotationOverLifetime.isActive&&(i.lifetimeValues.rotationOverLifetime[t]=y.MathUtils.randFloat(a.rotationOverLifetime.min,a.rotationOverLifetime.max)),k(i,S,m,Q[t],W[t]);const o=Math.floor(3*t);G.attributes.position.array[o]=r.x+Q[t].x,G.attributes.position.array[o+1]=r.y+Q[t].y,G.attributes.position.array[o+2]=r.z+Q[t].z,G.attributes.position.needsUpdate=!0,i.linearVelocityData&&i.linearVelocityData[t].speed.set(a.velocityOverLifetime.linear.x?O(i.particleSystemId,a.velocityOverLifetime.linear.x,0):0,a.velocityOverLifetime.linear.y?O(i.particleSystemId,a.velocityOverLifetime.linear.y,0):0,a.velocityOverLifetime.linear.z?O(i.particleSystemId,a.velocityOverLifetime.linear.z,0):0),i.orbitalVelocityData&&(i.orbitalVelocityData[t].speed.set(a.velocityOverLifetime.orbital.x?O(i.particleSystemId,a.velocityOverLifetime.orbital.x,0):0,a.velocityOverLifetime.orbital.y?O(i.particleSystemId,a.velocityOverLifetime.orbital.y,0):0,a.velocityOverLifetime.orbital.z?O(i.particleSystemId,a.velocityOverLifetime.orbital.z,0):0),i.orbitalVelocityData[t].positionOffset.set(Q[t].x,Q[t].y,Q[t].z)),G.attributes.lifetime.array[t]=0,G.attributes.lifetime.needsUpdate=!0,P({delta:0,generalData:i,normalizedConfig:a,attributes:$.geometry.attributes,particleLifetimePercentage:0,particleIndex:t})}});return{instance:X||$,resumeEmitter:()=>i.isEnabled=!0,pauseEmitter:()=>i.isEnabled=!1,dispose:()=>(t=>{N=N.filter((({particleSystem:e,wrapper:r,generalData:{particleSystemId:i}})=>e!==t&&r!==t||(l(i),e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach((t=>t.dispose())):e.material.dispose(),e.parent&&e.parent.remove(e),!1)))})($)}},j=({now:t,delta:e,elapsed:r})=>{N.forEach((i=>{const{onUpdate:a,generalData:n,onComplete:o,particleSystem:s,wrapper:l,creationTime:c,lastEmissionTime:d,duration:u,looping:m,emission:p,normalizedConfig:f,iterationCount:v,velocities:h,deactivateParticle:g,activateParticle:x,simulationSpace:b,gravity:I}=i,M=t-c,z=M%(1e3*u);n.normalizedLifetimePercentage=Math.max(Math.min(z/(1e3*u),1),0);const{lastWorldPosition:w,currentWorldPosition:A,worldPositionChange:S,lastWorldQuaternion:_,worldQuaternion:C,worldEuler:L,gravityVelocity:V,isEnabled:T}=n;l?.parent&&n.wrapperQuaternion.copy(l.parent.quaternion);const E={...w};if(Array.isArray(s.material)?s.material.forEach((t=>{t instanceof y.ShaderMaterial&&(t.uniforms.elapsed.value=r)})):s.material instanceof y.ShaderMaterial&&(s.material.uniforms.elapsed.value=r),s.getWorldPosition(A),-99999!==w.x&&S.set(A.x-w.x,A.y-w.y,A.z-w.z),n.distanceFromLastEmitByDistance+=S.length(),s.getWorldPosition(w),s.getWorldQuaternion(C),-99999!==_.x&&_.x===C.x&&_.y===C.y&&_.z===C.z||(L.setFromQuaternion(C),_.copy(C),V.set(w.x,w.y+I,w.z),s.worldToLocal(V)),n.creationTimes.forEach(((r,i)=>{if(s.geometry.attributes.isActive.array[i]){const a=t-r;if(a>s.geometry.attributes.startLifetime.array[i])g(i);else{const t=h[i];if(t.x-=V.x*e,t.y-=V.y*e,t.z-=V.z*e,0!==I||0!==t.x||0!==t.y||0!==t.z||0!==S.x||0!==S.y||0!==S.z){const r=3*i,a=s.geometry.attributes.position.array;"WORLD"===b&&(a[r]-=S.x,a[r+1]-=S.y,a[r+2]-=S.z),a[r]+=t.x*e,a[r+1]+=t.y*e,a[r+2]+=t.z*e,s.geometry.attributes.position.needsUpdate=!0}s.geometry.attributes.lifetime.array[i]=a,s.geometry.attributes.lifetime.needsUpdate=!0;const r=a/s.geometry.attributes.startLifetime.array[i];P({delta:e,generalData:n,normalizedConfig:f,attributes:s.geometry.attributes,particleLifetimePercentage:r,particleIndex:i})}}})),T&&(m||M<1e3*u)){const o=t-d,l=p.rateOverTime?Math.floor(O(n.particleSystemId,p.rateOverTime,n.normalizedLifetimePercentage)*(o/1e3)):0,c=p.rateOverDistance?O(n.particleSystemId,p.rateOverDistance,n.normalizedLifetimePercentage):0,u=c>0&&n.distanceFromLastEmitByDistance>0?Math.floor(n.distanceFromLastEmitByDistance/(1/c)):0,m=u>0?{x:(A.x-E.x)/u,y:(A.y-E.y)/u,z:(A.z-E.z)/u}:null,y=l+u;if(c>0&&u>=1&&(n.distanceFromLastEmitByDistance=0),y>0){let e=0;for(let r=0;r<y;r++){let r=-1;if(s.geometry.attributes.isActive.array.find(((t,e)=>!t&&(r=e,!0))),-1!==r&&r<s.geometry.attributes.isActive.array.length){let a={x:0,y:0,z:0};m&&e<u&&(a={x:m.x*e,y:m.y*e,z:m.z*e},e++),x({particleIndex:r,activationTime:t,position:a}),i.lastEmissionTime=t}}}a&&a({particleSystem:s,delta:e,elapsed:r,lifetime:M,normalizedLifetime:z,iterationCount:v+1})}else o&&o({particleSystem:s})}))};var G=a.pB,H=a.U_,q=a.rU,$=a.M4,Y=a.$H,X=a.hp,J=a.l$,K=a.Y$,Z=a.Tt,tt=a.JP,et=a.eL,rt=a.Hc,it=a.Ao,at=a.iy,nt=a.Px,ot=a.rJ,st=a.Pj,lt=a.YR;export{G as applyModifiers,H as blendingMap,q as calculateRandomPositionAndVelocityOnBox,$ as calculateRandomPositionAndVelocityOnCircle,Y as calculateRandomPositionAndVelocityOnCone,X as calculateRandomPositionAndVelocityOnRectangle,J as calculateRandomPositionAndVelocityOnSphere,K as calculateValue,Z as createBezierCurveFunction,tt as createDefaultParticleTexture,et as createParticleSystem,rt as getBezierCacheSize,it as getCurveFunction,at as getCurveFunctionFromConfig,nt as getDefaultParticleSystemConfig,ot as isLifeTimeCurve,st as removeBezierCurveFunction,lt as updateParticleSystems};
|
|
1
|
+
import*as t from"THREE";var e={300:t=>{const e=t=>t,r={In:t=>t*t,Out:t=>t*(2-t),InOut(t){let e=2*t;return e<1?.5*e*e:(e-=1,-.5*(e*(e-2)-1))}},i={In:t=>t*t*t,Out:t=>--t*t*t+1,InOut(t){let e=2*t;return e<1?.5*e*e*e:(e-=2,.5*(e*e*e+2))}},n={In:t=>t*t*t*t,Out:t=>1- --t*t*t*t,InOut(t){let e=2*t;return e<1?.5*e*e*e*e:(e-=2,-.5*(e*e*e*e-2))}},a={In:t=>t*t*t*t*t,Out:t=>--t*t*t*t*t+1,InOut(t){let e=2*t;return e<1?.5*e*e*e*e*e:(e-=2,.5*(e*e*e*e*e+2))}},o={In:t=>1-Math.cos(t*Math.PI/2),Out:t=>Math.sin(t*Math.PI/2),InOut:t=>.5*(1-Math.cos(Math.PI*t))},s={In:t=>0===t?0:1024**(t-1),Out:t=>1===t?1:1-2**(-10*t),InOut(t){if(0===t)return 0;if(1===t)return 1;const e=2*t;return e<1?.5*1024**(e-1):.5*(2-2**(-10*(e-1)))}},l={In:t=>1-Math.sqrt(1-t*t),Out:t=>Math.sqrt(1- --t*t),InOut(t){let e=2*t;return e<1?-.5*(Math.sqrt(1-e*e)-1):(e-=2,.5*(Math.sqrt(1-e*e)+1))}},c={In(t){let e=.1;let r;return 0===t?0:1===t?1:(e<1?(e=1,r=.1):r=.4*Math.asin(1/e)/(2*Math.PI),-e*2**(10*(t-=1))*Math.sin((t-r)*(2*Math.PI)/.4))},Out(t){let e=.1;let r;return 0===t?0:1===t?1:(e<1?(e=1,r=.1):r=.4*Math.asin(1/e)/(2*Math.PI),e*2**(-10*t)*Math.sin((t-r)*(2*Math.PI)/.4)+1)},InOut(t){let e=.1;const r=.4;let i;if(0===t)return 0;if(1===t)return 1;e<1?(e=1,i=.1):i=r*Math.asin(1/e)/(2*Math.PI);const n=2*t;if(n<1){const t=n-1;return e*2**(10*t)*Math.sin((t-i)*(2*Math.PI)/r)*-.5}const a=n-1;return e*2**(-10*a)*Math.sin((a-i)*(2*Math.PI)/r)*.5+1}},d={In(t){const e=1.70158;return t*t*((e+1)*t-e)},Out(t){const e=1.70158;return--t*t*((e+1)*t+e)+1},InOut(t){const e=2.5949095;let r=2*t;return r<1?r*r*((e+1)*r-e)*.5:(r-=2,.5*(r*r*((e+1)*r+e)+2))}},u={In:t=>1-u.Out(1-t),Out(t){if(t<1/2.75)return 7.5625*t*t;if(t<2/2.75){const e=t-1.5/2.75;return 7.5625*e*e+.75}if(t<2.5/2.75){const e=t-2.25/2.75;return 7.5625*e*e+.9375}const e=t-2.625/2.75;return 7.5625*e*e+.984375},InOut:t=>t<.5?.5*u.In(2*t):.5*u.Out(2*t-1)+.5},m={Quadratic:r,Cubic:i,Quartic:n,Quintic:a,Sinusoidal:o,Exponential:s,Circular:l,Elastic:c,Back:d,Bounce:u},p=(t,e,r)=>Object.defineProperty(t,e,{value:r});for(const t of Object.keys(m)){const e=m[t],r=t.toLowerCase();p(m,r,e);for(const i of Object.keys(e)){const n=e[i],a=i.toLowerCase();p(m,`${t}.${i}`,n),p(m,`${r}.${a}`,n),p(e,a,n)}}m.Linear=e,p(m,"linear",e),t.exports=m,"undefined"!=typeof window&&(window.Easing=m)}},r={};function i(t){var n=r[t];if(void 0!==n)return n.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,i),a.exports}i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const n=[],a=(t,e)=>{let r=1;for(let i=1;i<=e;i++)r*=(t+1-i)/i;return r},o=(t,e)=>{const r=n.find((t=>t.bezierPoints===e));if(r)return r.referencedBy.includes(t)||r.referencedBy.push(t),r.curveFunction;const i={referencedBy:[t],bezierPoints:e,curveFunction:t=>{if(t<0)return e[0].y;if(t>1)return e[e.length-1].y;let r=0,i=e.length-1;e.find(((e,n)=>{const a=t<(e.percentage??0);return a?i=n:void 0!==e.percentage&&(r=n),a}));const n=i-r,o=(t-(e[r].percentage??0))/((e[i].percentage??1)-(e[r].percentage??0));let s=0;for(let t=0;t<=n;t++){const i=e[r+t];s+=a(n,t)*Math.pow(1-o,n-t)*Math.pow(o,t)*i.y}return s}};return n.push(i),i.curveFunction},s=t=>{for(;;){const e=n.findIndex((e=>e.referencedBy.includes(t)));if(-1===e)break;const r=n[e];r.referencedBy=r.referencedBy.filter((e=>e!==t)),0===r.referencedBy.length&&n.splice(e,1)}},l=()=>n.length;var c=i(300);const d={LINEAR:c.Linear.None,QUADRATIC_IN:c.Quadratic.In,QUADRATIC_OUT:c.Quadratic.Out,QUADRATIC_IN_OUT:c.Quadratic.InOut,CUBIC_IN:c.Cubic.In,CUBIC_OUT:c.Cubic.Out,CUBIC_IN_OUT:c.Cubic.InOut,QUARTIC_IN:c.Quartic.In,QUARTIC_OUT:c.Quartic.Out,QUARTIC_IN_OUT:c.Quartic.InOut,QUINTIC_IN:c.Quintic.In,QUINTIC_OUT:c.Quintic.Out,QUINTIC_IN_OUT:c.Quintic.InOut,SINUSOIDAL_IN:c.Sinusoidal.In,SINUSOIDAL_OUT:c.Sinusoidal.Out,SINUSOIDAL_IN_OUT:c.Sinusoidal.InOut,EXPONENTIAL_IN:c.Exponential.In,EXPONENTIAL_OUT:c.Exponential.Out,EXPONENTIAL_IN_OUT:c.Exponential.InOut,CIRCULAR_IN:c.Circular.In,CIRCULAR_OUT:c.Circular.Out,CIRCULAR_IN_OUT:c.Circular.InOut,ELASTIC_IN:c.Elastic.In,ELASTIC_OUT:c.Elastic.Out,ELASTIC_IN_OUT:c.Elastic.InOut,BACK_IN:c.Back.In,BACK_OUT:c.Back.Out,BACK_IN_OUT:c.Back.InOut,BOUNCE_IN:c.Bounce.In,BOUNCE_OUT:c.Bounce.Out,BOUNCE_IN_OUT:c.Bounce.InOut},u=t=>"function"==typeof t?t:d[t];const m=(t=>{var e={};return i.d(e,t),e})({AdditiveBlending:()=>t.AdditiveBlending,BufferAttribute:()=>t.BufferAttribute,BufferGeometry:()=>t.BufferGeometry,CanvasTexture:()=>t.CanvasTexture,Euler:()=>t.Euler,MathUtils:()=>t.MathUtils,MultiplyBlending:()=>t.MultiplyBlending,NoBlending:()=>t.NoBlending,NormalBlending:()=>t.NormalBlending,Object3D:()=>t.Object3D,Points:()=>t.Points,Quaternion:()=>t.Quaternion,ShaderMaterial:()=>t.ShaderMaterial,SubtractiveBlending:()=>t.SubtractiveBlending,Vector2:()=>t.Vector2,Vector3:()=>t.Vector3}),p=(t,e,r,i,{radius:n,radiusThickness:a,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),y=m*Math.sin(d),f=Math.cos(u),v=1-a;t.x=n*v*p+n*a*c*p,t.y=n*v*y+n*a*c*y,t.z=n*v*f+n*a*c*f,t.applyQuaternion(e);const h=1/t.length();r.set(t.x*h*i,t.y*h*i,t.z*h*i),r.applyQuaternion(e)},y=(t,e,r,i,{radius:n,radiusThickness:a,arc:o,angle:s=90})=>{const l=2*Math.PI*Math.random()*(o/360),c=Math.random(),d=Math.cos(l),u=Math.sin(l),p=1-a;t.x=n*p*d+n*a*c*d,t.y=n*p*u+n*a*c*u,t.z=0,t.applyQuaternion(e);const y=t.length(),f=Math.abs(y/n*m.MathUtils.degToRad(s)),v=Math.sin(f),h=1/y;r.set(t.x*v*h*i,t.y*v*h*i,Math.cos(f)*i),r.applyQuaternion(e)},f=(t,e,r,i,{scale:n,emitFrom:a})=>{const o=n;switch(a){case"VOLUME":t.x=Math.random()*o.x-o.x/2,t.y=Math.random()*o.y-o.y/2,t.z=Math.random()*o.z-o.z/2;break;case"SHELL":const e=Math.floor(6*Math.random()),r=e%3,i=[];i[r]=e>2?1:0,i[(r+1)%3]=Math.random(),i[(r+2)%3]=Math.random(),t.x=i[0]*o.x-o.x/2,t.y=i[1]*o.y-o.y/2,t.z=i[2]*o.z-o.z/2;break;case"EDGE":const n=Math.floor(6*Math.random()),a=n%3,s=Math.floor(4*Math.random()),l=[];l[a]=n>2?1:0,l[(a+1)%3]=s<2?Math.random():s-2,l[(a+2)%3]=s<2?s:Math.random(),t.x=l[0]*o.x-o.x/2,t.y=l[1]*o.y-o.y/2,t.z=l[2]*o.z-o.z/2}t.applyQuaternion(e),r.set(0,0,i),r.applyQuaternion(e)},v=(t,e,r,i,{radius:n,radiusThickness:a,arc:o})=>{const s=2*Math.PI*Math.random()*(o/360),l=Math.random(),c=Math.cos(s),d=Math.sin(s),u=1-a;t.x=n*u*c+n*a*l*c,t.y=n*u*d+n*a*l*d,t.z=0,t.applyQuaternion(e);const m=1/t.length();r.set(t.x*m*i,t.y*m*i,0),r.applyQuaternion(e)},h=(t,e,r,i,{rotation:n,scale:a})=>{const o=a,s=n,l=Math.random()*o.x-o.x/2,c=Math.random()*o.y-o.y/2,d=m.MathUtils.degToRad(s.x),u=m.MathUtils.degToRad(s.y);t.x=l*Math.cos(u),t.y=c*Math.cos(d),t.z=l*Math.sin(u)-c*Math.sin(d),t.applyQuaternion(e),r.set(0,0,i),r.applyQuaternion(e)},g=()=>{try{const t=document.createElement("canvas"),e=64;t.width=e,t.height=e;const r=t.getContext("2d");if(r){const i=e/2,n=e/2,a=e/2-2;r.beginPath(),r.arc(i,n,a,0,2*Math.PI,!1),r.fillStyle="white",r.fill();const o=new m.CanvasTexture(t);return o.needsUpdate=!0,o}return null}catch(t){return null}},x=t=>"number"!=typeof t&&"type"in t,b=(t,e)=>{if("BEZIER"===e.type)return o(t,e.bezierPoints);if("EASING"===e.type)return e.curveFunction;throw new Error(`Unsupported value type: ${e}`)},I=(t,e,r=0)=>{if("number"==typeof e)return e;if("min"in e&&"max"in e)return e.min===e.max?e.min??0:m.MathUtils.randFloat(e.min??0,e.max??1);const i=e;return b(t,i)(r)*(i.scale??1)},O=new m.Vector3(0,0,0),M=new m.Euler,z=({delta:t,generalData:e,normalizedConfig:r,attributes:i,particleLifetimePercentage:n,particleIndex:a})=>{const{particleSystemId:o,startValues:s,lifetimeValues:l,linearVelocityData:c,orbitalVelocityData:d,noise:u}=e,m=3*a,p=i.position.array;if(c){const{speed:e,valueModifiers:r}=c[a],o=r.x?r.x(n):e.x,s=r.y?r.y(n):e.y,l=r.z?r.z(n):e.z;p[m]+=o*t,p[m+1]+=s*t,p[m+2]+=l*t,i.position.needsUpdate=!0}if(d){const{speed:e,positionOffset:r,valueModifiers:o}=d[a];p[m]-=r.x,p[m+1]-=r.y,p[m+2]-=r.z;const s=o.x?o.x(n):e.x,l=o.y?o.y(n):e.y,c=o.z?o.z(n):e.z;M.set(s*t,c*t,l*t),r.applyEuler(M),p[m]+=r.x,p[m+1]+=r.y,p[m+2]+=r.z,i.position.needsUpdate=!0}if(r.sizeOverLifetime.isActive){const t=I(o,r.sizeOverLifetime.lifetimeCurve,n);i.size.array[a]=s.startSize[a]*t,i.size.needsUpdate=!0}if(r.opacityOverLifetime.isActive){const t=I(o,r.opacityOverLifetime.lifetimeCurve,n);i.colorA.array[a]=s.startOpacity[a]*t,i.colorA.needsUpdate=!0}if(l.rotationOverLifetime&&(i.rotation.array[a]+=l.rotationOverLifetime[a]*t*.02,i.rotation.needsUpdate=!0),u.isActive){const{sampler:t,strength:e,offsets:r,positionAmount:o,rotationAmount:s,sizeAmount:l}=u;let c;const d=10*(n+(r?r[a]:0))*e,y=.15*e;O.set(d,0,0),c=t.get3(O),p[m]+=c*y*o,0!==s&&(i.rotation.array[a]+=c*y*s,i.rotation.needsUpdate=!0),0!==l&&(i.size.array[a]+=c*y*l,i.size.needsUpdate=!0),O.set(d,d,0),c=t.get3(O),p[m+1]+=c*y*o,O.set(d,d,d),c=t.get3(O),p[m+2]+=c*y*o,i.position.needsUpdate=!0}};const w=(t,e,r={skippedProperties:[],applyToFirstObject:!1})=>{const i={};return Array.from(new Set([...Object.keys(t||{}),...Object.keys(e||{})])).forEach((n=>{r.skippedProperties&&r.skippedProperties.includes(n)||("object"==typeof t[n]&&t[n]&&e[n]&&!Array.isArray(t[n])?i[n]=w(t[n],e[n],r):(i[n]=0===e[n]?0:!1!==e[n]&&(e[n]||t[n]),r.applyToFirstObject&&(t[n]=i[n])))})),i},_=new m.Vector3,S=new m.Quaternion,A=new m.Vector3,P=new m.Vector3,L=new m.Quaternion,C=new m.Vector3;class E extends m.Object3D{constructor(){super()}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(null!==this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(P,L,C),this.matrix.decompose(_,S,A),this.matrixWorld.compose(P,S,C)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let e=0,r=this.children.length;e<r;e++)this.children[e].updateMatrixWorld(t)}}var T=[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];class V{constructor(t){const e=[new m.Vector3(1,1,0),new m.Vector3(-1,1,0),new m.Vector3(1,-1,0),new m.Vector3(-1,-1,0),new m.Vector3(1,0,1),new m.Vector3(-1,0,1),new m.Vector3(1,0,-1),new m.Vector3(-1,0,-1),new m.Vector3(0,1,1),new m.Vector3(0,-1,1),new m.Vector3(0,1,-1),new m.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 n=0;n<256;n++){var a;a=1&n?T[n]^255&t:T[n]^t>>8&255,r[n]=r[n+256]=a,i[n]=i[n+256]=e[a%12]}this._seed=t,this._offsetMatrix=[new m.Vector3(0,0,0),new m.Vector3(0,0,1),new m.Vector3(0,1,0),new m.Vector3(0,1,1),new m.Vector3(1,0,0),new m.Vector3(1,0,1),new m.Vector3(1,1,0),new m.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(t){return t*t*t*(t*(6*t-15)+10)}_lerp(t,e,r){return(1-r)*t+r*e}_gradient(t){return t instanceof m.Vector3?t.x+this.perm[t.y+this.perm[t.z]]:t.x+this.perm[t.y]}static map(t,e,r,i,n){return(t-e)*(n-i)/(r-e)+i}get2(t){void 0!==t.z&&(t=new m.Vector2(t.x,t.y));const e=new m.Vector2(Math.floor(t.x),Math.floor(t.y));t.sub(e),e.x&=255,e.y&=255;const r=[];for(let i=0;i<4;i++){const n=this._offsetMatrix[2*i],a=new m.Vector2(n.x,n.y),o=this.gradP[this._gradient((new m.Vector2).addVectors(e,a))],s=new m.Vector2(o.x,o.y),l=(new m.Vector2).subVectors(t,a);r.push(s.dot(l))}const i=this._fade(t.x),n=this._fade(t.y);return this._lerp(this._lerp(r[0],r[2],i),this._lerp(r[1],r[3],i),n)}get3(t){if(void 0===t.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const e=new m.Vector3(Math.floor(t.x),Math.floor(t.y),Math.floor(t.z));t.sub(e),e.x&=255,e.y&=255,e.z&=255;const r=[];for(let i=0;i<8;i++){const n=this._offsetMatrix[i],a=this.gradP[this._gradient((new m.Vector3).addVectors(e,n))],o=(new m.Vector3).subVectors(t,n);r.push(a.dot(o))}const i=this._fade(t.x),n=this._fade(t.y),a=this._fade(t.z);return this._lerp(this._lerp(this._lerp(r[0],r[4],i),this._lerp(r[1],r[5],i),a),this._lerp(this._lerp(r[2],r[6],i),this._lerp(r[3],r[7],i),a),n)}}class U{constructor(t){const{seed:e,scale:r,persistance:i,lacunarity:n,octaves:a,redistribution:o}=t;this._noise=new V(e),this._scale=r||1,this._persistance=i||.5,this._lacunarity=n||2,this._octaves=a||6,this._redistribution=o||1}get2(t){let e=0,r=1,i=1,n=r,a=this._noise.get2.bind(this._noise);for(let o=0;o<this._octaves;o++){e+=a(new m.Vector2(t.x*this._scale*i,t.y*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,n+=r}return Math.pow(e,this._redistribution)/n}get3(t){let e=0,r=1,i=1,n=r,a=this._noise.get3.bind(this._noise);for(let o=0;o<this._octaves;o++){e+=a(new m.Vector3(t.x*this._scale*i,t.y*this._scale*i,t.z*this._scale*i))*r,i*=this._lacunarity,r*=this._persistance,n+=r}return Math.pow(e,this._redistribution)/n}}let B=0,N=[];const R={"THREE.NoBlending":m.NoBlending,"THREE.NormalBlending":m.NormalBlending,"THREE.AdditiveBlending":m.AdditiveBlending,"THREE.SubtractiveBlending":m.SubtractiveBlending,"THREE.MultiplyBlending":m.MultiplyBlending},Q=()=>JSON.parse(JSON.stringify(F)),F={transform:{position:new m.Vector3,rotation:new m.Vector3,scale:new m.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},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:m.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}]}},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 m.Vector2(1,1),timeMode:"LIFETIME",fps:30,startFrame:0}},D=(t,{shape:e,sphere:r,cone:i,circle:n,rectangle:a,box:o},s,l,c)=>{const d=I(t.particleSystemId,s,t.normalizedLifetimePercentage);switch(e){case"SPHERE":p(l,t.wrapperQuaternion,c,d,r);break;case"CONE":y(l,t.wrapperQuaternion,c,d,i);break;case"CIRCLE":v(l,t.wrapperQuaternion,c,d,n);break;case"RECTANGLE":h(l,t.wrapperQuaternion,c,d,a);break;case"BOX":f(l,t.wrapperQuaternion,c,d,o)}},k=(t=F,e)=>{const r=e||Date.now(),i={particleSystemId:B++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new m.Vector3(-99999),currentWorldPosition:new m.Vector3(-99999),worldPositionChange:new m.Vector3,worldQuaternion:new m.Quaternion,wrapperQuaternion:new m.Quaternion,lastWorldQuaternion:new m.Quaternion(-99999),worldEuler:new m.Euler,gravityVelocity:new m.Vector3(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},n=w(F,t,{applyToFirstObject:!1,skippedProperties:[]});let a=n.map||g();const{transform:o,duration:l,looping:c,startDelay:d,startLifetime:u,startSpeed:p,startSize:y,startRotation:f,startColor:v,startOpacity:h,gravity:O,simulationSpace:M,maxParticles:_,emission:S,shape:A,renderer:P,noise:L,velocityOverLifetime:C,onUpdate:T,onComplete:V,textureSheetAnimation:Q}=n;"string"==typeof P?.blending&&(P.blending=R[P.blending]);const k=Array.from({length:_},(()=>new m.Vector3)),W=Array.from({length:_},(()=>new m.Vector3));i.creationTimes=Array.from({length:_},(()=>0)),C.isActive&&(i.linearVelocityData=Array.from({length:_},(()=>({speed:new m.Vector3(C.linear.x?I(i.particleSystemId,C.linear.x,0):0,C.linear.y?I(i.particleSystemId,C.linear.y,0):0,C.linear.z?I(i.particleSystemId,C.linear.z,0):0),valueModifiers:{x:x(C.linear.x||0)?b(i.particleSystemId,C.linear.x):void 0,y:x(C.linear.y||0)?b(i.particleSystemId,C.linear.y):void 0,z:x(C.linear.z||0)?b(i.particleSystemId,C.linear.z):void 0}}))),i.orbitalVelocityData=Array.from({length:_},(()=>({speed:new m.Vector3(C.orbital.x?I(i.particleSystemId,C.orbital.x,0):0,C.orbital.y?I(i.particleSystemId,C.orbital.y,0):0,C.orbital.z?I(i.particleSystemId,C.orbital.z,0):0),valueModifiers:{x:x(C.orbital.x||0)?b(i.particleSystemId,C.orbital.x):void 0,y:x(C.orbital.y||0)?b(i.particleSystemId,C.orbital.y):void 0,z:x(C.orbital.z||0)?b(i.particleSystemId,C.orbital.z):void 0},positionOffset:new m.Vector3}))));["startSize","startOpacity"].forEach((t=>{i.startValues[t]=Array.from({length:_},(()=>I(i.particleSystemId,n[t],0)))}));["rotationOverLifetime"].forEach((t=>{const e=n[t];e.isActive&&(i.lifetimeValues[t]=Array.from({length:_},(()=>m.MathUtils.randFloat(e.min,e.max))))})),i.noise={isActive:L.isActive,strength:L.strength,positionAmount:L.positionAmount,rotationAmount:L.rotationAmount,sizeAmount:L.sizeAmount,sampler:L.isActive?new U({seed:Math.random(),scale:L.frequency,octaves:L.octaves}):void 0,offsets:L.useRandomOffset?Array.from({length:_},(()=>100*Math.random())):void 0};const j=new m.ShaderMaterial({uniforms:{elapsed:{value:0},map:{value:a},tiles:{value:Q.tiles},fps:{value:Q.fps},useFPSForFrameIndex:{value:"FPS"===Q.timeMode},backgroundColor:{value:P.backgroundColor},discardBackgroundColor:{value:P.discardBackgroundColor},backgroundColorTolerance:{value:P.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:P.transparent,blending:P.blending,depthTest:P.depthTest,depthWrite:P.depthWrite}),G=new m.BufferGeometry;for(let t=0;t<_;t++)D(i,A,p,k[t],W[t]);G.setFromPoints(Array.from({length:_},((t,e)=>k[e].clone())));const q=(t,e)=>{(({geometry:t,propertyName:e,maxParticles:r,factory:i})=>{t.setAttribute(e,new m.BufferAttribute(new Float32Array(Array.from({length:r},"function"==typeof i?i:()=>i)),1))})({geometry:G,propertyName:t,maxParticles:_,factory:e})};q("isActive",0),q("lifetime",0),q("startLifetime",(()=>1e3*I(i.particleSystemId,u,0))),q("startFrame",(()=>Q.startFrame?I(i.particleSystemId,Q.startFrame,0):0)),q("opacity",(()=>I(i.particleSystemId,h,0))),q("rotation",(()=>I(i.particleSystemId,f,0))),q("size",((t,e)=>i.startValues.startSize[e])),q("rotation",0);const H=Math.random();q("colorR",(()=>v.min.r+H*(v.max.r-v.min.r))),q("colorG",(()=>v.min.g+H*(v.max.g-v.min.g))),q("colorB",(()=>v.min.b+H*(v.max.b-v.min.b))),q("colorA",0);let X=new m.Points(G,j);X.position.copy(o.position),X.rotation.x=m.MathUtils.degToRad(o.rotation.x),X.rotation.y=m.MathUtils.degToRad(o.rotation.y),X.rotation.z=m.MathUtils.degToRad(o.rotation.z),X.scale.copy(o.scale);const $=r+1e3*I(i.particleSystemId,d);let Y;"WORLD"===n.simulationSpace&&(Y=new E,Y.add(X)),N.push({particleSystem:X,wrapper:Y,generalData:i,onUpdate:T,onComplete:V,creationTime:$,lastEmissionTime:$,duration:l,looping:c,simulationSpace:M,gravity:O,emission:S,normalizedConfig:n,iterationCount:0,velocities:W,deactivateParticle:t=>{G.attributes.isActive.array[t]=0,G.attributes.colorA.array[t]=0,G.attributes.colorA.needsUpdate=!0},activateParticle:({particleIndex:t,activationTime:e,position:r})=>{G.attributes.isActive.array[t]=1,i.creationTimes[t]=e,i.noise.offsets&&(i.noise.offsets[t]=100*Math.random());const a=Math.random();G.attributes.colorR.array[t]=v.min.r+a*(v.max.r-v.min.r),G.attributes.colorR.needsUpdate=!0,G.attributes.colorG.array[t]=v.min.g+a*(v.max.g-v.min.g),G.attributes.colorG.needsUpdate=!0,G.attributes.colorB.array[t]=v.min.b+a*(v.max.b-v.min.b),G.attributes.colorB.needsUpdate=!0,G.attributes.startFrame.array[t]=Q.startFrame?I(i.particleSystemId,Q.startFrame,0):0,G.attributes.startFrame.needsUpdate=!0,G.attributes.startLifetime.array[t]=1e3*I(i.particleSystemId,u,i.normalizedLifetimePercentage),G.attributes.startLifetime.needsUpdate=!0,i.startValues.startSize[t]=I(i.particleSystemId,y,i.normalizedLifetimePercentage),G.attributes.size.array[t]=i.startValues.startSize[t],G.attributes.size.needsUpdate=!0,i.startValues.startOpacity[t]=I(i.particleSystemId,h,i.normalizedLifetimePercentage),G.attributes.colorA.array[t]=i.startValues.startOpacity[t],G.attributes.colorA.needsUpdate=!0,G.attributes.rotation.array[t]=I(i.particleSystemId,f,i.normalizedLifetimePercentage),G.attributes.rotation.needsUpdate=!0,n.rotationOverLifetime.isActive&&(i.lifetimeValues.rotationOverLifetime[t]=m.MathUtils.randFloat(n.rotationOverLifetime.min,n.rotationOverLifetime.max)),D(i,A,p,k[t],W[t]);const o=Math.floor(3*t);G.attributes.position.array[o]=r.x+k[t].x,G.attributes.position.array[o+1]=r.y+k[t].y,G.attributes.position.array[o+2]=r.z+k[t].z,G.attributes.position.needsUpdate=!0,i.linearVelocityData&&i.linearVelocityData[t].speed.set(n.velocityOverLifetime.linear.x?I(i.particleSystemId,n.velocityOverLifetime.linear.x,0):0,n.velocityOverLifetime.linear.y?I(i.particleSystemId,n.velocityOverLifetime.linear.y,0):0,n.velocityOverLifetime.linear.z?I(i.particleSystemId,n.velocityOverLifetime.linear.z,0):0),i.orbitalVelocityData&&(i.orbitalVelocityData[t].speed.set(n.velocityOverLifetime.orbital.x?I(i.particleSystemId,n.velocityOverLifetime.orbital.x,0):0,n.velocityOverLifetime.orbital.y?I(i.particleSystemId,n.velocityOverLifetime.orbital.y,0):0,n.velocityOverLifetime.orbital.z?I(i.particleSystemId,n.velocityOverLifetime.orbital.z,0):0),i.orbitalVelocityData[t].positionOffset.set(k[t].x,k[t].y,k[t].z)),G.attributes.lifetime.array[t]=0,G.attributes.lifetime.needsUpdate=!0,z({delta:0,generalData:i,normalizedConfig:n,attributes:X.geometry.attributes,particleLifetimePercentage:0,particleIndex:t})}});return{instance:Y||X,resumeEmitter:()=>i.isEnabled=!0,pauseEmitter:()=>i.isEnabled=!1,dispose:()=>(t=>{N=N.filter((({particleSystem:e,wrapper:r,generalData:{particleSystemId:i}})=>e!==t&&r!==t||(s(i),e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach((t=>t.dispose())):e.material.dispose(),e.parent&&e.parent.remove(e),!1)))})(X)}},W=({now:t,delta:e,elapsed:r})=>{N.forEach((i=>{const{onUpdate:n,generalData:a,onComplete:o,particleSystem:s,wrapper:l,creationTime:c,lastEmissionTime:d,duration:u,looping:p,emission:y,normalizedConfig:f,iterationCount:v,velocities:h,deactivateParticle:g,activateParticle:x,simulationSpace:b,gravity:O}=i,M=t-c,w=M%(1e3*u);a.normalizedLifetimePercentage=Math.max(Math.min(w/(1e3*u),1),0);const{lastWorldPosition:_,currentWorldPosition:S,worldPositionChange:A,lastWorldQuaternion:P,worldQuaternion:L,worldEuler:C,gravityVelocity:E,isEnabled:T}=a;l?.parent&&a.wrapperQuaternion.copy(l.parent.quaternion);const V={..._};if(Array.isArray(s.material)?s.material.forEach((t=>{t instanceof m.ShaderMaterial&&(t.uniforms.elapsed.value=r)})):s.material instanceof m.ShaderMaterial&&(s.material.uniforms.elapsed.value=r),s.getWorldPosition(S),-99999!==_.x&&A.set(S.x-_.x,S.y-_.y,S.z-_.z),a.distanceFromLastEmitByDistance+=A.length(),s.getWorldPosition(_),s.getWorldQuaternion(L),-99999!==P.x&&P.x===L.x&&P.y===L.y&&P.z===L.z||(C.setFromQuaternion(L),P.copy(L),E.set(_.x,_.y+O,_.z),s.worldToLocal(E)),a.creationTimes.forEach(((r,i)=>{if(s.geometry.attributes.isActive.array[i]){const n=t-r;if(n>s.geometry.attributes.startLifetime.array[i])g(i);else{const t=h[i];if(t.x-=E.x*e,t.y-=E.y*e,t.z-=E.z*e,0!==O||0!==t.x||0!==t.y||0!==t.z||0!==A.x||0!==A.y||0!==A.z){const r=3*i,n=s.geometry.attributes.position.array;"WORLD"===b&&(n[r]-=A.x,n[r+1]-=A.y,n[r+2]-=A.z),n[r]+=t.x*e,n[r+1]+=t.y*e,n[r+2]+=t.z*e,s.geometry.attributes.position.needsUpdate=!0}s.geometry.attributes.lifetime.array[i]=n,s.geometry.attributes.lifetime.needsUpdate=!0;const r=n/s.geometry.attributes.startLifetime.array[i];z({delta:e,generalData:a,normalizedConfig:f,attributes:s.geometry.attributes,particleLifetimePercentage:r,particleIndex:i})}}})),T&&(p||M<1e3*u)){const o=t-d,l=y.rateOverTime?Math.floor(I(a.particleSystemId,y.rateOverTime,a.normalizedLifetimePercentage)*(o/1e3)):0,c=y.rateOverDistance?I(a.particleSystemId,y.rateOverDistance,a.normalizedLifetimePercentage):0,u=c>0&&a.distanceFromLastEmitByDistance>0?Math.floor(a.distanceFromLastEmitByDistance/(1/c)):0,m=u>0?{x:(S.x-V.x)/u,y:(S.y-V.y)/u,z:(S.z-V.z)/u}:null,p=l+u;if(c>0&&u>=1&&(a.distanceFromLastEmitByDistance=0),p>0){let e=0;for(let r=0;r<p;r++){let r=-1;if(s.geometry.attributes.isActive.array.find(((t,e)=>!t&&(r=e,!0))),-1!==r&&r<s.geometry.attributes.isActive.array.length){let n={x:0,y:0,z:0};m&&e<u&&(n={x:m.x*e,y:m.y*e,z:m.z*e},e++),x({particleIndex:r,activationTime:t,position:n}),i.lastEmissionTime=t}}}n&&n({particleSystem:s,delta:e,elapsed:r,lifetime:M,normalizedLifetime:w,iterationCount:v+1})}else o&&o({particleSystem:s})}))};export{z as applyModifiers,R as blendingMap,f as calculateRandomPositionAndVelocityOnBox,v as calculateRandomPositionAndVelocityOnCircle,y as calculateRandomPositionAndVelocityOnCone,h as calculateRandomPositionAndVelocityOnRectangle,p as calculateRandomPositionAndVelocityOnSphere,I as calculateValue,o as createBezierCurveFunction,g as createDefaultParticleTexture,k as createParticleSystem,l as getBezierCacheSize,u as getCurveFunction,b as getCurveFunctionFromConfig,Q as getDefaultParticleSystemConfig,x as isLifeTimeCurve,s as removeBezierCurveFunction,W as updateParticleSystems};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@newkrok/three-particles",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Three.js-based high-performance particle system library designed for creating visually stunning particle effects with ease. Perfect for game developers and 3D applications.",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"three-noise": "1.1.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"three": "^0.
|
|
60
|
+
"three": "^0.177.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@babel/preset-env": "^7.26.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@commitlint/config-conventional": "^19.8.0",
|
|
67
67
|
"@types/jest": "^29.5.14",
|
|
68
68
|
"@types/node": "^22.10.4",
|
|
69
|
-
"@types/three": "^0.
|
|
69
|
+
"@types/three": "^0.177.0",
|
|
70
70
|
"@typescript-eslint/eslint-plugin": "^8.21.0",
|
|
71
71
|
"@typescript-eslint/parser": "^8.21.0",
|
|
72
72
|
"babel-jest": "^29.7.0",
|
|
@@ -89,4 +89,4 @@
|
|
|
89
89
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
90
90
|
"webpack-cli": "^6.0.1"
|
|
91
91
|
}
|
|
92
|
-
}
|
|
92
|
+
}
|