custom-pixi-particles 5.1.1 → 7.0.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 +118 -82
- package/dist/index.d.ts +5 -1
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/Particle.d.ts +35 -1
- package/dist/lib/Particle.js +66 -1
- package/dist/lib/Particle.js.map +1 -1
- package/dist/lib/ParticlePool.js +2 -1
- package/dist/lib/ParticlePool.js.map +1 -1
- package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +10 -6
- package/dist/lib/behaviour/AngularVelocityBehaviour.js +45 -14
- package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -1
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.d.ts +42 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js +78 -0
- package/dist/lib/behaviour/AttractionRepulsionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/BehaviourNames.d.ts +13 -2
- package/dist/lib/behaviour/BehaviourNames.js +13 -1
- package/dist/lib/behaviour/BehaviourNames.js.map +1 -1
- package/dist/lib/behaviour/CollisionBehaviour.d.ts +86 -0
- package/dist/lib/behaviour/CollisionBehaviour.js +140 -0
- package/dist/lib/behaviour/CollisionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/ColorBehaviour.d.ts +22 -0
- package/dist/lib/behaviour/ColorBehaviour.js +134 -18
- package/dist/lib/behaviour/ColorBehaviour.js.map +1 -1
- package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +14 -8
- package/dist/lib/behaviour/EmitDirectionBehaviour.js +53 -12
- package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +6 -0
- package/dist/lib/behaviour/EmitterBehaviours.js +11 -0
- package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
- package/dist/lib/behaviour/ForceFieldsBehaviour.d.ts +53 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.js +80 -0
- package/dist/lib/behaviour/ForceFieldsBehaviour.js.map +1 -0
- package/dist/lib/behaviour/GroupingBehaviour.d.ts +57 -0
- package/dist/lib/behaviour/GroupingBehaviour.js +143 -0
- package/dist/lib/behaviour/GroupingBehaviour.js.map +1 -0
- package/dist/lib/behaviour/LifeBehaviour.d.ts +0 -20
- package/dist/lib/behaviour/LifeBehaviour.js +0 -20
- package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/LightEffectBehaviour.d.ts +59 -0
- package/dist/lib/behaviour/LightEffectBehaviour.js +94 -0
- package/dist/lib/behaviour/LightEffectBehaviour.js.map +1 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.d.ts +35 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js +93 -0
- package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/PositionBehaviour.d.ts +62 -9
- package/dist/lib/behaviour/PositionBehaviour.js +352 -88
- package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/RotationBehaviour.d.ts +20 -12
- package/dist/lib/behaviour/RotationBehaviour.js +50 -16
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SizeBehaviour.d.ts +33 -3
- package/dist/lib/behaviour/SizeBehaviour.js +107 -22
- package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SoundReactiveBehaviour.d.ts +58 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.js +132 -0
- package/dist/lib/behaviour/SoundReactiveBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SpawnBehaviour.d.ts +89 -0
- package/dist/lib/behaviour/SpawnBehaviour.js +705 -0
- package/dist/lib/behaviour/SpawnBehaviour.js.map +1 -0
- package/dist/lib/behaviour/StretchBehaviour.d.ts +30 -0
- package/dist/lib/behaviour/StretchBehaviour.js +59 -0
- package/dist/lib/behaviour/StretchBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TemperatureBehaviour.d.ts +47 -0
- package/dist/lib/behaviour/TemperatureBehaviour.js +64 -0
- package/dist/lib/behaviour/TemperatureBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TimelineBehaviour.d.ts +73 -0
- package/dist/lib/behaviour/TimelineBehaviour.js +100 -0
- package/dist/lib/behaviour/TimelineBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +2 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.js +18 -13
- package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
- package/dist/lib/behaviour/index.d.ts +12 -1
- package/dist/lib/behaviour/index.js +12 -1
- package/dist/lib/behaviour/index.js.map +1 -1
- package/dist/lib/customPixiParticlesSettingsInterface.d.ts +1 -0
- package/dist/lib/emission/RandomEmission.js.map +1 -1
- package/dist/lib/emission/StandardEmission.js.map +1 -1
- package/dist/lib/emission/UniformEmission.js.map +1 -1
- package/dist/lib/emitter/Emitter.d.ts +4 -1
- package/dist/lib/emitter/Emitter.js +42 -2
- package/dist/lib/emitter/Emitter.js.map +1 -1
- package/dist/lib/parser/BehaviourParser.js +38 -2
- package/dist/lib/parser/BehaviourParser.js.map +1 -1
- package/dist/lib/parser/CompatibilityHelper.js +2 -1
- package/dist/lib/parser/CompatibilityHelper.js.map +1 -1
- package/dist/lib/parser/EmitControllerParser.js.map +1 -1
- package/dist/lib/parser/EmitterParser.js.map +1 -1
- package/dist/lib/pixi/Renderer.d.ts +14 -5
- package/dist/lib/pixi/Renderer.js +128 -70
- package/dist/lib/pixi/Renderer.js.map +1 -1
- package/dist/lib/pixi/TestRenderer.d.ts +125 -0
- package/dist/lib/pixi/TestRenderer.js +560 -0
- package/dist/lib/pixi/TestRenderer.js.map +1 -0
- package/dist/lib/util/List.js.map +1 -1
- package/dist/lib/util/MinMax.d.ts +34 -0
- package/dist/lib/util/MinMax.js +46 -0
- package/dist/lib/util/MinMax.js.map +1 -0
- package/dist/lib/util/Point.js +2 -2
- package/dist/lib/util/Point.js.map +1 -1
- package/dist/lib/util/Random.js +2 -1
- package/dist/lib/util/Random.js.map +1 -1
- package/dist/lib/util/ThereBack.d.ts +14 -0
- package/dist/lib/util/ThereBack.js +23 -0
- package/dist/lib/util/ThereBack.js.map +1 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -1,126 +1,162 @@
|
|
|
1
1
|
# CustomPIXIParticles by [@lukasz-okuniewicz](http://github.com/lukasz-okuniewicz)
|
|
2
2
|
|
|
3
|
-
CustomPIXIParticles is a lightweight
|
|
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
|
-
|
|
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
|
-
###
|
|
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
|
-
|
|
14
|
-
|---|---|
|
|
15
|
-
| v5.x - v6.x | v4.x |
|
|
16
|
-
| v7.x | v5.x |
|
|
10
|
+
[](https://buymeacoffee.com/lukasz.okuniewicz)
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
[custom-pixi-particles](http://particles.okuniewicz.eu/)
|
|
12
|
+
---
|
|
20
13
|
|
|
21
|
-
|
|
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 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
|
-
|
|
28
|
-
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 🚀 Quick Start
|
|
39
|
+
Import or Require
|
|
29
40
|
```javascript
|
|
30
|
-
|
|
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
|
|
50
|
+
// Define textures and emitter configuration
|
|
37
51
|
const textures = ['texture1.png', 'texture2.png']
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
container
|
|
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
|
-
|
|
49
|
-
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 📖 API Reference
|
|
69
|
+
Initializes a particle emitter.
|
|
50
70
|
```javascript
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
animatedSpriteZeroPad: Number,
|
|
55
|
-
animatedSpriteIndexToStart: Number,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
71
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
98
|
-
|
|
130
|
+
### Position Updates
|
|
131
|
+
Dynamically adjust the emitter's position.
|
|
132
|
+
```javascript
|
|
133
|
+
particles.updatePosition({ x: 100, y: 200 })
|
|
134
|
+
```
|
|
99
135
|
|
|
100
|
-
|
|
101
|
-
|
|
136
|
+
### Pool Management
|
|
137
|
+
Clears internal object pools to free memory.
|
|
138
|
+
```javascript
|
|
139
|
+
particles.clearPool()
|
|
140
|
+
```
|
|
102
141
|
|
|
103
|
-
|
|
104
|
-
destroy()
|
|
142
|
+
---
|
|
105
143
|
|
|
106
|
-
|
|
107
|
-
|
|
144
|
+
## 🖥️ Versions Compatibility
|
|
145
|
+
| PixiJS | CustomPIXIParticles |
|
|
146
|
+
|---|---|
|
|
147
|
+
| v5.x - v6.x | v4.x |
|
|
108
148
|
|
|
109
|
-
|
|
110
|
-
resetEmitter()
|
|
149
|
+
---
|
|
111
150
|
|
|
112
|
-
|
|
113
|
-
|
|
151
|
+
## 🛠️ Advanced Editor
|
|
152
|
+
Easily design and fine-tune your particle effects with the CustomPIXIParticles Editor.
|
|
153
|
+
🔗 [CustomPIXIParticles Live Editor](https://okuniewicz.eu/)
|
|
114
154
|
|
|
115
|
-
|
|
116
|
-
updateConfig(config, resetDuration = true)
|
|
155
|
+
---
|
|
117
156
|
|
|
118
|
-
|
|
119
|
-
|
|
157
|
+
## 🤝 Contributing
|
|
158
|
+
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
159
|
|
|
121
|
-
|
|
122
|
-
clearPool()
|
|
123
|
-
```
|
|
160
|
+
---
|
|
124
161
|
|
|
125
|
-
|
|
126
|
-
Editor for particles: [custom-pixi-particles-editor](https://github.com/lukasz-okuniewicz/custom-pixi-particles-editor)
|
|
162
|
+
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
|
-
|
|
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
|
-
|
|
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;
|
|
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"}
|
package/dist/lib/Particle.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Sprite } from 'pixi.js
|
|
1
|
+
import { Sprite } from 'pixi.js';
|
|
2
2
|
import { Color, Point } from './util';
|
|
3
|
+
import ThereBack from './util/ThereBack';
|
|
3
4
|
/**
|
|
4
5
|
* Represents a particle object used in particle system simulations
|
|
5
6
|
*/
|
|
@@ -61,6 +62,7 @@ export default class Particle {
|
|
|
61
62
|
* Stores the ending color of the particle
|
|
62
63
|
*/
|
|
63
64
|
colorEnd: Color;
|
|
65
|
+
superColorAlphaEnd: number;
|
|
64
66
|
/**
|
|
65
67
|
* Stores the maximum life time of the particle
|
|
66
68
|
*/
|
|
@@ -97,6 +99,8 @@ export default class Particle {
|
|
|
97
99
|
* Stores the radius of the particle
|
|
98
100
|
*/
|
|
99
101
|
radius: number;
|
|
102
|
+
radiusX: number;
|
|
103
|
+
radiusY: number;
|
|
100
104
|
/**
|
|
101
105
|
* Stores the starting radius of the particle
|
|
102
106
|
*/
|
|
@@ -165,6 +169,13 @@ export default class Particle {
|
|
|
165
169
|
* Stores the warp stretch of the particle
|
|
166
170
|
*/
|
|
167
171
|
warpStretch: number;
|
|
172
|
+
skipPositionBehaviour: boolean;
|
|
173
|
+
skipAngularVelocityBehaviour: boolean;
|
|
174
|
+
skipColorBehaviour: boolean;
|
|
175
|
+
skipEmitDirectionBehaviour: boolean;
|
|
176
|
+
skipRotationBehaviour: boolean;
|
|
177
|
+
skipSizeBehaviour: boolean;
|
|
178
|
+
skipAttractionRepulsionBehaviour: boolean;
|
|
168
179
|
/**
|
|
169
180
|
* Stores the warp distance scale converter of the particle
|
|
170
181
|
*/
|
|
@@ -173,6 +184,29 @@ export default class Particle {
|
|
|
173
184
|
x: number;
|
|
174
185
|
y: number;
|
|
175
186
|
};
|
|
187
|
+
fromAtoB: boolean;
|
|
188
|
+
fromAtoBTwoWays: boolean;
|
|
189
|
+
pointA: Point;
|
|
190
|
+
pointB: Point;
|
|
191
|
+
there: ThereBack;
|
|
192
|
+
back: ThereBack;
|
|
193
|
+
xStart: number;
|
|
194
|
+
yStart: number;
|
|
195
|
+
xTarget: number;
|
|
196
|
+
yTarget: number;
|
|
197
|
+
thereDuration: number;
|
|
198
|
+
backDuration: number;
|
|
199
|
+
progress: number;
|
|
200
|
+
time: number;
|
|
201
|
+
thereAmplitude: number;
|
|
202
|
+
backAmplitude: number;
|
|
203
|
+
direction: number;
|
|
204
|
+
noiseOffset: Point;
|
|
205
|
+
timeline: any[];
|
|
206
|
+
initialDirectionCos: number;
|
|
207
|
+
initialDirectionSin: number;
|
|
208
|
+
velocityScale: number;
|
|
209
|
+
rotationAcceleration: number;
|
|
176
210
|
/**
|
|
177
211
|
* Constructs a particle object
|
|
178
212
|
*/
|
package/dist/lib/Particle.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Color, Point } from './util';
|
|
2
|
+
import ThereBack from './util/ThereBack';
|
|
2
3
|
/**
|
|
3
4
|
* Represents a particle object used in particle system simulations
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
class Particle {
|
|
6
7
|
/**
|
|
7
8
|
* Constructs a particle object
|
|
8
9
|
*/
|
|
@@ -61,6 +62,37 @@ export default class Particle {
|
|
|
61
62
|
* Stores the ending color of the particle
|
|
62
63
|
*/
|
|
63
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;
|
|
73
|
+
this.fromAtoB = false;
|
|
74
|
+
this.fromAtoBTwoWays = false;
|
|
75
|
+
this.pointA = new Point();
|
|
76
|
+
this.pointB = new Point();
|
|
77
|
+
this.there = new ThereBack();
|
|
78
|
+
this.back = new ThereBack();
|
|
79
|
+
this.xStart = 0;
|
|
80
|
+
this.yStart = 0;
|
|
81
|
+
this.xTarget = 0;
|
|
82
|
+
this.yTarget = 0;
|
|
83
|
+
this.thereDuration = 1;
|
|
84
|
+
this.backDuration = 1;
|
|
85
|
+
this.progress = 0;
|
|
86
|
+
this.time = 0;
|
|
87
|
+
this.thereAmplitude = 10;
|
|
88
|
+
this.backAmplitude = 10;
|
|
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;
|
|
64
96
|
this.reset();
|
|
65
97
|
}
|
|
66
98
|
/**
|
|
@@ -73,6 +105,14 @@ export default class Particle {
|
|
|
73
105
|
this.x = 0;
|
|
74
106
|
this.y = 0;
|
|
75
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;
|
|
76
116
|
this.movement.set(0, 0);
|
|
77
117
|
this.acceleration.set(0, 0);
|
|
78
118
|
this.velocity.set(0, 0);
|
|
@@ -97,6 +137,7 @@ export default class Particle {
|
|
|
97
137
|
this.color.set(255, 255, 255, 1);
|
|
98
138
|
this.colorStart.set(0, 0, 0, 1);
|
|
99
139
|
this.colorEnd.set(0, 0, 0, 1);
|
|
140
|
+
this.superColorAlphaEnd = 1;
|
|
100
141
|
this.cameraZ = 0;
|
|
101
142
|
this.cameraZConverter = 10;
|
|
102
143
|
this.warpSpeed = 0;
|
|
@@ -104,6 +145,29 @@ export default class Particle {
|
|
|
104
145
|
this.warpFov = 20;
|
|
105
146
|
this.warpStretch = 5;
|
|
106
147
|
this.warpDistanceScaleConverter = 2000;
|
|
148
|
+
this.sizeDifference = { x: 1, y: 1 };
|
|
149
|
+
this.fromAtoB = false;
|
|
150
|
+
this.fromAtoBTwoWays = false;
|
|
151
|
+
this.pointA.set(0, 0);
|
|
152
|
+
this.pointB.set(0, 0);
|
|
153
|
+
this.there.set('', '', '');
|
|
154
|
+
this.back.set('', '', '');
|
|
155
|
+
this.thereDuration = 1;
|
|
156
|
+
this.backDuration = 1;
|
|
157
|
+
this.thereAmplitude = 10;
|
|
158
|
+
this.backAmplitude = 10;
|
|
159
|
+
this.progress = 0;
|
|
160
|
+
this.direction = 1;
|
|
161
|
+
this.time = 0;
|
|
162
|
+
this.xStart = 0;
|
|
163
|
+
this.yStart = 0;
|
|
164
|
+
this.xTarget = 0;
|
|
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;
|
|
107
171
|
}
|
|
108
172
|
/**
|
|
109
173
|
* Checks if the particle is almost dead
|
|
@@ -133,4 +197,5 @@ export default class Particle {
|
|
|
133
197
|
}
|
|
134
198
|
}
|
|
135
199
|
Particle._UID = { value: 0 };
|
|
200
|
+
export default Particle;
|
|
136
201
|
//# sourceMappingURL=Particle.js.map
|
package/dist/lib/Particle.js.map
CHANGED
|
@@ -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;
|
|
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;IAmP3B;;OAEG;IACH;QApPA,SAAI,GAAoB,IAAI,CAAA;QAC5B,SAAI,GAAoB,IAAI,CAAA;QAE5B;;WAEG;QACH,QAAG,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;QAE3B;;WAEG;QACH,aAAQ,GAAG,IAAI,KAAK,EAAE,CAAA;QAEtB;;WAEG;QACH,iBAAY,GAAG,IAAI,KAAK,EAAE,CAAA;QAE1B;;WAEG;QACH,aAAQ,GAAG,IAAI,KAAK,EAAE,CAAA;QAEtB;;WAEG;QACH,SAAI,GAAG,IAAI,KAAK,EAAE,CAAA;QAElB;;WAEG;QACH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AAW,GAAG,IAAI,KAAK,EAAE,CAAA;QAC9B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,CAAC,CAAA;QACtB,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAA;IAC/B,CAAC;IAED;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,CAAA;IAChD,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAM;QACxB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO;YAAE,OAAM;QAChC,IAAI,CAAC,MAAM,CAAC,OAAO,GAAG,KAAK,CAAA;IAC7B,CAAC;;AA3WM,aAAI,GAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,AAAlC,CAAkC;eAD1B,QAAQ"}
|
package/dist/lib/ParticlePool.js
CHANGED
|
@@ -3,7 +3,7 @@ import Particle from './Particle';
|
|
|
3
3
|
* @class ParticlePool
|
|
4
4
|
* A class for managing a pool of particles.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
class ParticlePool {
|
|
7
7
|
constructor() {
|
|
8
8
|
/**
|
|
9
9
|
* The first element in the pool.
|
|
@@ -52,4 +52,5 @@ export default class ParticlePool {
|
|
|
52
52
|
* A static global instance of ParticlePool.
|
|
53
53
|
*/
|
|
54
54
|
ParticlePool.global = new ParticlePool();
|
|
55
|
+
export default ParticlePool;
|
|
55
56
|
//# sourceMappingURL=ParticlePool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ParticlePool.js","sourceRoot":"","sources":["../../src/lib/ParticlePool.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"ParticlePool.js","sourceRoot":"","sources":["../../src/lib/ParticlePool.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAA;AAEjC;;;GAGG;AACH,MAAqB,YAAY;IAAjC;QAME;;WAEG;QACH,UAAK,GAAoB,IAAI,CAAA;IA0C/B,CAAC;IAxCC;;;;OAIG;IACH,GAAG;QACD,IAAI,CAAC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC,MAAM,EAAE,CAAA;QAErC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAA;QACzB,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;QACnB,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,MAAM;QACJ,OAAO,IAAI,QAAQ,EAAE,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,QAAkB;QACrB,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAA;IACvB,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,YAAY,CAAC,MAAM,GAAG,IAAI,YAAY,EAAE,CAAA;IAC1C,CAAC;;AAjDD;;GAEG;AACI,mBAAM,GAAG,IAAI,YAAY,EAAE,AAArB,CAAqB;eAJf,YAAY"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import Behaviour from './Behaviour';
|
|
2
2
|
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 =
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
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
|
};
|