custom-pixi-particles 5.2.0 → 7.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.
Files changed (86) hide show
  1. package/README.md +120 -82
  2. package/dist/index.d.ts +5 -1
  3. package/dist/index.js +19 -2
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/Particle.d.ts +15 -1
  6. package/dist/lib/Particle.js +29 -0
  7. package/dist/lib/Particle.js.map +1 -1
  8. package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +10 -6
  9. package/dist/lib/behaviour/AngularVelocityBehaviour.js +45 -14
  10. package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -1
  11. package/dist/lib/behaviour/AttractionRepulsionBehaviour.d.ts +42 -0
  12. package/dist/lib/behaviour/AttractionRepulsionBehaviour.js +78 -0
  13. package/dist/lib/behaviour/AttractionRepulsionBehaviour.js.map +1 -0
  14. package/dist/lib/behaviour/BehaviourNames.d.ts +13 -2
  15. package/dist/lib/behaviour/BehaviourNames.js +13 -1
  16. package/dist/lib/behaviour/BehaviourNames.js.map +1 -1
  17. package/dist/lib/behaviour/CollisionBehaviour.d.ts +86 -0
  18. package/dist/lib/behaviour/CollisionBehaviour.js +140 -0
  19. package/dist/lib/behaviour/CollisionBehaviour.js.map +1 -0
  20. package/dist/lib/behaviour/ColorBehaviour.d.ts +22 -0
  21. package/dist/lib/behaviour/ColorBehaviour.js +122 -6
  22. package/dist/lib/behaviour/ColorBehaviour.js.map +1 -1
  23. package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +14 -8
  24. package/dist/lib/behaviour/EmitDirectionBehaviour.js +53 -12
  25. package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -1
  26. package/dist/lib/behaviour/EmitterBehaviours.d.ts +6 -0
  27. package/dist/lib/behaviour/EmitterBehaviours.js +11 -0
  28. package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
  29. package/dist/lib/behaviour/ForceFieldsBehaviour.d.ts +53 -0
  30. package/dist/lib/behaviour/ForceFieldsBehaviour.js +80 -0
  31. package/dist/lib/behaviour/ForceFieldsBehaviour.js.map +1 -0
  32. package/dist/lib/behaviour/GroupingBehaviour.d.ts +57 -0
  33. package/dist/lib/behaviour/GroupingBehaviour.js +143 -0
  34. package/dist/lib/behaviour/GroupingBehaviour.js.map +1 -0
  35. package/dist/lib/behaviour/LifeBehaviour.d.ts +0 -20
  36. package/dist/lib/behaviour/LifeBehaviour.js +0 -20
  37. package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
  38. package/dist/lib/behaviour/LightEffectBehaviour.d.ts +59 -0
  39. package/dist/lib/behaviour/LightEffectBehaviour.js +94 -0
  40. package/dist/lib/behaviour/LightEffectBehaviour.js.map +1 -0
  41. package/dist/lib/behaviour/NoiseBasedMotionBehaviour.d.ts +28 -0
  42. package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js +50 -0
  43. package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js.map +1 -0
  44. package/dist/lib/behaviour/PositionBehaviour.d.ts +0 -13
  45. package/dist/lib/behaviour/PositionBehaviour.js +3 -53
  46. package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
  47. package/dist/lib/behaviour/RotationBehaviour.d.ts +20 -12
  48. package/dist/lib/behaviour/RotationBehaviour.js +50 -16
  49. package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
  50. package/dist/lib/behaviour/SizeBehaviour.d.ts +33 -3
  51. package/dist/lib/behaviour/SizeBehaviour.js +105 -20
  52. package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
  53. package/dist/lib/behaviour/SoundReactiveBehaviour.d.ts +58 -0
  54. package/dist/lib/behaviour/SoundReactiveBehaviour.js +132 -0
  55. package/dist/lib/behaviour/SoundReactiveBehaviour.js.map +1 -0
  56. package/dist/lib/behaviour/SpawnBehaviour.d.ts +89 -0
  57. package/dist/lib/behaviour/SpawnBehaviour.js +705 -0
  58. package/dist/lib/behaviour/SpawnBehaviour.js.map +1 -0
  59. package/dist/lib/behaviour/StretchBehaviour.d.ts +30 -0
  60. package/dist/lib/behaviour/StretchBehaviour.js +59 -0
  61. package/dist/lib/behaviour/StretchBehaviour.js.map +1 -0
  62. package/dist/lib/behaviour/TemperatureBehaviour.d.ts +47 -0
  63. package/dist/lib/behaviour/TemperatureBehaviour.js +64 -0
  64. package/dist/lib/behaviour/TemperatureBehaviour.js.map +1 -0
  65. package/dist/lib/behaviour/TimelineBehaviour.d.ts +73 -0
  66. package/dist/lib/behaviour/TimelineBehaviour.js +100 -0
  67. package/dist/lib/behaviour/TimelineBehaviour.js.map +1 -0
  68. package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +2 -1
  69. package/dist/lib/behaviour/TurbulenceBehaviour.js +6 -1
  70. package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
  71. package/dist/lib/behaviour/index.d.ts +12 -1
  72. package/dist/lib/behaviour/index.js +12 -1
  73. package/dist/lib/behaviour/index.js.map +1 -1
  74. package/dist/lib/customPixiParticlesSettingsInterface.d.ts +1 -0
  75. package/dist/lib/emitter/Emitter.d.ts +4 -1
  76. package/dist/lib/emitter/Emitter.js +40 -1
  77. package/dist/lib/emitter/Emitter.js.map +1 -1
  78. package/dist/lib/parser/BehaviourParser.js +1 -1
  79. package/dist/lib/parser/BehaviourParser.js.map +1 -1
  80. package/dist/lib/pixi/Renderer.d.ts +14 -5
  81. package/dist/lib/pixi/Renderer.js +128 -70
  82. package/dist/lib/pixi/Renderer.js.map +1 -1
  83. package/dist/lib/pixi/TestRenderer.d.ts +125 -0
  84. package/dist/lib/pixi/TestRenderer.js +560 -0
  85. package/dist/lib/pixi/TestRenderer.js.map +1 -0
  86. package/package.json +7 -5
package/README.md CHANGED
@@ -1,126 +1,164 @@
1
1
  # CustomPIXIParticles by [@lukasz-okuniewicz](http://github.com/lukasz-okuniewicz)
2
2
 
3
- CustomPIXIParticles is a lightweight and flexible library for creating and managing particle effects in PIXI.js applications. It provides a simple API for defining particle emitters, textures, and configurations, allowing developers to create a wide range of visual effects with ease.
3
+ **CustomPIXIParticles** is a lightweight, high-performance library designed for creating and managing customizable particle effects in **PIXI.js** applications. It offers an intuitive API, flexible configuration options, and seamless compatibility with modern PIXI.js versions, making it an essential tool for developers looking to create stunning visual effects.
4
4
 
5
- ### Features
6
- * Easy-to-use API: Create particle emitters with just a few lines of code
7
- * Flexible configuration: Customize particle behavior, appearance, and animation
8
- * High performance: Render particles efficiently without impacting application performance
9
- * Compatible with PIXI.js v7: Works seamlessly with the latest version of PIXI.js
5
+ ---
10
6
 
11
- ### Versions Compatibility
7
+ ### Support My Work
8
+ If you find **CustomPIXIParticles** useful and would like to support my work, you can buy me a coffee. Your contributions help me dedicate more time to improving this library and creating new features for the community. Thank you for your support! ☕💖
12
9
 
13
- | PixiJS | CustomPIXIParticles |
14
- |---|---|
15
- | v5.x - v6.x | v4.x |
16
- | v7.x | v5.x |
10
+ [![Buy Me a Coffee](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-Support%20My%20Work-orange?logo=buy-me-a-coffee&logoColor=white)](https://buymeacoffee.com/lukasz.okuniewicz)
17
11
 
18
- ### Demo
19
- [custom-pixi-particles](http://particles.okuniewicz.eu/)
12
+ ---
20
13
 
21
- #### Installation:
14
+ ## ✨ Features
15
+ - **Simple API**: Effortlessly create particle emitters with minimal code.
16
+ - **Highly Configurable**: Adjust particle behavior, appearance, animation, and more.
17
+ - **Performance Optimized**: Handle thousands of particles with minimal performance overhead.
18
+ - **PIXI.js Compatibility**: Fully compatible with **PIXI.js v8**, **PIXI.js v7**, with legacy support for v5.x and v6.x.
19
+ - **Real-Time Customization**: Dynamically update textures, positions, configurations, and emitters on the fly.
22
20
 
23
- ```
21
+ ---
22
+
23
+ ## 🎮 Demo
24
+ Try it out here: [CustomPIXIParticles Live Editor](https://okuniewicz.eu/)
25
+
26
+ ---
27
+
28
+ ## 🛠️ Installation
29
+
30
+ Install via npm:
31
+
32
+ ```bash
24
33
  npm install custom-pixi-particles
25
34
  ```
26
35
 
27
- #### Usage:
28
- Import or require the library:
36
+ ---
37
+
38
+ ## 🚀 Quick Start
39
+ Import or Require
29
40
  ```javascript
30
- const customPixiParticles = require('custom-pixi-particles')
31
- // or
41
+ // ES6 Modules
32
42
  import customPixiParticles from 'custom-pixi-particles'
43
+
44
+ // CommonJS
45
+ const customPixiParticles = require('custom-pixi-particles')
33
46
  ```
34
47
 
48
+ Create Particle Effects
35
49
  ```javascript
36
- // Define array of textures
50
+ // Define textures and emitter configuration
37
51
  const textures = ['texture1.png', 'texture2.png']
38
- // Define generated emiter config
39
- const emitterConfig = {...}
40
- // Create particles
41
- this.particles = customParticles.create({ textures, emitterConfig })
42
- // Start to play
43
- this.particles.play()
44
- // Add particles to PIXI container
45
- container.addChild(this.particles)
52
+ const emitterConfig = {
53
+ // Your configuration object
54
+ }
55
+
56
+ // Initialize particle emitter
57
+ const particles = customPixiParticles.create({ textures, emitterConfig })
58
+
59
+ // Add emitter to the PIXI container
60
+ container.addChild(particles)
61
+
62
+ // Start the emitter
63
+ particles.play()
46
64
  ```
47
65
 
48
- ### API Reference
49
- `create`
66
+ ---
67
+
68
+ ## 📖 API Reference
69
+ Initializes a particle emitter.
50
70
  ```javascript
51
- // All possible params which can be passed during particles creation
52
- this.particles = customPixiParticles.create({
53
- textures: [String],
54
- animatedSpriteZeroPad: Number,
55
- animatedSpriteIndexToStart: Number,
56
- emitterConfig: Object,
57
- finishingTextures: [String],
58
- vertices: Boolean,
59
- position: Boolean,
60
- rotation: Boolean,
61
- uvs: Boolean,
62
- tint: Boolean,
63
- maxParticles: Number,
64
- maxFPS: Number,
65
- tickerSpeed: Number,
71
+ const particles = customPixiParticles.create({
72
+ textures: [String], // Array of particle textures
73
+ emitterConfig: Object, // Configuration object for the emitter
74
+ animatedSpriteZeroPad: Number, // Zero-padding for animated sprite names
75
+ animatedSpriteIndexToStart: Number, // Initial frame index for animated sprites
76
+ finishingTextures: [String], // Textures used for particle finishing
77
+ vertices: Boolean, // Use vertex mode for rendering
78
+ position: Boolean, // Allow position-based behavior
79
+ rotation: Boolean, // Allow rotation-based behavior
80
+ uvs: Boolean, // Apply UV mapping
81
+ tint: Boolean, // Apply tint to particles
82
+ maxParticles: Number, // Maximum particles allowed
83
+ maxFPS: Number, // Cap emitter update frequency
84
+ tickerSpeed: Number, // Speed of the PIXI ticker
66
85
  })
67
86
  ```
68
87
 
88
+ ### Event Callbacks
89
+ Triggered when the particle animation completes.
69
90
  ```javascript
70
- // Callback function called when the particle animation completes.
71
- this.particles.onComplete = () => {
72
- //...
91
+ particles.onComplete = () => {
92
+ console.log("Particle animation finished!")
73
93
  }
74
94
  ```
75
95
 
96
+ ### Texture Management
97
+ Updates the particle emitter's textures.
76
98
  ```javascript
77
- // Define array of new textures
78
- const newTextures = ['texture3.png', 'texture4.png']
79
- // Updates the particle emitter's textures.
80
- this.particles.setTextures(newTextures)
99
+ particles.setTextures(['texture3.png', 'texture4.png'])
81
100
  ```
82
101
 
102
+ ### Configuration Updates
103
+ Dynamically update emitter configurations.
83
104
  ```javascript
84
- // Updates the particle emitter's configuration.
85
- this.particles.updateConfig({
86
- // Update emitter configuration properties
87
- })
105
+ particles.updateConfig({ /* New configuration properties */ })
88
106
  ```
89
107
 
108
+ ### State Control
109
+ Starts or resumes the emitter.
90
110
  ```javascript
91
- // Sets the paused state
92
- pause(isPaused)
93
-
94
- // Starts the emitter
95
- start()
111
+ particles.play()
112
+ ```
113
+ Toggles the paused state.
114
+ ```javascript
115
+ particles.pause(isPaused)
116
+ ```
117
+ Terminates the emitter and stops emission.
118
+ ```javascript
119
+ particles.stop()
120
+ ```
121
+ Halts all emissions immediately.
122
+ ```javascript
123
+ particles.stopImmediately()
124
+ ```
125
+ Resets the emitter to its initial state.
126
+ ```javascript
127
+ particles.resetEmitter()
128
+ ```
96
129
 
97
- // Resets the particle emitters in this class without removing existing particles and plays them
98
- play()
130
+ ### Position Updates
131
+ Dynamically adjust the emitter's position.
132
+ ```javascript
133
+ particles.updatePosition({ x: 100, y: 200 })
134
+ ```
99
135
 
100
- // Immediately stops emitting particles
101
- stopImmediately()
136
+ ### Pool Management
137
+ Clears internal object pools to free memory.
138
+ ```javascript
139
+ particles.clearPool()
140
+ ```
102
141
 
103
- // Destroy particles
104
- destroy()
142
+ ---
105
143
 
106
- // Terminates the emitter
107
- stop()
144
+ ## 🖥️ Versions Compatibility
145
+ | PixiJS | CustomPIXIParticles |
146
+ |-------------|---------------------|
147
+ | v5.x - v6.x | v4.x |
148
+ | v7.x | v7.x |
149
+ | v8.x | v8.x |
108
150
 
109
- // Resets the emitters to their initial state
110
- resetEmitter()
151
+ ---
111
152
 
112
- // Update textures used by the emitter
113
- setTextures(textures)
153
+ ## 🛠️ Advanced Editor
154
+ Easily design and fine-tune your particle effects with the CustomPIXIParticles Editor.
155
+ 🔗 [CustomPIXIParticles Live Editor](https://okuniewicz.eu/)
114
156
 
115
- // Updates the configuration of the emitter
116
- updateConfig(config, resetDuration = true)
157
+ ---
117
158
 
118
- // Updates the position of the emitter
119
- updatePosition(position, resetDuration = true)
159
+ ## 🤝 Contributing
160
+ Contributions, feature suggestions, and bug reports are welcome! Open an issue or submit a pull request on the [GitHub repository](https://github.com/lukasz-okuniewicz/custom-pixi-particles).
120
161
 
121
- // Clear pools
122
- clearPool()
123
- ```
162
+ ---
124
163
 
125
- ### Additional Resources
126
- Editor for particles: [custom-pixi-particles-editor](https://github.com/lukasz-okuniewicz/custom-pixi-particles-editor)
164
+ With CustomPIXIParticles, you're not just building animations; you're crafting immersive experiences! 🌟
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Renderer from './lib/pixi/Renderer';
2
2
  import { ICustomPixiParticlesSettings } from './lib/customPixiParticlesSettingsInterface';
3
+ import TestRenderer from './lib/pixi/TestRenderer';
3
4
  /**
4
5
  * Constructs a renderer for custom pixi particles
5
6
  * @class Renderer
@@ -8,4 +9,7 @@ import { ICustomPixiParticlesSettings } from './lib/customPixiParticlesSettingsI
8
9
  declare const customPixiParticles: {
9
10
  create(settings: ICustomPixiParticlesSettings): Renderer;
10
11
  };
11
- export { Renderer, customPixiParticles, ICustomPixiParticlesSettings };
12
+ declare const _customPixiParticlesEditorOnly: {
13
+ create(settings: ICustomPixiParticlesSettings): TestRenderer;
14
+ };
15
+ export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly, ICustomPixiParticlesSettings };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import Renderer from './lib/pixi/Renderer';
2
+ import TestRenderer from './lib/pixi/TestRenderer';
2
3
  /**
3
4
  * Constructs a renderer for custom pixi particles
4
5
  * @class Renderer
@@ -6,7 +7,7 @@ import Renderer from './lib/pixi/Renderer';
6
7
  */
7
8
  const customPixiParticles = {
8
9
  create(settings) {
9
- const { textures, emitterConfig, animatedSpriteZeroPad = 2, animatedSpriteIndexToStart = 0, finishingTextures = [], vertices = true, position = true, rotation = true, uvs = true, tint = true, maxParticles = 10000, maxFPS = 60, tickerSpeed = 0.02, } = settings;
10
+ const { textures, emitterConfig, animatedSpriteZeroPad = 2, animatedSpriteIndexToStart = 0, finishingTextures = [], vertices = true, position = true, rotation = true, uvs = true, tint = true, maxParticles = 10000, maxFPS = 60, minFPS = 30, tickerSpeed = 0.02, } = settings;
10
11
  return new Renderer({
11
12
  textures,
12
13
  animatedSpriteZeroPad,
@@ -20,9 +21,25 @@ const customPixiParticles = {
20
21
  tint,
21
22
  maxParticles,
22
23
  maxFPS,
24
+ minFPS,
23
25
  tickerSpeed,
24
26
  });
25
27
  },
26
28
  };
27
- export { Renderer, customPixiParticles };
29
+ const _customPixiParticlesEditorOnly = {
30
+ create(settings) {
31
+ const { textures, emitterConfig, animatedSpriteZeroPad = 2, animatedSpriteIndexToStart = 0, finishingTextures = [], maxFPS = 60, minFPS = 60, tickerSpeed = 0.02, } = settings;
32
+ return new TestRenderer({
33
+ textures,
34
+ animatedSpriteZeroPad,
35
+ animatedSpriteIndexToStart,
36
+ emitterConfig,
37
+ finishingTextures,
38
+ maxFPS,
39
+ minFPS,
40
+ tickerSpeed,
41
+ });
42
+ },
43
+ };
44
+ export { Renderer, customPixiParticles, _customPixiParticlesEditorOnly };
28
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAG1C;;;;GAIG;AACH,MAAM,mBAAmB,GAAG;IAC1B,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,GAAG,GAAG,IAAI,EACV,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,KAAK,EACpB,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,QAAQ,CAAC;YAClB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAgC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,qBAAqB,CAAA;AAE1C,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAElD;;;;GAIG;AACH,MAAM,mBAAmB,GAAG;IAC1B,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,QAAQ,GAAG,IAAI,EACf,GAAG,GAAG,IAAI,EACV,IAAI,GAAG,IAAI,EACX,YAAY,GAAG,KAAK,EACpB,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,QAAQ,CAAC;YAClB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,QAAQ;YACR,QAAQ;YACR,QAAQ;YACR,GAAG;YACH,IAAI;YACJ,YAAY;YACZ,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,MAAM,8BAA8B,GAAG;IACrC,MAAM,CAAC,QAAsC;QAC3C,MAAM,EACJ,QAAQ,EACR,aAAa,EACb,qBAAqB,GAAG,CAAC,EACzB,0BAA0B,GAAG,CAAC,EAC9B,iBAAiB,GAAG,EAAE,EACtB,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,WAAW,GAAG,IAAI,GACnB,GAAG,QAAQ,CAAA;QACZ,OAAO,IAAI,YAAY,CAAC;YACtB,QAAQ;YACR,qBAAqB;YACrB,0BAA0B;YAC1B,aAAa;YACb,iBAAiB;YACjB,MAAM;YACN,MAAM;YACN,WAAW;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,8BAA8B,EAAgC,CAAA"}
@@ -1,4 +1,4 @@
1
- import { Sprite } from 'pixi.js-legacy';
1
+ import { Sprite } from 'pixi.js';
2
2
  import { Color, Point } from './util';
3
3
  import ThereBack from './util/ThereBack';
4
4
  /**
@@ -62,6 +62,7 @@ export default class Particle {
62
62
  * Stores the ending color of the particle
63
63
  */
64
64
  colorEnd: Color;
65
+ superColorAlphaEnd: number;
65
66
  /**
66
67
  * Stores the maximum life time of the particle
67
68
  */
@@ -168,6 +169,13 @@ export default class Particle {
168
169
  * Stores the warp stretch of the particle
169
170
  */
170
171
  warpStretch: number;
172
+ skipPositionBehaviour: boolean;
173
+ skipAngularVelocityBehaviour: boolean;
174
+ skipColorBehaviour: boolean;
175
+ skipEmitDirectionBehaviour: boolean;
176
+ skipRotationBehaviour: boolean;
177
+ skipSizeBehaviour: boolean;
178
+ skipAttractionRepulsionBehaviour: boolean;
171
179
  /**
172
180
  * Stores the warp distance scale converter of the particle
173
181
  */
@@ -193,6 +201,12 @@ export default class Particle {
193
201
  thereAmplitude: number;
194
202
  backAmplitude: number;
195
203
  direction: number;
204
+ noiseOffset: Point;
205
+ timeline: any[];
206
+ initialDirectionCos: number;
207
+ initialDirectionSin: number;
208
+ velocityScale: number;
209
+ rotationAcceleration: number;
196
210
  /**
197
211
  * Constructs a particle object
198
212
  */
@@ -62,6 +62,14 @@ class Particle {
62
62
  * Stores the ending color of the particle
63
63
  */
64
64
  this.colorEnd = new Color();
65
+ this.superColorAlphaEnd = 1;
66
+ this.skipPositionBehaviour = false;
67
+ this.skipAngularVelocityBehaviour = false;
68
+ this.skipColorBehaviour = false;
69
+ this.skipEmitDirectionBehaviour = false;
70
+ this.skipRotationBehaviour = false;
71
+ this.skipSizeBehaviour = false;
72
+ this.skipAttractionRepulsionBehaviour = false;
65
73
  this.fromAtoB = false;
66
74
  this.fromAtoBTwoWays = false;
67
75
  this.pointA = new Point();
@@ -79,6 +87,12 @@ class Particle {
79
87
  this.thereAmplitude = 10;
80
88
  this.backAmplitude = 10;
81
89
  this.direction = 1;
90
+ this.noiseOffset = new Point();
91
+ this.timeline = [];
92
+ this.initialDirectionCos = 0;
93
+ this.initialDirectionSin = 0;
94
+ this.velocityScale = 1;
95
+ this.rotationAcceleration = 0;
82
96
  this.reset();
83
97
  }
84
98
  /**
@@ -91,6 +105,14 @@ class Particle {
91
105
  this.x = 0;
92
106
  this.y = 0;
93
107
  this.z = 0;
108
+ this.timeline = [];
109
+ this.skipPositionBehaviour = false;
110
+ this.skipAngularVelocityBehaviour = false;
111
+ this.skipColorBehaviour = false;
112
+ this.skipAttractionRepulsionBehaviour = false;
113
+ this.skipEmitDirectionBehaviour = false;
114
+ this.skipRotationBehaviour = false;
115
+ this.skipSizeBehaviour = false;
94
116
  this.movement.set(0, 0);
95
117
  this.acceleration.set(0, 0);
96
118
  this.velocity.set(0, 0);
@@ -115,6 +137,7 @@ class Particle {
115
137
  this.color.set(255, 255, 255, 1);
116
138
  this.colorStart.set(0, 0, 0, 1);
117
139
  this.colorEnd.set(0, 0, 0, 1);
140
+ this.superColorAlphaEnd = 1;
118
141
  this.cameraZ = 0;
119
142
  this.cameraZConverter = 10;
120
143
  this.warpSpeed = 0;
@@ -122,6 +145,7 @@ class Particle {
122
145
  this.warpFov = 20;
123
146
  this.warpStretch = 5;
124
147
  this.warpDistanceScaleConverter = 2000;
148
+ this.sizeDifference = { x: 1, y: 1 };
125
149
  this.fromAtoB = false;
126
150
  this.fromAtoBTwoWays = false;
127
151
  this.pointA.set(0, 0);
@@ -139,6 +163,11 @@ class Particle {
139
163
  this.yStart = 0;
140
164
  this.xTarget = 0;
141
165
  this.yTarget = 0;
166
+ this.noiseOffset = new Point();
167
+ this.initialDirectionCos = 0;
168
+ this.initialDirectionSin = 0;
169
+ this.velocityScale = 1;
170
+ this.rotationAcceleration = 0;
142
171
  }
143
172
  /**
144
173
  * Checks if the particle is almost dead
@@ -1 +1 @@
1
- {"version":3,"file":"Particle.js","sourceRoot":"","sources":["../../src/lib/Particle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,SAAS,MAAM,kBAAkB,CAAA;AAExC;;GAEG;AACH,MAAqB,QAAQ;IAmO3B;;OAEG;IACH;QApOA,SAAI,GAAoB,IAAI,CAAA;QAC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  import Particle from '../Particle';
3
- /**
4
- * AngularVelocityBehaviour is a subclass of Behaviour and defines the angular velocity of a particle.
5
- *
6
- * @class AngularVelocityBehaviour
7
- * @extends {Behaviour}
8
- */
9
3
  export default class AngularVelocityBehaviour extends Behaviour {
10
4
  protected priority: number;
11
5
  private enabled;
@@ -15,6 +9,11 @@ export default class AngularVelocityBehaviour extends Behaviour {
15
9
  private maxRadiusVariance;
16
10
  private minRadius;
17
11
  private minRadiusVariance;
12
+ private oscillate;
13
+ private oscillationSpeed;
14
+ private oscillationAmplitude;
15
+ private linearRadiusReduction;
16
+ private dynamicRadius;
18
17
  /**
19
18
  * Initializes particle properties of the behaviour
20
19
  *
@@ -51,6 +50,11 @@ export default class AngularVelocityBehaviour extends Behaviour {
51
50
  maxRadiusVariance: number;
52
51
  minRadius: number;
53
52
  minRadiusVariance: number;
53
+ oscillate: boolean;
54
+ oscillationSpeed: number;
55
+ oscillationAmplitude: number;
56
+ linearRadiusReduction: boolean;
57
+ dynamicRadius: boolean;
54
58
  priority: number;
55
59
  name: string;
56
60
  };
@@ -1,12 +1,6 @@
1
1
  import Behaviour from './Behaviour';
2
2
  import math from '../util/maths';
3
3
  import BehaviourNames from './BehaviourNames';
4
- /**
5
- * AngularVelocityBehaviour is a subclass of Behaviour and defines the angular velocity of a particle.
6
- *
7
- * @class AngularVelocityBehaviour
8
- * @extends {Behaviour}
9
- */
10
4
  export default class AngularVelocityBehaviour extends Behaviour {
11
5
  constructor() {
12
6
  super(...arguments);
@@ -18,6 +12,11 @@ export default class AngularVelocityBehaviour extends Behaviour {
18
12
  this.maxRadiusVariance = 0;
19
13
  this.minRadius = 0;
20
14
  this.minRadiusVariance = 0;
15
+ this.oscillate = false; // Oscillate angular velocity
16
+ this.oscillationSpeed = 1; // Speed of oscillation
17
+ this.oscillationAmplitude = 10; // Amplitude of oscillation in degrees
18
+ this.linearRadiusReduction = true; // Linear or exponential radius reduction
19
+ this.dynamicRadius = false; // Allow dynamic radius changes during lifetime
21
20
  /**
22
21
  * Initializes particle properties of the behaviour
23
22
  *
@@ -25,10 +24,14 @@ export default class AngularVelocityBehaviour extends Behaviour {
25
24
  * @memberof AngularVelocityBehaviour
26
25
  */
27
26
  this.init = (particle) => {
27
+ if (!this.enabled)
28
+ return;
28
29
  particle.radiansPerSecond = math.degreesToRadians(this.degrees + this.varianceFrom(this.degreesVariance));
29
30
  const radiusStart = this.maxRadius + this.varianceFrom(this.maxRadiusVariance);
31
+ const radiusEnd = this.minRadius + this.varianceFrom(this.minRadiusVariance);
30
32
  particle.radiusStart = radiusStart;
31
- particle.radiusEnd = this.minRadius + this.varianceFrom(this.minRadiusVariance);
33
+ particle.radiusEnd = radiusEnd;
34
+ particle.velocityAngle = 0;
32
35
  particle.x = 0;
33
36
  particle.y = 0;
34
37
  particle.radius = radiusStart;
@@ -42,13 +45,36 @@ export default class AngularVelocityBehaviour extends Behaviour {
42
45
  * @memberof AngularVelocityBehaviour
43
46
  */
44
47
  this.apply = (particle, deltaTime) => {
45
- const { radiusStart, radiusEnd, radiansPerSecond, lifeProgress } = particle;
46
- const velocityAngle = particle.velocityAngle + radiansPerSecond * deltaTime;
47
- const radius = radiusStart + (radiusEnd - radiusStart) * lifeProgress;
48
- const movementX = Math.cos(velocityAngle) * radius;
49
- const movementY = Math.sin(velocityAngle) * radius;
50
- particle.velocityAngle = velocityAngle;
51
- particle.radius = radius;
48
+ if (!this.enabled)
49
+ return;
50
+ if (particle.skipAngularVelocityBehaviour)
51
+ return;
52
+ const { radiusStart, radiusEnd, radiansPerSecond, lifeProgress, velocityAngle } = particle;
53
+ let angleVelocity = radiansPerSecond;
54
+ // Oscillation logic
55
+ if (this.oscillate) {
56
+ const oscillationFactor = Math.sin(particle.lifeTime * this.oscillationSpeed) * this.oscillationAmplitude;
57
+ angleVelocity += math.degreesToRadians(oscillationFactor);
58
+ }
59
+ // Update angle
60
+ const newVelocityAngle = velocityAngle + angleVelocity * deltaTime;
61
+ // Radius calculation
62
+ let newRadius;
63
+ if (this.linearRadiusReduction) {
64
+ newRadius = radiusStart + (radiusEnd - radiusStart) * lifeProgress;
65
+ }
66
+ else {
67
+ // Exponential radius reduction
68
+ const progressFactor = Math.pow(lifeProgress, 2);
69
+ newRadius = radiusStart + (radiusEnd - radiusStart) * progressFactor;
70
+ }
71
+ if (this.dynamicRadius) {
72
+ newRadius += Math.sin(particle.lifeTime * 2 * Math.PI) * 5; // Example dynamic change
73
+ }
74
+ const movementX = Math.cos(newVelocityAngle) * newRadius;
75
+ const movementY = Math.sin(newVelocityAngle) * newRadius;
76
+ particle.velocityAngle = newVelocityAngle;
77
+ particle.radius = newRadius;
52
78
  particle.movement.x = movementX;
53
79
  particle.movement.y = movementY;
54
80
  particle.x = movementX;
@@ -79,6 +105,11 @@ export default class AngularVelocityBehaviour extends Behaviour {
79
105
  maxRadiusVariance: this.maxRadiusVariance,
80
106
  minRadius: this.minRadius,
81
107
  minRadiusVariance: this.minRadiusVariance,
108
+ oscillate: this.oscillate,
109
+ oscillationSpeed: this.oscillationSpeed,
110
+ oscillationAmplitude: this.oscillationAmplitude,
111
+ linearRadiusReduction: this.linearRadiusReduction,
112
+ dynamicRadius: this.dynamicRadius,
82
113
  priority: this.priority,
83
114
  name: this.getName(),
84
115
  };
@@ -1 +1 @@
1
- {"version":3,"file":"AngularVelocityBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/AngularVelocityBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,IAAI,MAAM,eAAe,CAAA;AAChC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAyB,SAAQ,SAAS;IAA/D;;QACY,aAAQ,GAAW,GAAG,CAAA;QACxB,YAAO,GAAY,KAAK,CAAA;QACxB,YAAO,GAAW,CAAC,CAAA;QACnB,oBAAe,GAAW,CAAC,CAAA;QAC3B,cAAS,GAAW,CAAC,CAAA;QACr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AC,gBAAgB,CAAC,GAAG,SAAS,CAAA;YAExD,QAAQ,CAAC,aAAa,GAAG,gBAAgB,CAAA;YACzC,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAA;YAC3B,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;YAC/B,QAAQ,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;YAC/B,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;YACtB,QAAQ,CAAC,CAAC,GAAG,SAAS,CAAA;QACxB,CAAC,CAAA;IAoCH,CAAC;IAlCC;;;;;OAKG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,iBAAiB,CAAA;IACzC,CAAC;IAED;;;;;OAKG;IACH,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;YACjD,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ import { Behaviour } from './index';
2
+ import Particle from '../Particle';
3
+ /**
4
+ * AttractionRepulsionBehaviour applies attraction or repulsion forces to particles
5
+ * without overriding other position-related behaviors.
6
+ * @extends Behaviour
7
+ */
8
+ export default class AttractionRepulsionBehaviour extends Behaviour {
9
+ enabled: boolean;
10
+ priority: number;
11
+ /**
12
+ * List of influence points affecting particles.
13
+ * Each point: { point: Point, strength: number, range: number }
14
+ */
15
+ influencePoints: never[];
16
+ /**
17
+ * Initializes the particle, but does not modify position directly.
18
+ * @param {Particle} particle - The particle to initialize.
19
+ */
20
+ init: (particle: Particle) => void;
21
+ /**
22
+ * Applies attraction or repulsion forces to the particle additively.
23
+ * @param {Particle} particle - The particle to apply the behavior to.
24
+ * @param {number} deltaTime - Time elapsed since the last frame.
25
+ */
26
+ apply: (particle: Particle, deltaTime: number) => void;
27
+ /**
28
+ * Gets the name of the behavior.
29
+ * @returns {string} - The name of the behavior.
30
+ */
31
+ getName(): string;
32
+ /**
33
+ * Gets the properties of the behavior.
34
+ * @returns {object} - The properties of the behavior.
35
+ */
36
+ getProps(): {
37
+ enabled: boolean;
38
+ priority: number;
39
+ influencePoints: never[];
40
+ name: string;
41
+ };
42
+ }