@newkrok/three-particles 2.6.3 → 2.6.4

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.
Files changed (39) hide show
  1. package/dist/index.d.ts +1782 -7
  2. package/dist/index.js +1578 -6
  3. package/dist/index.js.map +1 -0
  4. package/dist/three-particles.min.js +1 -2
  5. package/dist/three-particles.min.js.map +1 -0
  6. package/package.json +5 -7
  7. package/dist/bundle-report.json +0 -1
  8. package/dist/index.d.ts.map +0 -1
  9. package/dist/js/effects/three-particles/index.d.ts +0 -7
  10. package/dist/js/effects/three-particles/index.d.ts.map +0 -1
  11. package/dist/js/effects/three-particles/index.js +0 -6
  12. package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts +0 -3
  13. package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts.map +0 -1
  14. package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.js +0 -71
  15. package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.d.ts +0 -3
  16. package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.d.ts.map +0 -1
  17. package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.js +0 -37
  18. package/dist/js/effects/three-particles/three-particles-bezier.d.ts +0 -5
  19. package/dist/js/effects/three-particles/three-particles-bezier.d.ts.map +0 -1
  20. package/dist/js/effects/three-particles/three-particles-bezier.js +0 -62
  21. package/dist/js/effects/three-particles/three-particles-curves.d.ts +0 -108
  22. package/dist/js/effects/three-particles/three-particles-curves.d.ts.map +0 -1
  23. package/dist/js/effects/three-particles/three-particles-curves.js +0 -62
  24. package/dist/js/effects/three-particles/three-particles-enums.d.ts +0 -115
  25. package/dist/js/effects/three-particles/three-particles-enums.d.ts.map +0 -1
  26. package/dist/js/effects/three-particles/three-particles-enums.js +0 -1
  27. package/dist/js/effects/three-particles/three-particles-modifiers.d.ts +0 -73
  28. package/dist/js/effects/three-particles/three-particles-modifiers.d.ts.map +0 -1
  29. package/dist/js/effects/three-particles/three-particles-modifiers.js +0 -168
  30. package/dist/js/effects/three-particles/three-particles-utils.d.ts +0 -159
  31. package/dist/js/effects/three-particles/three-particles-utils.d.ts.map +0 -1
  32. package/dist/js/effects/three-particles/three-particles-utils.js +0 -302
  33. package/dist/js/effects/three-particles/three-particles.d.ts +0 -107
  34. package/dist/js/effects/three-particles/three-particles.d.ts.map +0 -1
  35. package/dist/js/effects/three-particles/three-particles.js +0 -972
  36. package/dist/js/effects/three-particles/types.d.ts +0 -1223
  37. package/dist/js/effects/three-particles/types.d.ts.map +0 -1
  38. package/dist/js/effects/three-particles/types.js +0 -1
  39. package/dist/three-particles.min.js.LICENSE.txt +0 -6
@@ -1,62 +0,0 @@
1
- const cache = [];
2
- const nCr = (n, k) => {
3
- let z = 1;
4
- for (let i = 1; i <= k; i++)
5
- z *= (n + 1 - i) / i;
6
- return z;
7
- };
8
- export const createBezierCurveFunction = (particleSystemId, bezierPoints) => {
9
- const cacheEntry = cache.find((item) => item.bezierPoints === bezierPoints);
10
- if (cacheEntry) {
11
- if (!cacheEntry.referencedBy.includes(particleSystemId))
12
- cacheEntry.referencedBy.push(particleSystemId);
13
- return cacheEntry.curveFunction;
14
- }
15
- const entry = {
16
- referencedBy: [particleSystemId],
17
- bezierPoints,
18
- curveFunction: (percentage) => {
19
- if (percentage < 0)
20
- return bezierPoints[0].y;
21
- if (percentage > 1)
22
- return bezierPoints[bezierPoints.length - 1].y;
23
- let start = 0;
24
- let stop = bezierPoints.length - 1;
25
- bezierPoints.find((point, index) => {
26
- const result = percentage < (point.percentage ?? 0);
27
- if (result)
28
- stop = index;
29
- else if (point.percentage !== undefined)
30
- start = index;
31
- return result;
32
- });
33
- const n = stop - start;
34
- const calculatedPercentage = (percentage - (bezierPoints[start].percentage ?? 0)) /
35
- ((bezierPoints[stop].percentage ?? 1) -
36
- (bezierPoints[start].percentage ?? 0));
37
- let value = 0;
38
- for (let i = 0; i <= n; i++) {
39
- const p = bezierPoints[start + i];
40
- const c = nCr(n, i) *
41
- Math.pow(1 - calculatedPercentage, n - i) *
42
- Math.pow(calculatedPercentage, i);
43
- value += c * p.y;
44
- }
45
- return value;
46
- },
47
- };
48
- cache.push(entry);
49
- return entry.curveFunction;
50
- };
51
- export const removeBezierCurveFunction = (particleSystemId) => {
52
- while (true) {
53
- const index = cache.findIndex((item) => item.referencedBy.includes(particleSystemId));
54
- if (index === -1)
55
- break;
56
- const entry = cache[index];
57
- entry.referencedBy = entry.referencedBy.filter((id) => id !== particleSystemId);
58
- if (entry.referencedBy.length === 0)
59
- cache.splice(index, 1);
60
- }
61
- };
62
- export const getBezierCacheSize = () => cache.length;
@@ -1,108 +0,0 @@
1
- import { CurveFunction } from './types.js';
2
- /**
3
- * Predefined easing function identifiers for animating particle properties
4
- * over their lifetime.
5
- *
6
- * These functions control the rate of change and create different animation
7
- * feels. Each type has three variants:
8
- * - **IN**: Starts slow, accelerates toward the end
9
- * - **OUT**: Starts fast, decelerates toward the end
10
- * - **IN_OUT**: Combines both, slow at start and end, fast in middle
11
- *
12
- * @enum {string}
13
- *
14
- * @see {@link https://easings.net/} - Visual reference for easing functions
15
- */
16
- export declare const enum CurveFunctionId {
17
- /** Use custom Bezier curve (not an easing function) */
18
- BEZIER = "BEZIER",
19
- /** Linear interpolation with constant rate of change */
20
- LINEAR = "LINEAR",
21
- /** Quadratic (t²) easing - gentle acceleration */
22
- QUADRATIC_IN = "QUADRATIC_IN",
23
- /** Quadratic (t²) easing - gentle deceleration */
24
- QUADRATIC_OUT = "QUADRATIC_OUT",
25
- /** Quadratic (t²) easing - gentle acceleration then deceleration */
26
- QUADRATIC_IN_OUT = "QUADRATIC_IN_OUT",
27
- /** Cubic (t³) easing - moderate acceleration */
28
- CUBIC_IN = "CUBIC_IN",
29
- /** Cubic (t³) easing - moderate deceleration */
30
- CUBIC_OUT = "CUBIC_OUT",
31
- /** Cubic (t³) easing - moderate acceleration then deceleration */
32
- CUBIC_IN_OUT = "CUBIC_IN_OUT",
33
- /** Quartic (t⁴) easing - strong acceleration */
34
- QUARTIC_IN = "QUARTIC_IN",
35
- /** Quartic (t⁴) easing - strong deceleration */
36
- QUARTIC_OUT = "QUARTIC_OUT",
37
- /** Quartic (t⁴) easing - strong acceleration then deceleration */
38
- QUARTIC_IN_OUT = "QUARTIC_IN_OUT",
39
- /** Quintic (t⁵) easing - very strong acceleration */
40
- QUINTIC_IN = "QUINTIC_IN",
41
- /** Quintic (t⁵) easing - very strong deceleration */
42
- QUINTIC_OUT = "QUINTIC_OUT",
43
- /** Quintic (t⁵) easing - very strong acceleration then deceleration */
44
- QUINTIC_IN_OUT = "QUINTIC_IN_OUT",
45
- /** Sinusoidal easing - smooth, natural acceleration */
46
- SINUSOIDAL_IN = "SINUSOIDAL_IN",
47
- /** Sinusoidal easing - smooth, natural deceleration */
48
- SINUSOIDAL_OUT = "SINUSOIDAL_OUT",
49
- /** Sinusoidal easing - smooth acceleration then deceleration */
50
- SINUSOIDAL_IN_OUT = "SINUSOIDAL_IN_OUT",
51
- /** Exponential easing - dramatic, explosive acceleration */
52
- EXPONENTIAL_IN = "EXPONENTIAL_IN",
53
- /** Exponential easing - dramatic, explosive deceleration */
54
- EXPONENTIAL_OUT = "EXPONENTIAL_OUT",
55
- /** Exponential easing - dramatic acceleration then deceleration */
56
- EXPONENTIAL_IN_OUT = "EXPONENTIAL_IN_OUT",
57
- /** Circular easing - sharp acceleration with curved trajectory */
58
- CIRCULAR_IN = "CIRCULAR_IN",
59
- /** Circular easing - sharp deceleration with curved trajectory */
60
- CIRCULAR_OUT = "CIRCULAR_OUT",
61
- /** Circular easing - sharp acceleration then deceleration */
62
- CIRCULAR_IN_OUT = "CIRCULAR_IN_OUT",
63
- /** Elastic easing - oscillates back before accelerating (spring-like) */
64
- ELASTIC_IN = "ELASTIC_IN",
65
- /** Elastic easing - overshoots then oscillates back (spring-like) */
66
- ELASTIC_OUT = "ELASTIC_OUT",
67
- /** Elastic easing - oscillates at both ends (spring-like) */
68
- ELASTIC_IN_OUT = "ELASTIC_IN_OUT",
69
- /** Back easing - pulls back before accelerating forward */
70
- BACK_IN = "BACK_IN",
71
- /** Back easing - overshoots forward then pulls back */
72
- BACK_OUT = "BACK_OUT",
73
- /** Back easing - pulls back, overshoots, then settles */
74
- BACK_IN_OUT = "BACK_IN_OUT",
75
- /** Bounce easing - bounces at the start */
76
- BOUNCE_IN = "BOUNCE_IN",
77
- /** Bounce easing - bounces at the end (like a ball landing) */
78
- BOUNCE_OUT = "BOUNCE_OUT",
79
- /** Bounce easing - bounces at both start and end */
80
- BOUNCE_IN_OUT = "BOUNCE_IN_OUT"
81
- }
82
- /**
83
- * Resolves a curve function from an identifier or returns the function itself.
84
- *
85
- * This utility function allows you to use either a {@link CurveFunctionId} string
86
- * identifier or a custom function directly.
87
- *
88
- * @param curveFunctionId - Either a {@link CurveFunctionId} enum value or a
89
- * custom {@link CurveFunction} implementation
90
- * @returns The actual easing function that takes a normalized time value (0-1)
91
- * and returns the eased value
92
- *
93
- * @example
94
- * ```typescript
95
- * import { getCurveFunction, CurveFunctionId } from '@newkrok/three-particles';
96
- *
97
- * // Using a predefined easing function
98
- * const easingFunc = getCurveFunction(CurveFunctionId.CUBIC_OUT);
99
- * console.log(easingFunc(0.5)); // Returns eased value at 50% progress
100
- *
101
- * // Using a custom function
102
- * const customEasing = (t: number) => t * t; // Quadratic
103
- * const customFunc = getCurveFunction(customEasing);
104
- * console.log(customFunc(0.5)); // Returns 0.25
105
- * ```
106
- */
107
- export declare const getCurveFunction: (curveFunctionId: CurveFunctionId | CurveFunction) => CurveFunction;
108
- //# sourceMappingURL=three-particles-curves.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"three-particles-curves.d.ts","sourceRoot":"","sources":["../../../../src/js/effects/three-particles/three-particles-curves.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,0BAAkB,eAAe;IAC/B,uDAAuD;IACvD,MAAM,WAAW;IAEjB,wDAAwD;IACxD,MAAM,WAAW;IAEjB,kDAAkD;IAClD,YAAY,iBAAiB;IAC7B,kDAAkD;IAClD,aAAa,kBAAkB;IAC/B,oEAAoE;IACpE,gBAAgB,qBAAqB;IAErC,gDAAgD;IAChD,QAAQ,aAAa;IACrB,gDAAgD;IAChD,SAAS,cAAc;IACvB,kEAAkE;IAClE,YAAY,iBAAiB;IAE7B,gDAAgD;IAChD,UAAU,eAAe;IACzB,gDAAgD;IAChD,WAAW,gBAAgB;IAC3B,kEAAkE;IAClE,cAAc,mBAAmB;IAEjC,qDAAqD;IACrD,UAAU,eAAe;IACzB,qDAAqD;IACrD,WAAW,gBAAgB;IAC3B,uEAAuE;IACvE,cAAc,mBAAmB;IAEjC,uDAAuD;IACvD,aAAa,kBAAkB;IAC/B,uDAAuD;IACvD,cAAc,mBAAmB;IACjC,gEAAgE;IAChE,iBAAiB,sBAAsB;IAEvC,4DAA4D;IAC5D,cAAc,mBAAmB;IACjC,4DAA4D;IAC5D,eAAe,oBAAoB;IACnC,mEAAmE;IACnE,kBAAkB,uBAAuB;IAEzC,kEAAkE;IAClE,WAAW,gBAAgB;IAC3B,kEAAkE;IAClE,YAAY,iBAAiB;IAC7B,6DAA6D;IAC7D,eAAe,oBAAoB;IAEnC,yEAAyE;IACzE,UAAU,eAAe;IACzB,qEAAqE;IACrE,WAAW,gBAAgB;IAC3B,6DAA6D;IAC7D,cAAc,mBAAmB;IAEjC,2DAA2D;IAC3D,OAAO,YAAY;IACnB,uDAAuD;IACvD,QAAQ,aAAa;IACrB,yDAAyD;IACzD,WAAW,gBAAgB;IAE3B,2CAA2C;IAC3C,SAAS,cAAc;IACvB,+DAA+D;IAC/D,UAAU,eAAe;IACzB,oDAAoD;IACpD,aAAa,kBAAkB;CAChC;AAoCD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,gBAAgB,GAC3B,iBAAiB,eAAe,GAAG,aAAa,KAC/C,aAGuC,CAAC"}
@@ -1,62 +0,0 @@
1
- import Easing from 'easing-functions';
2
- const CurveFunctionIdMap = {
3
- ["LINEAR" /* CurveFunctionId.LINEAR */]: Easing.Linear.None,
4
- ["QUADRATIC_IN" /* CurveFunctionId.QUADRATIC_IN */]: Easing.Quadratic.In,
5
- ["QUADRATIC_OUT" /* CurveFunctionId.QUADRATIC_OUT */]: Easing.Quadratic.Out,
6
- ["QUADRATIC_IN_OUT" /* CurveFunctionId.QUADRATIC_IN_OUT */]: Easing.Quadratic.InOut,
7
- ["CUBIC_IN" /* CurveFunctionId.CUBIC_IN */]: Easing.Cubic.In,
8
- ["CUBIC_OUT" /* CurveFunctionId.CUBIC_OUT */]: Easing.Cubic.Out,
9
- ["CUBIC_IN_OUT" /* CurveFunctionId.CUBIC_IN_OUT */]: Easing.Cubic.InOut,
10
- ["QUARTIC_IN" /* CurveFunctionId.QUARTIC_IN */]: Easing.Quartic.In,
11
- ["QUARTIC_OUT" /* CurveFunctionId.QUARTIC_OUT */]: Easing.Quartic.Out,
12
- ["QUARTIC_IN_OUT" /* CurveFunctionId.QUARTIC_IN_OUT */]: Easing.Quartic.InOut,
13
- ["QUINTIC_IN" /* CurveFunctionId.QUINTIC_IN */]: Easing.Quintic.In,
14
- ["QUINTIC_OUT" /* CurveFunctionId.QUINTIC_OUT */]: Easing.Quintic.Out,
15
- ["QUINTIC_IN_OUT" /* CurveFunctionId.QUINTIC_IN_OUT */]: Easing.Quintic.InOut,
16
- ["SINUSOIDAL_IN" /* CurveFunctionId.SINUSOIDAL_IN */]: Easing.Sinusoidal.In,
17
- ["SINUSOIDAL_OUT" /* CurveFunctionId.SINUSOIDAL_OUT */]: Easing.Sinusoidal.Out,
18
- ["SINUSOIDAL_IN_OUT" /* CurveFunctionId.SINUSOIDAL_IN_OUT */]: Easing.Sinusoidal.InOut,
19
- ["EXPONENTIAL_IN" /* CurveFunctionId.EXPONENTIAL_IN */]: Easing.Exponential.In,
20
- ["EXPONENTIAL_OUT" /* CurveFunctionId.EXPONENTIAL_OUT */]: Easing.Exponential.Out,
21
- ["EXPONENTIAL_IN_OUT" /* CurveFunctionId.EXPONENTIAL_IN_OUT */]: Easing.Exponential.InOut,
22
- ["CIRCULAR_IN" /* CurveFunctionId.CIRCULAR_IN */]: Easing.Circular.In,
23
- ["CIRCULAR_OUT" /* CurveFunctionId.CIRCULAR_OUT */]: Easing.Circular.Out,
24
- ["CIRCULAR_IN_OUT" /* CurveFunctionId.CIRCULAR_IN_OUT */]: Easing.Circular.InOut,
25
- ["ELASTIC_IN" /* CurveFunctionId.ELASTIC_IN */]: Easing.Elastic.In,
26
- ["ELASTIC_OUT" /* CurveFunctionId.ELASTIC_OUT */]: Easing.Elastic.Out,
27
- ["ELASTIC_IN_OUT" /* CurveFunctionId.ELASTIC_IN_OUT */]: Easing.Elastic.InOut,
28
- ["BACK_IN" /* CurveFunctionId.BACK_IN */]: Easing.Back.In,
29
- ["BACK_OUT" /* CurveFunctionId.BACK_OUT */]: Easing.Back.Out,
30
- ["BACK_IN_OUT" /* CurveFunctionId.BACK_IN_OUT */]: Easing.Back.InOut,
31
- ["BOUNCE_IN" /* CurveFunctionId.BOUNCE_IN */]: Easing.Bounce.In,
32
- ["BOUNCE_OUT" /* CurveFunctionId.BOUNCE_OUT */]: Easing.Bounce.Out,
33
- ["BOUNCE_IN_OUT" /* CurveFunctionId.BOUNCE_IN_OUT */]: Easing.Bounce.InOut,
34
- };
35
- /**
36
- * Resolves a curve function from an identifier or returns the function itself.
37
- *
38
- * This utility function allows you to use either a {@link CurveFunctionId} string
39
- * identifier or a custom function directly.
40
- *
41
- * @param curveFunctionId - Either a {@link CurveFunctionId} enum value or a
42
- * custom {@link CurveFunction} implementation
43
- * @returns The actual easing function that takes a normalized time value (0-1)
44
- * and returns the eased value
45
- *
46
- * @example
47
- * ```typescript
48
- * import { getCurveFunction, CurveFunctionId } from '@newkrok/three-particles';
49
- *
50
- * // Using a predefined easing function
51
- * const easingFunc = getCurveFunction(CurveFunctionId.CUBIC_OUT);
52
- * console.log(easingFunc(0.5)); // Returns eased value at 50% progress
53
- *
54
- * // Using a custom function
55
- * const customEasing = (t: number) => t * t; // Quadratic
56
- * const customFunc = getCurveFunction(customEasing);
57
- * console.log(customFunc(0.5)); // Returns 0.25
58
- * ```
59
- */
60
- export const getCurveFunction = (curveFunctionId) => typeof curveFunctionId === 'function'
61
- ? curveFunctionId
62
- : CurveFunctionIdMap[curveFunctionId];
@@ -1,115 +0,0 @@
1
- /**
2
- * Defines the coordinate space in which particles are simulated.
3
- *
4
- * @enum {string}
5
- */
6
- export declare const enum SimulationSpace {
7
- /**
8
- * Particles move relative to the emitter's local coordinate system.
9
- * When the emitter moves or rotates, particles move with it.
10
- * Ideal for effects attached to moving objects (e.g., engine trails, character auras).
11
- */
12
- LOCAL = "LOCAL",
13
- /**
14
- * Particles move in world space and are independent of the emitter's transform.
15
- * Once emitted, particles remain stationary or move according to their velocity in world coordinates.
16
- * Ideal for environmental effects (e.g., smoke, explosions, ambient particles).
17
- */
18
- WORLD = "WORLD"
19
- }
20
- /**
21
- * Defines the geometric shape from which particles are emitted.
22
- *
23
- * @enum {string}
24
- */
25
- export declare const enum Shape {
26
- /**
27
- * Emit particles from a spherical volume or shell.
28
- * Configure with {@link Sphere} properties (radius, arc, radiusThickness).
29
- */
30
- SPHERE = "SPHERE",
31
- /**
32
- * Emit particles from a conical volume or shell.
33
- * Configure with {@link Cone} properties (angle, radius, arc, radiusThickness).
34
- * Useful for directional effects like fire, smoke plumes, or spray effects.
35
- */
36
- CONE = "CONE",
37
- /**
38
- * Emit particles from a box volume, shell, or edges.
39
- * Configure with {@link Box} properties (scale, emitFrom).
40
- * Useful for area-based effects like dust clouds or rain.
41
- */
42
- BOX = "BOX",
43
- /**
44
- * Emit particles from a circular area or edge.
45
- * Configure with {@link Circle} properties (radius, arc, radiusThickness).
46
- * Useful for ground impacts, rings, or radial effects.
47
- */
48
- CIRCLE = "CIRCLE",
49
- /**
50
- * Emit particles from a rectangular area.
51
- * Configure with {@link Rectangle} properties (scale, rotation).
52
- * Useful for planar effects like rain on a surface or screen effects.
53
- */
54
- RECTANGLE = "RECTANGLE"
55
- }
56
- /**
57
- * Defines where on a shape particles are emitted from.
58
- * Not all shapes support all emit modes.
59
- *
60
- * @enum {string}
61
- */
62
- export declare const enum EmitFrom {
63
- /**
64
- * Emit particles from random positions within the entire volume of the shape.
65
- * Supported by: SPHERE, CONE, BOX.
66
- */
67
- VOLUME = "VOLUME",
68
- /**
69
- * Emit particles from the surface/shell of the shape.
70
- * Supported by: SPHERE, CONE, BOX.
71
- */
72
- SHELL = "SHELL",
73
- /**
74
- * Emit particles from the edges of the shape.
75
- * Supported by: BOX.
76
- */
77
- EDGE = "EDGE"
78
- }
79
- /**
80
- * Defines how texture sheet animation is timed.
81
- *
82
- * @enum {string}
83
- */
84
- export declare const enum TimeMode {
85
- /**
86
- * Animation frames are based on the particle's lifetime percentage.
87
- * The animation completes once over the particle's lifetime.
88
- */
89
- LIFETIME = "LIFETIME",
90
- /**
91
- * Animation frames are based on frames per second (FPS).
92
- * The animation runs at a fixed speed regardless of particle lifetime.
93
- */
94
- FPS = "FPS"
95
- }
96
- /**
97
- * Defines the type of curve function used for animating values over a particle's lifetime.
98
- *
99
- * @enum {string}
100
- */
101
- export declare const enum LifeTimeCurve {
102
- /**
103
- * Use custom Bezier curves with control points.
104
- * Provides maximum control over the animation curve shape.
105
- * See {@link BezierCurve} for configuration.
106
- */
107
- BEZIER = "BEZIER",
108
- /**
109
- * Use predefined easing functions (e.g., easeInQuad, easeOutCubic).
110
- * Convenient for common animation patterns.
111
- * See {@link EasingCurve} and {@link CurveFunctionId} for available functions.
112
- */
113
- EASING = "EASING"
114
- }
115
- //# sourceMappingURL=three-particles-enums.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"three-particles-enums.d.ts","sourceRoot":"","sources":["../../../../src/js/effects/three-particles/three-particles-enums.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,0BAAkB,eAAe;IAC/B;;;;OAIG;IACH,KAAK,UAAU;IAEf;;;;OAIG;IACH,KAAK,UAAU;CAChB;AAED;;;;GAIG;AACH,0BAAkB,KAAK;IACrB;;;OAGG;IACH,MAAM,WAAW;IAEjB;;;;OAIG;IACH,IAAI,SAAS;IAEb;;;;OAIG;IACH,GAAG,QAAQ;IAEX;;;;OAIG;IACH,MAAM,WAAW;IAEjB;;;;OAIG;IACH,SAAS,cAAc;CACxB;AAED;;;;;GAKG;AACH,0BAAkB,QAAQ;IACxB;;;OAGG;IACH,MAAM,WAAW;IAEjB;;;OAGG;IACH,KAAK,UAAU;IAEf;;;OAGG;IACH,IAAI,SAAS;CACd;AAED;;;;GAIG;AACH,0BAAkB,QAAQ;IACxB;;;OAGG;IACH,QAAQ,aAAa;IAErB;;;OAGG;IACH,GAAG,QAAQ;CACZ;AAED;;;;GAIG;AACH,0BAAkB,aAAa;IAC7B;;;;OAIG;IACH,MAAM,WAAW;IAEjB;;;;OAIG;IACH,MAAM,WAAW;CAClB"}
@@ -1,73 +0,0 @@
1
- import * as THREE from 'three';
2
- import { GeneralData, NormalizedParticleSystemConfig } from './types.js';
3
- /**
4
- * Applies all active modifiers to a single particle during the update cycle.
5
- *
6
- * This function handles the animation and modification of particle properties over its lifetime,
7
- * including velocity (linear and orbital), size, opacity, color, rotation, and noise-based effects.
8
- * It is called once per particle per frame by the {@link updateParticleSystems} function.
9
- *
10
- * @param params - Configuration object containing:
11
- * @param params.delta - Time elapsed since the last frame in seconds. Used for velocity and rotation calculations.
12
- * @param params.generalData - Internal particle system state and cached values.
13
- * @param params.normalizedConfig - The normalized particle system configuration with all modifiers.
14
- * @param params.attributes - Three.js buffer attributes for position, size, rotation, and color.
15
- * @param params.particleLifetimePercentage - Normalized lifetime of the particle (0.0 to 1.0).
16
- * - 0.0 = particle just born
17
- * - 1.0 = particle at end of life
18
- * @param params.particleIndex - Index of the particle in the buffer arrays.
19
- *
20
- * @remarks
21
- * The function modifies the following particle properties based on configuration:
22
- *
23
- * - **Linear Velocity**: Moves particles in a straight line (velocityOverLifetime.linear)
24
- * - **Orbital Velocity**: Rotates particles around their emission point (velocityOverLifetime.orbital)
25
- * - **Size Over Lifetime**: Scales particle size based on lifetime curve (sizeOverLifetime)
26
- * - **Opacity Over Lifetime**: Fades particles in/out based on lifetime curve (opacityOverLifetime)
27
- * - **Color Over Lifetime**: Animates RGB channels independently based on lifetime curves (colorOverLifetime)
28
- * - **Rotation Over Lifetime**: Rotates particles around their center (rotationOverLifetime)
29
- * - **Noise**: Adds organic, turbulent motion to position, rotation, and size (noise)
30
- *
31
- * Each modifier only runs if it's active in the configuration, optimizing performance for simple effects.
32
- *
33
- * @example
34
- * ```typescript
35
- * // This function is called internally by updateParticleSystems
36
- * // You typically don't need to call it directly
37
- *
38
- * // However, understanding its behavior helps configure particle systems:
39
- * const config = {
40
- * sizeOverLifetime: {
41
- * isActive: true,
42
- * lifetimeCurve: {
43
- * type: 'BEZIER',
44
- * bezierPoints: [
45
- * { x: 0, y: 0, percentage: 0 }, // Start at 0% size
46
- * { x: 0.5, y: 1, percentage: 0.5 }, // Grow to 100% at midlife
47
- * { x: 1, y: 0, percentage: 1 } // Shrink to 0% at end
48
- * ]
49
- * }
50
- * },
51
- * opacityOverLifetime: {
52
- * isActive: true,
53
- * lifetimeCurve: {
54
- * type: 'EASING',
55
- * curveFunction: 'easeOutQuad'
56
- * }
57
- * }
58
- * };
59
- * ```
60
- *
61
- * @see {@link updateParticleSystems} - Calls this function for each active particle
62
- * @see {@link VelocityOverLifetime} - Configuration for velocity modifiers
63
- * @see {@link NoiseConfig} - Configuration for noise-based effects
64
- */
65
- export declare const applyModifiers: ({ delta, generalData, normalizedConfig, attributes, particleLifetimePercentage, particleIndex, }: {
66
- delta: number;
67
- generalData: GeneralData;
68
- normalizedConfig: NormalizedParticleSystemConfig;
69
- attributes: THREE.NormalBufferAttributes;
70
- particleLifetimePercentage: number;
71
- particleIndex: number;
72
- }) => void;
73
- //# sourceMappingURL=three-particles-modifiers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"three-particles-modifiers.d.ts","sourceRoot":"","sources":["../../../../src/js/effects/three-particles/three-particles-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,WAAW,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAC;AAKzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,eAAO,MAAM,cAAc,GAAI,kGAO5B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;IACzB,gBAAgB,EAAE,8BAA8B,CAAC;IACjD,UAAU,EAAE,KAAK,CAAC,sBAAsB,CAAC;IACzC,0BAA0B,EAAE,MAAM,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB,SA2KA,CAAC"}
@@ -1,168 +0,0 @@
1
- import * as THREE from 'three';
2
- import { calculateValue } from './three-particles-utils.js';
3
- const noiseInput = new THREE.Vector3(0, 0, 0);
4
- const orbitalEuler = new THREE.Euler();
5
- /**
6
- * Applies all active modifiers to a single particle during the update cycle.
7
- *
8
- * This function handles the animation and modification of particle properties over its lifetime,
9
- * including velocity (linear and orbital), size, opacity, color, rotation, and noise-based effects.
10
- * It is called once per particle per frame by the {@link updateParticleSystems} function.
11
- *
12
- * @param params - Configuration object containing:
13
- * @param params.delta - Time elapsed since the last frame in seconds. Used for velocity and rotation calculations.
14
- * @param params.generalData - Internal particle system state and cached values.
15
- * @param params.normalizedConfig - The normalized particle system configuration with all modifiers.
16
- * @param params.attributes - Three.js buffer attributes for position, size, rotation, and color.
17
- * @param params.particleLifetimePercentage - Normalized lifetime of the particle (0.0 to 1.0).
18
- * - 0.0 = particle just born
19
- * - 1.0 = particle at end of life
20
- * @param params.particleIndex - Index of the particle in the buffer arrays.
21
- *
22
- * @remarks
23
- * The function modifies the following particle properties based on configuration:
24
- *
25
- * - **Linear Velocity**: Moves particles in a straight line (velocityOverLifetime.linear)
26
- * - **Orbital Velocity**: Rotates particles around their emission point (velocityOverLifetime.orbital)
27
- * - **Size Over Lifetime**: Scales particle size based on lifetime curve (sizeOverLifetime)
28
- * - **Opacity Over Lifetime**: Fades particles in/out based on lifetime curve (opacityOverLifetime)
29
- * - **Color Over Lifetime**: Animates RGB channels independently based on lifetime curves (colorOverLifetime)
30
- * - **Rotation Over Lifetime**: Rotates particles around their center (rotationOverLifetime)
31
- * - **Noise**: Adds organic, turbulent motion to position, rotation, and size (noise)
32
- *
33
- * Each modifier only runs if it's active in the configuration, optimizing performance for simple effects.
34
- *
35
- * @example
36
- * ```typescript
37
- * // This function is called internally by updateParticleSystems
38
- * // You typically don't need to call it directly
39
- *
40
- * // However, understanding its behavior helps configure particle systems:
41
- * const config = {
42
- * sizeOverLifetime: {
43
- * isActive: true,
44
- * lifetimeCurve: {
45
- * type: 'BEZIER',
46
- * bezierPoints: [
47
- * { x: 0, y: 0, percentage: 0 }, // Start at 0% size
48
- * { x: 0.5, y: 1, percentage: 0.5 }, // Grow to 100% at midlife
49
- * { x: 1, y: 0, percentage: 1 } // Shrink to 0% at end
50
- * ]
51
- * }
52
- * },
53
- * opacityOverLifetime: {
54
- * isActive: true,
55
- * lifetimeCurve: {
56
- * type: 'EASING',
57
- * curveFunction: 'easeOutQuad'
58
- * }
59
- * }
60
- * };
61
- * ```
62
- *
63
- * @see {@link updateParticleSystems} - Calls this function for each active particle
64
- * @see {@link VelocityOverLifetime} - Configuration for velocity modifiers
65
- * @see {@link NoiseConfig} - Configuration for noise-based effects
66
- */
67
- export const applyModifiers = ({ delta, generalData, normalizedConfig, attributes, particleLifetimePercentage, particleIndex, }) => {
68
- const { particleSystemId, startValues, lifetimeValues, linearVelocityData, orbitalVelocityData, noise, } = generalData;
69
- const positionIndex = particleIndex * 3;
70
- const positionArr = attributes.position.array;
71
- if (linearVelocityData) {
72
- const { speed, valueModifiers } = linearVelocityData[particleIndex];
73
- const normalizedXSpeed = valueModifiers.x
74
- ? valueModifiers.x(particleLifetimePercentage)
75
- : speed.x;
76
- const normalizedYSpeed = valueModifiers.y
77
- ? valueModifiers.y(particleLifetimePercentage)
78
- : speed.y;
79
- const normalizedZSpeed = valueModifiers.z
80
- ? valueModifiers.z(particleLifetimePercentage)
81
- : speed.z;
82
- positionArr[positionIndex] += normalizedXSpeed * delta;
83
- positionArr[positionIndex + 1] += normalizedYSpeed * delta;
84
- positionArr[positionIndex + 2] += normalizedZSpeed * delta;
85
- attributes.position.needsUpdate = true;
86
- }
87
- if (orbitalVelocityData) {
88
- const { speed, positionOffset, valueModifiers } = orbitalVelocityData[particleIndex];
89
- positionArr[positionIndex] -= positionOffset.x;
90
- positionArr[positionIndex + 1] -= positionOffset.y;
91
- positionArr[positionIndex + 2] -= positionOffset.z;
92
- const normalizedXSpeed = valueModifiers.x
93
- ? valueModifiers.x(particleLifetimePercentage)
94
- : speed.x;
95
- const normalizedYSpeed = valueModifiers.y
96
- ? valueModifiers.y(particleLifetimePercentage)
97
- : speed.y;
98
- const normalizedZSpeed = valueModifiers.z
99
- ? valueModifiers.z(particleLifetimePercentage)
100
- : speed.z;
101
- orbitalEuler.set(normalizedXSpeed * delta, normalizedZSpeed * delta, normalizedYSpeed * delta);
102
- positionOffset.applyEuler(orbitalEuler);
103
- positionArr[positionIndex] += positionOffset.x;
104
- positionArr[positionIndex + 1] += positionOffset.y;
105
- positionArr[positionIndex + 2] += positionOffset.z;
106
- attributes.position.needsUpdate = true;
107
- }
108
- if (normalizedConfig.sizeOverLifetime.isActive) {
109
- const multiplier = calculateValue(particleSystemId, normalizedConfig.sizeOverLifetime.lifetimeCurve, particleLifetimePercentage);
110
- attributes.size.array[particleIndex] =
111
- startValues.startSize[particleIndex] * multiplier;
112
- attributes.size.needsUpdate = true;
113
- }
114
- if (normalizedConfig.opacityOverLifetime.isActive) {
115
- const multiplier = calculateValue(particleSystemId, normalizedConfig.opacityOverLifetime.lifetimeCurve, particleLifetimePercentage);
116
- attributes.colorA.array[particleIndex] =
117
- startValues.startOpacity[particleIndex] * multiplier;
118
- attributes.colorA.needsUpdate = true;
119
- }
120
- if (normalizedConfig.colorOverLifetime.isActive) {
121
- const rMultiplier = calculateValue(particleSystemId, normalizedConfig.colorOverLifetime.r, particleLifetimePercentage);
122
- const gMultiplier = calculateValue(particleSystemId, normalizedConfig.colorOverLifetime.g, particleLifetimePercentage);
123
- const bMultiplier = calculateValue(particleSystemId, normalizedConfig.colorOverLifetime.b, particleLifetimePercentage);
124
- attributes.colorR.array[particleIndex] =
125
- startValues.startColorR[particleIndex] * rMultiplier;
126
- attributes.colorG.array[particleIndex] =
127
- startValues.startColorG[particleIndex] * gMultiplier;
128
- attributes.colorB.array[particleIndex] =
129
- startValues.startColorB[particleIndex] * bMultiplier;
130
- attributes.colorR.needsUpdate = true;
131
- attributes.colorG.needsUpdate = true;
132
- attributes.colorB.needsUpdate = true;
133
- }
134
- if (lifetimeValues.rotationOverLifetime) {
135
- attributes.rotation.array[particleIndex] +=
136
- lifetimeValues.rotationOverLifetime[particleIndex] * delta * 0.02;
137
- attributes.rotation.needsUpdate = true;
138
- }
139
- if (noise.isActive) {
140
- const { sampler, strength, noisePower, offsets, positionAmount, rotationAmount, sizeAmount, } = noise;
141
- let noiseOnPosition;
142
- const noisePosition = (particleLifetimePercentage + (offsets ? offsets[particleIndex] : 0)) *
143
- 10 *
144
- strength;
145
- noiseInput.set(noisePosition, 0, 0);
146
- noiseOnPosition = sampler.get3(noiseInput);
147
- positionArr[positionIndex] += noiseOnPosition * noisePower * positionAmount;
148
- if (rotationAmount !== 0) {
149
- attributes.rotation.array[particleIndex] +=
150
- noiseOnPosition * noisePower * rotationAmount;
151
- attributes.rotation.needsUpdate = true;
152
- }
153
- if (sizeAmount !== 0) {
154
- attributes.size.array[particleIndex] +=
155
- noiseOnPosition * noisePower * sizeAmount;
156
- attributes.size.needsUpdate = true;
157
- }
158
- noiseInput.set(noisePosition, noisePosition, 0);
159
- noiseOnPosition = sampler.get3(noiseInput);
160
- positionArr[positionIndex + 1] +=
161
- noiseOnPosition * noisePower * positionAmount;
162
- noiseInput.set(noisePosition, noisePosition, noisePosition);
163
- noiseOnPosition = sampler.get3(noiseInput);
164
- positionArr[positionIndex + 2] +=
165
- noiseOnPosition * noisePower * positionAmount;
166
- attributes.position.needsUpdate = true;
167
- }
168
- };