custom-pixi-particles 8.15.2 → 8.17.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 +10 -8
- package/dist/lib/behaviour/RotationBehaviour.d.ts +4 -0
- package/dist/lib/behaviour/RotationBehaviour.js +6 -3
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
- package/dist/lib/emission/PersistentFillEmission.d.ts +1 -0
- package/dist/lib/emission/PersistentFillEmission.js +13 -4
- package/dist/lib/emission/PersistentFillEmission.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ If you find **custom-pixi-particles** useful and would like to support my work,
|
|
|
57
57
|
---
|
|
58
58
|
|
|
59
59
|
## 🎮 Demo
|
|
60
|
-
Try it out here: [custom-pixi-particles Live Editor](https://okuniewicz.eu/)
|
|
60
|
+
Try it out here: [custom-pixi-particles Live Editor](https://particle-editor.okuniewicz.eu/)
|
|
61
61
|
|
|
62
62
|
---
|
|
63
63
|
|
|
@@ -1015,7 +1015,7 @@ Defines where and how particles spawn. Supports multiple spawn types.
|
|
|
1015
1015
|
- `Path` - Custom path defined by points
|
|
1016
1016
|
- `Oval` - Elliptical distributions
|
|
1017
1017
|
|
|
1018
|
-
**Additional behaviours** (see the [editor](https://okuniewicz.eu/) for full documentation): Aizawa Attractor, Beat Phase Lock, Bezier Flow Tube, Boids Flocking, Bounce, Color Cycle, Constrain To Shape, Conversion Cascade, Curvature Flow, Damage Flash Ripple, Emitter Attractor Link, Flicker, Float Up, Form Pattern, Gravity Well, Homing, Jacobian Curl-Field, Kelvin Wake, Lissajous Harmonic Lattice, Limit Cycle, Magnet, Near Miss Dispersion, Obstacle SDF Steer, Orbit, Phase Coherence, Phase Field Flow, Proximity State, Proximity Triggered Phase, Pulse, Ripple, RVO Avoidance, Screen Space Flow Map, Shear Flow, Toroidal Wrap, Trail, Toroidal Flow, Vortex, Wobble.
|
|
1018
|
+
**Additional behaviours** (see the [editor](https://particle-editor.okuniewicz.eu/) for full documentation): Aizawa Attractor, Beat Phase Lock, Bezier Flow Tube, Boids Flocking, Bounce, Color Cycle, Constrain To Shape, Conversion Cascade, Curvature Flow, Damage Flash Ripple, Emitter Attractor Link, Flicker, Float Up, Form Pattern, Gravity Well, Homing, Jacobian Curl-Field, Kelvin Wake, Lissajous Harmonic Lattice, Limit Cycle, Magnet, Near Miss Dispersion, Obstacle SDF Steer, Orbit, Phase Coherence, Phase Field Flow, Proximity State, Proximity Triggered Phase, Pulse, Ripple, RVO Avoidance, Screen Space Flow Map, Shear Flow, Toroidal Wrap, Trail, Toroidal Flow, Vortex, Wobble.
|
|
1019
1019
|
|
|
1020
1020
|
#### Size Behaviour
|
|
1021
1021
|
Controls particle size over time.
|
|
@@ -1050,18 +1050,22 @@ Controls particle color and alpha over time.
|
|
|
1050
1050
|
```
|
|
1051
1051
|
|
|
1052
1052
|
#### Rotation Behaviour
|
|
1053
|
-
Controls particle rotation.
|
|
1053
|
+
Controls particle rotation at spawn and over time.
|
|
1054
1054
|
|
|
1055
1055
|
```javascript
|
|
1056
1056
|
{
|
|
1057
1057
|
priority: 0,
|
|
1058
1058
|
enabled: true,
|
|
1059
|
-
|
|
1060
|
-
|
|
1059
|
+
startRotation: 0, // Initial sprite angle at spawn (radians)
|
|
1060
|
+
startRotationVariance: Math.PI, // Random spread on spawn (±variance)
|
|
1061
|
+
rotation: 0, // Spin speed (radians per second)
|
|
1062
|
+
variance: 0.2, // Random variance on spin speed
|
|
1061
1063
|
name: 'RotationBehaviour',
|
|
1062
1064
|
}
|
|
1063
1065
|
```
|
|
1064
1066
|
|
|
1067
|
+
For a uniform random angle on spawn with no spin, use `startRotation: Math.PI`, `startRotationVariance: Math.PI`, and `rotation: 0`.
|
|
1068
|
+
|
|
1065
1069
|
#### Angular Velocity Behaviour
|
|
1066
1070
|
Controls particle spin speed and orbital motion.
|
|
1067
1071
|
|
|
@@ -1545,9 +1549,7 @@ Design and fine-tune particle effects visually with the **custom-pixi-particles-
|
|
|
1545
1549
|
- Export/import of emitter configurations as JSON
|
|
1546
1550
|
- Built-in descriptions for every behaviour and property
|
|
1547
1551
|
|
|
1548
|
-
**
|
|
1549
|
-
|
|
1550
|
-
**Try online:** [custom-pixi-particles Live Editor](https://okuniewicz.eu/)
|
|
1552
|
+
**Try online:** [custom-pixi-particles Live Editor](https://particle-editor.okuniewicz.eu/)
|
|
1551
1553
|
|
|
1552
1554
|
---
|
|
1553
1555
|
|
|
@@ -9,6 +9,8 @@ export default class RotationBehaviour extends Behaviour {
|
|
|
9
9
|
priority: number;
|
|
10
10
|
rotation: number;
|
|
11
11
|
variance: number;
|
|
12
|
+
startRotation: number;
|
|
13
|
+
startRotationVariance: number;
|
|
12
14
|
oscillate: boolean;
|
|
13
15
|
oscillationSpeed: number;
|
|
14
16
|
oscillationAmplitude: number;
|
|
@@ -47,6 +49,8 @@ export default class RotationBehaviour extends Behaviour {
|
|
|
47
49
|
priority: number;
|
|
48
50
|
rotation: number;
|
|
49
51
|
variance: number;
|
|
52
|
+
startRotation: number;
|
|
53
|
+
startRotationVariance: number;
|
|
50
54
|
oscillate: boolean;
|
|
51
55
|
oscillationSpeed: number;
|
|
52
56
|
oscillationAmplitude: number;
|
|
@@ -9,8 +9,10 @@ export default class RotationBehaviour extends Behaviour {
|
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.enabled = false;
|
|
11
11
|
this.priority = 0;
|
|
12
|
-
this.rotation = 0; // Base rotation speed
|
|
12
|
+
this.rotation = 0; // Base rotation speed (radians per second)
|
|
13
13
|
this.variance = 0; // Variance in rotation speed
|
|
14
|
+
this.startRotation = 0; // Initial sprite rotation at spawn (radians)
|
|
15
|
+
this.startRotationVariance = 0; // Random variance applied to startRotation at spawn
|
|
14
16
|
this.oscillate = false; // Enable oscillation
|
|
15
17
|
this.oscillationSpeed = 1; // Speed of oscillation
|
|
16
18
|
this.oscillationAmplitude = 0; // Amplitude of oscillation
|
|
@@ -25,10 +27,9 @@ export default class RotationBehaviour extends Behaviour {
|
|
|
25
27
|
this.init = (particle) => {
|
|
26
28
|
if (!this.enabled)
|
|
27
29
|
return;
|
|
28
|
-
|
|
30
|
+
particle.rotation = this.startRotation + this.varianceFrom(this.startRotationVariance);
|
|
29
31
|
const baseRotation = this.rotation + this.varianceFrom(this.variance);
|
|
30
32
|
particle.rotationDelta = this.clockwise ? baseRotation : -baseRotation;
|
|
31
|
-
// Initialize acceleration if enabled
|
|
32
33
|
particle.rotationAcceleration = this.acceleration;
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
@@ -87,6 +88,8 @@ export default class RotationBehaviour extends Behaviour {
|
|
|
87
88
|
priority: this.priority,
|
|
88
89
|
rotation: this.rotation,
|
|
89
90
|
variance: this.variance,
|
|
91
|
+
startRotation: this.startRotation,
|
|
92
|
+
startRotationVariance: this.startRotationVariance,
|
|
90
93
|
oscillate: this.oscillate,
|
|
91
94
|
oscillationSpeed: this.oscillationSpeed,
|
|
92
95
|
oscillationAmplitude: this.oscillationAmplitude,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RotationBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/RotationBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,SAAS;IAAxD;;QACE,YAAO,GAAG,KAAK,CAAA;QACf,aAAQ,GAAG,CAAC,CAAA;QACZ,aAAQ,GAAG,CAAC,CAAA,CAAC,
|
|
1
|
+
{"version":3,"file":"RotationBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/RotationBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,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AAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;YACjD,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;YAC/C,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -6,6 +6,7 @@ import AbstractEmission from './AbstractEmission';
|
|
|
6
6
|
export default class PersistentFillEmission extends AbstractEmission {
|
|
7
7
|
_maxParticles: number;
|
|
8
8
|
_burstPerFrame: number;
|
|
9
|
+
_carry: number;
|
|
9
10
|
/**
|
|
10
11
|
* @param deltaTime - unused; API matches other emission controllers
|
|
11
12
|
* @param particlesCount - current live particle count
|
|
@@ -9,6 +9,7 @@ export default class PersistentFillEmission extends AbstractEmission {
|
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this._maxParticles = 0;
|
|
11
11
|
this._burstPerFrame = 500;
|
|
12
|
+
this._carry = 0;
|
|
12
13
|
this.getName = () => {
|
|
13
14
|
return EmissionTypes.PERSISTENT_FILL;
|
|
14
15
|
};
|
|
@@ -21,15 +22,23 @@ export default class PersistentFillEmission extends AbstractEmission {
|
|
|
21
22
|
if (particlesCount >= this._maxParticles) {
|
|
22
23
|
return 0;
|
|
23
24
|
}
|
|
25
|
+
this._carry += this._burstPerFrame;
|
|
26
|
+
const wholeParticles = Math.floor(this._carry + 1e-9);
|
|
27
|
+
if (wholeParticles <= 0) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
24
30
|
const capacity = this._maxParticles - particlesCount;
|
|
25
|
-
|
|
31
|
+
const toEmit = Math.min(capacity, wholeParticles);
|
|
32
|
+
this._carry -= toEmit;
|
|
33
|
+
return toEmit;
|
|
26
34
|
}
|
|
27
35
|
reset() {
|
|
28
|
-
|
|
36
|
+
this._carry = 0;
|
|
29
37
|
}
|
|
30
38
|
validate() {
|
|
31
39
|
this._maxParticles = Math.max(0, this._maxParticles);
|
|
32
|
-
this._burstPerFrame = Math.max(
|
|
40
|
+
this._burstPerFrame = Math.max(0, this._burstPerFrame);
|
|
41
|
+
this._carry = 0;
|
|
33
42
|
}
|
|
34
43
|
set maxParticles(value) {
|
|
35
44
|
this._maxParticles = Math.max(value, 0);
|
|
@@ -38,7 +47,7 @@ export default class PersistentFillEmission extends AbstractEmission {
|
|
|
38
47
|
return this._maxParticles;
|
|
39
48
|
}
|
|
40
49
|
set burstPerFrame(value) {
|
|
41
|
-
this._burstPerFrame = Math.max(
|
|
50
|
+
this._burstPerFrame = Math.max(value, 0);
|
|
42
51
|
}
|
|
43
52
|
get burstPerFrame() {
|
|
44
53
|
return this._burstPerFrame;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PersistentFillEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/PersistentFillEmission.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAE3C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,gBAAgB;IAApE;;QACE,kBAAa,GAAG,CAAC,CAAA;QACjB,mBAAc,GAAG,GAAG,CAAA;
|
|
1
|
+
{"version":3,"file":"PersistentFillEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/PersistentFillEmission.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,aAAa,MAAM,i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