@tsparticles/plugin-infection 4.0.0-alpha.5 → 4.0.0-beta.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/392.min.js +1 -0
- package/800.min.js +1 -0
- package/91.min.js +1 -0
- package/README.md +5 -0
- package/browser/Infecter.js +22 -21
- package/browser/InfectionPlugin.js +1 -3
- package/browser/InfectionPluginInstance.js +2 -2
- package/browser/Options/Classes/Infection.js +5 -0
- package/browser/Options/Classes/InfectionStage.js +5 -0
- package/browser/ParticlesInfecter.js +7 -1
- package/browser/index.js +6 -3
- package/cjs/Infecter.js +22 -21
- package/cjs/InfectionPlugin.js +1 -3
- package/cjs/InfectionPluginInstance.js +2 -2
- package/cjs/Options/Classes/Infection.js +5 -0
- package/cjs/Options/Classes/InfectionStage.js +5 -0
- package/cjs/ParticlesInfecter.js +7 -1
- package/cjs/index.js +6 -3
- package/dist_browser_InfectionPluginInstance_js.js +3 -3
- package/dist_browser_InfectionPlugin_js.js +4 -4
- package/dist_browser_ParticlesInfecter_js.js +2 -2
- package/esm/Infecter.js +22 -21
- package/esm/InfectionPlugin.js +1 -3
- package/esm/InfectionPluginInstance.js +2 -2
- package/esm/Options/Classes/Infection.js +5 -0
- package/esm/Options/Classes/InfectionStage.js +5 -0
- package/esm/ParticlesInfecter.js +7 -1
- package/esm/index.js +6 -3
- package/package.json +3 -3
- package/report.html +3 -3
- package/tsparticles.plugin.infection.js +31 -19
- package/tsparticles.plugin.infection.min.js +2 -2
- package/types/InfectionPlugin.d.ts +1 -2
- package/types/ParticlesInfecter.d.ts +2 -0
- package/umd/Infecter.js +22 -21
- package/umd/InfectionPlugin.js +1 -3
- package/umd/InfectionPluginInstance.js +2 -2
- package/umd/Options/Classes/Infection.js +5 -0
- package/umd/Options/Classes/InfectionStage.js +5 -0
- package/umd/ParticlesInfecter.js +7 -1
- package/umd/index.js +6 -3
- package/249.min.js +0 -2
- package/249.min.js.LICENSE.txt +0 -1
- package/713.min.js +0 -2
- package/713.min.js.LICENSE.txt +0 -1
- package/835.min.js +0 -2
- package/835.min.js.LICENSE.txt +0 -1
- package/tsparticles.plugin.infection.min.js.LICENSE.txt +0 -1
package/392.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[392],{392(i,e,t){t.r(e),t.d(e,{InfectionPlugin:()=>a});var s=t(303);class n{color;duration;infectedStage;radius;rate;constructor(){this.color=new s.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(i){(0,s.isNull)(i)||(void 0!==i.color&&(this.color=s.OptionsColor.create(this.color,i.color)),this.duration=i.duration,this.infectedStage=i.infectedStage,void 0!==i.radius&&(this.radius=i.radius),void 0!==i.rate&&(this.rate=i.rate))}}class o{cure;delay;enable;infections;stages;constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(i){(0,s.isNull)(i)||(void 0!==i.cure&&(this.cure=i.cure),void 0!==i.delay&&(this.delay=i.delay),void 0!==i.enable&&(this.enable=i.enable),void 0!==i.infections&&(this.infections=i.infections),void 0!==i.stages&&(this.stages=i.stages.map(i=>{let e=new n;return e.load(i),e})))}}class a{id="infection";async getPlugin(i){let{InfectionPluginInstance:e}=await t.e(800).then(t.bind(t,800));return new e(i)}loadOptions(i,e,t){if(!this.needsPlugin(e)&&!this.needsPlugin(t))return;let s=e.infection;s?.load===void 0&&(e.infection=s=new o),s.load(t?.infection)}needsPlugin(i){return i?.infection?.enable??!1}}}}]);
|
package/800.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[800],{800(e,t,i){i.d(t,{InfectionPluginInstance:()=>o});var n=i(303);class a{_container;constructor(e){this._container=e}startInfection(e,t){let i=this._container.actualOptions.infection,{infection:n}=e;!i||!n||t>i.stages.length||t<0||(n.delay=0,n.delayStage=t)}updateInfection(e,t){let i=this._container.actualOptions.infection,{infection:a}=e;if(!i||!a)return;let o=i.stages,s=o.length;if(void 0!==a.delay&&void 0!==a.delayStage){let e=a.delayStage;if(e>s||e<0)return;a.delay>=i.delay*n.millisecondsToSeconds?(a.stage=e,a.time=0,delete a.delay,delete a.delayStage):a.delay+=t}else delete a.delay,delete a.delayStage;if(void 0!==a.stage&&void 0!==a.time){let i=o[a.stage];i?.duration!==void 0&&i.duration>=0&&a.time>i.duration*n.millisecondsToSeconds?this._nextInfectionStage(e):a.time+=t}else delete a.stage,delete a.time}updateInfectionStage(e,t){let i=this._container.actualOptions,{infection:n}=e;!i.infection||!n||t>i.infection.stages.length||t<0||void 0!==n.stage&&n.stage>t||(n.stage=t,n.time=0)}_nextInfectionStage=e=>{let t=this._container.actualOptions.infection,{infection:i}=e;if(!t||!i)return;let n=t.stages.length;!(n<=0)&&void 0!==i.stage&&(i.time=0,n<=++i.stage&&(t.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))}}class o{_container;constructor(e){this._container=e,this._container.infecter=new a(this._container)}particleFillColor(e){let t=this._container.actualOptions;if(!e.infection||!t.infection)return;let i=e.infection.stage,n=t.infection.stages;return void 0===i?void 0:n[i]?.color}particleStrokeColor(e){return this.particleFillColor(e)}particlesSetup(){let e=this._container.actualOptions;if(e.infection)for(let t=0;t<e.infection.infections;t++){let e=this._container.particles.filter(e=>(e.infection??={},void 0===e.infection.stage)),t=(0,n.itemFromArray)(e);t&&this._container.infecter?.startInfection(t,0)}}}}}]);
|
package/91.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[91],{91(e,t,i){i.d(t,{ParticlesInfecter:()=>s});var n=i(303),a=i(702);class s extends a.ParticlesInteractorBase{_maxDistance;constructor(e){super(e),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(){}init(){}interact(e,t,i){let a=this.container.infecter;if(!a||(a.updateInfection(e,i.value),e.infection?.stage===void 0))return;let s=this.container,c=s.actualOptions.infection;if(!c?.enable||c.stages.length<1)return;let o=c.stages[e.infection.stage];if(!o)return;this._maxDistance=Math.max(this._maxDistance,o.radius);let r=s.retina.pixelRatio,f=e.getRadius()*n.double+o.radius*r,g=e.getPosition(),l=o.infectedStage??e.infection.stage,u=s.particles.grid.queryCircle(g,f),d=o.rate,p=u.length;for(let t of u)if(!(t===e||t.destroyed||t.spawning||t.infection?.stage!==void 0&&t.infection.stage===e.infection.stage||(0,n.getRandom)()>=d/p)){if(t.infection?.stage===void 0)a.startInfection(t,l);else if(t.infection.stage<e.infection.stage)a.updateInfectionStage(t,l);else if(t.infection.stage>e.infection.stage){let i=c.stages[t.infection.stage];if(!i)continue;let n=i.infectedStage??t.infection.stage;a.updateInfectionStage(e,n)}}}isEnabled(){return this.container.actualOptions.infection?.enable??!1}reset(){}}}}]);
|
package/README.md
CHANGED
|
@@ -26,6 +26,7 @@ Once the scripts are loaded you can set up `tsParticles` and the plugin like thi
|
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
28
|
(async () => {
|
|
29
|
+
await loadInteractivityPlugin(tsParticles);
|
|
29
30
|
await loadInfectionPlugin(tsParticles);
|
|
30
31
|
|
|
31
32
|
await tsParticles.load({
|
|
@@ -55,9 +56,11 @@ Then you need to import it in the app, like this:
|
|
|
55
56
|
|
|
56
57
|
```javascript
|
|
57
58
|
const { tsParticles } = require("@tsparticles/engine");
|
|
59
|
+
const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity-events");
|
|
58
60
|
const { loadInfectionPlugin } = require("@tsparticles/plugin-infection");
|
|
59
61
|
|
|
60
62
|
(async () => {
|
|
63
|
+
await loadInteractivityPlugin(tsParticles);
|
|
61
64
|
await loadInfectionPlugin(tsParticles);
|
|
62
65
|
})();
|
|
63
66
|
```
|
|
@@ -66,9 +69,11 @@ or
|
|
|
66
69
|
|
|
67
70
|
```javascript
|
|
68
71
|
import { tsParticles } from "@tsparticles/engine";
|
|
72
|
+
import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity-events";
|
|
69
73
|
import { loadInfectionPlugin } from "@tsparticles/plugin-infection";
|
|
70
74
|
|
|
71
75
|
(async () => {
|
|
76
|
+
await loadInteractivityPlugin(tsParticles);
|
|
72
77
|
await loadInfectionPlugin(tsParticles);
|
|
73
78
|
})();
|
|
74
79
|
```
|
package/browser/Infecter.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import { millisecondsToSeconds } from "@tsparticles/engine";
|
|
2
2
|
const minStage = 0, minDuration = 0;
|
|
3
3
|
export class Infecter {
|
|
4
|
+
_container;
|
|
4
5
|
constructor(container) {
|
|
5
|
-
this._nextInfectionStage = particle => {
|
|
6
|
-
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
7
|
-
if (!infectionOptions || !infection) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const stagesCount = infectionOptions.stages.length;
|
|
11
|
-
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
infection.time = 0;
|
|
15
|
-
if (stagesCount <= ++infection.stage) {
|
|
16
|
-
if (infectionOptions.cure) {
|
|
17
|
-
delete infection.stage;
|
|
18
|
-
delete infection.time;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
infection.stage = 0;
|
|
22
|
-
infection.time = 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
6
|
this._container = container;
|
|
27
7
|
}
|
|
28
8
|
startInfection(particle, stage) {
|
|
@@ -93,4 +73,25 @@ export class Infecter {
|
|
|
93
73
|
infection.stage = stage;
|
|
94
74
|
infection.time = 0;
|
|
95
75
|
}
|
|
76
|
+
_nextInfectionStage = particle => {
|
|
77
|
+
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
78
|
+
if (!infectionOptions || !infection) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const stagesCount = infectionOptions.stages.length;
|
|
82
|
+
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
infection.time = 0;
|
|
86
|
+
if (stagesCount <= ++infection.stage) {
|
|
87
|
+
if (infectionOptions.cure) {
|
|
88
|
+
delete infection.stage;
|
|
89
|
+
delete infection.time;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
infection.stage = 0;
|
|
93
|
+
infection.time = 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
96
97
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Infection } from "./Options/Classes/Infection.js";
|
|
2
2
|
export class InfectionPlugin {
|
|
3
|
-
|
|
4
|
-
this.id = "infection";
|
|
5
|
-
}
|
|
3
|
+
id = "infection";
|
|
6
4
|
async getPlugin(container) {
|
|
7
5
|
const { InfectionPluginInstance } = await import("./InfectionPluginInstance.js");
|
|
8
6
|
return new InfectionPluginInstance(container);
|
|
@@ -2,6 +2,7 @@ import { itemFromArray } from "@tsparticles/engine";
|
|
|
2
2
|
import { Infecter } from "./Infecter.js";
|
|
3
3
|
const minStage = 0;
|
|
4
4
|
export class InfectionPluginInstance {
|
|
5
|
+
_container;
|
|
5
6
|
constructor(container) {
|
|
6
7
|
this._container = container;
|
|
7
8
|
this._container.infecter = new Infecter(this._container);
|
|
@@ -27,8 +28,7 @@ export class InfectionPluginInstance {
|
|
|
27
28
|
const infP = p;
|
|
28
29
|
infP.infection ??= {};
|
|
29
30
|
return infP.infection.stage === undefined;
|
|
30
|
-
});
|
|
31
|
-
const infected = itemFromArray(notInfected);
|
|
31
|
+
}), infected = itemFromArray(notInfected);
|
|
32
32
|
if (!infected) {
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
@@ -2,8 +2,13 @@ import { double, getRandom } from "@tsparticles/engine";
|
|
|
2
2
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
const minStagesCount = 1;
|
|
4
4
|
export class ParticlesInfecter extends ParticlesInteractorBase {
|
|
5
|
+
_maxDistance;
|
|
5
6
|
constructor(container) {
|
|
6
7
|
super(container);
|
|
8
|
+
this._maxDistance = 0;
|
|
9
|
+
}
|
|
10
|
+
get maxDistance() {
|
|
11
|
+
return this._maxDistance;
|
|
7
12
|
}
|
|
8
13
|
clear() {
|
|
9
14
|
}
|
|
@@ -26,7 +31,8 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
|
|
|
26
31
|
if (!infectionStage1) {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
|
-
|
|
34
|
+
this._maxDistance = Math.max(this._maxDistance, infectionStage1.radius);
|
|
35
|
+
const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.grid.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
|
|
30
36
|
for (const p2 of query) {
|
|
31
37
|
const infP2 = p2;
|
|
32
38
|
if (infP2 === p1 ||
|
package/browser/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export async function loadInfectionPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
|
|
5
|
+
import("@tsparticles/plugin-interactivity"),
|
|
6
|
+
import("./InfectionPlugin.js"),
|
|
7
|
+
]);
|
|
8
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
9
|
e.addPlugin(new InfectionPlugin());
|
|
7
10
|
e.addInteractor?.("particlesInfection", async (container) => {
|
|
8
11
|
const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
|
package/cjs/Infecter.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import { millisecondsToSeconds } from "@tsparticles/engine";
|
|
2
2
|
const minStage = 0, minDuration = 0;
|
|
3
3
|
export class Infecter {
|
|
4
|
+
_container;
|
|
4
5
|
constructor(container) {
|
|
5
|
-
this._nextInfectionStage = particle => {
|
|
6
|
-
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
7
|
-
if (!infectionOptions || !infection) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const stagesCount = infectionOptions.stages.length;
|
|
11
|
-
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
infection.time = 0;
|
|
15
|
-
if (stagesCount <= ++infection.stage) {
|
|
16
|
-
if (infectionOptions.cure) {
|
|
17
|
-
delete infection.stage;
|
|
18
|
-
delete infection.time;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
infection.stage = 0;
|
|
22
|
-
infection.time = 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
6
|
this._container = container;
|
|
27
7
|
}
|
|
28
8
|
startInfection(particle, stage) {
|
|
@@ -93,4 +73,25 @@ export class Infecter {
|
|
|
93
73
|
infection.stage = stage;
|
|
94
74
|
infection.time = 0;
|
|
95
75
|
}
|
|
76
|
+
_nextInfectionStage = particle => {
|
|
77
|
+
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
78
|
+
if (!infectionOptions || !infection) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const stagesCount = infectionOptions.stages.length;
|
|
82
|
+
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
infection.time = 0;
|
|
86
|
+
if (stagesCount <= ++infection.stage) {
|
|
87
|
+
if (infectionOptions.cure) {
|
|
88
|
+
delete infection.stage;
|
|
89
|
+
delete infection.time;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
infection.stage = 0;
|
|
93
|
+
infection.time = 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
96
97
|
}
|
package/cjs/InfectionPlugin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Infection } from "./Options/Classes/Infection.js";
|
|
2
2
|
export class InfectionPlugin {
|
|
3
|
-
|
|
4
|
-
this.id = "infection";
|
|
5
|
-
}
|
|
3
|
+
id = "infection";
|
|
6
4
|
async getPlugin(container) {
|
|
7
5
|
const { InfectionPluginInstance } = await import("./InfectionPluginInstance.js");
|
|
8
6
|
return new InfectionPluginInstance(container);
|
|
@@ -2,6 +2,7 @@ import { itemFromArray } from "@tsparticles/engine";
|
|
|
2
2
|
import { Infecter } from "./Infecter.js";
|
|
3
3
|
const minStage = 0;
|
|
4
4
|
export class InfectionPluginInstance {
|
|
5
|
+
_container;
|
|
5
6
|
constructor(container) {
|
|
6
7
|
this._container = container;
|
|
7
8
|
this._container.infecter = new Infecter(this._container);
|
|
@@ -27,8 +28,7 @@ export class InfectionPluginInstance {
|
|
|
27
28
|
const infP = p;
|
|
28
29
|
infP.infection ??= {};
|
|
29
30
|
return infP.infection.stage === undefined;
|
|
30
|
-
});
|
|
31
|
-
const infected = itemFromArray(notInfected);
|
|
31
|
+
}), infected = itemFromArray(notInfected);
|
|
32
32
|
if (!infected) {
|
|
33
33
|
continue;
|
|
34
34
|
}
|
package/cjs/ParticlesInfecter.js
CHANGED
|
@@ -2,8 +2,13 @@ import { double, getRandom } from "@tsparticles/engine";
|
|
|
2
2
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
const minStagesCount = 1;
|
|
4
4
|
export class ParticlesInfecter extends ParticlesInteractorBase {
|
|
5
|
+
_maxDistance;
|
|
5
6
|
constructor(container) {
|
|
6
7
|
super(container);
|
|
8
|
+
this._maxDistance = 0;
|
|
9
|
+
}
|
|
10
|
+
get maxDistance() {
|
|
11
|
+
return this._maxDistance;
|
|
7
12
|
}
|
|
8
13
|
clear() {
|
|
9
14
|
}
|
|
@@ -26,7 +31,8 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
|
|
|
26
31
|
if (!infectionStage1) {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
|
-
|
|
34
|
+
this._maxDistance = Math.max(this._maxDistance, infectionStage1.radius);
|
|
35
|
+
const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.grid.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
|
|
30
36
|
for (const p2 of query) {
|
|
31
37
|
const infP2 = p2;
|
|
32
38
|
if (infP2 === p1 ||
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export async function loadInfectionPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-
|
|
2
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
|
|
5
|
+
import("@tsparticles/plugin-interactivity"),
|
|
6
|
+
import("./InfectionPlugin.js"),
|
|
7
|
+
]);
|
|
8
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
9
|
e.addPlugin(new InfectionPlugin());
|
|
7
10
|
e.addInteractor?.("particlesInfection", async (container) => {
|
|
8
11
|
const { ParticlesInfecter } = await import("./ParticlesInfecter.js");
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\**********************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Infecter: () => (/* binding */ Infecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minStage = 0
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Infecter: () => (/* binding */ Infecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minStage = 0, minDuration = 0;\nclass Infecter {\n _container;\n constructor(container){\n this._container = container;\n }\n startInfection(particle, stage) {\n const infectionOptions = this._container.actualOptions.infection, { infection } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stages = infectionOptions.stages, stagesCount = stages.length;\n if (stage > stagesCount || stage < minStage) {\n return;\n }\n infection.delay = 0;\n infection.delayStage = stage;\n }\n updateInfection(particle, delta) {\n const infectionOptions = this._container.actualOptions.infection, { infection } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stages = infectionOptions.stages, stagesCount = stages.length;\n if (infection.delay !== undefined && infection.delayStage !== undefined) {\n const stage = infection.delayStage;\n if (stage > stagesCount || stage < minStage) {\n return;\n }\n if (infection.delay >= infectionOptions.delay * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds) {\n infection.stage = stage;\n infection.time = 0;\n delete infection.delay;\n delete infection.delayStage;\n } else {\n infection.delay += delta;\n }\n } else {\n delete infection.delay;\n delete infection.delayStage;\n }\n if (infection.stage !== undefined && infection.time !== undefined) {\n const infectionStage = stages[infection.stage];\n if (infectionStage?.duration !== undefined && infectionStage.duration >= minDuration) {\n if (infection.time > infectionStage.duration * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.millisecondsToSeconds) {\n this._nextInfectionStage(particle);\n } else {\n infection.time += delta;\n }\n } else {\n infection.time += delta;\n }\n } else {\n delete infection.stage;\n delete infection.time;\n }\n }\n updateInfectionStage(particle, stage) {\n const options = this._container.actualOptions, { infection } = particle;\n if (!options.infection || !infection) {\n return;\n }\n const stagesCount = options.infection.stages.length;\n if (stage > stagesCount || stage < minStage || infection.stage !== undefined && infection.stage > stage) {\n return;\n }\n infection.stage = stage;\n infection.time = 0;\n }\n _nextInfectionStage = (particle)=>{\n const infectionOptions = this._container.actualOptions.infection, { infection } = particle;\n if (!infectionOptions || !infection) {\n return;\n }\n const stagesCount = infectionOptions.stages.length;\n if (stagesCount <= minStage || infection.stage === undefined) {\n return;\n }\n infection.time = 0;\n if (stagesCount <= ++infection.stage) {\n if (infectionOptions.cure) {\n delete infection.stage;\n delete infection.time;\n } else {\n infection.stage = 0;\n infection.time = 0;\n }\n }\n };\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/Infecter.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\*************************************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPluginInstance: () => (/* binding */ InfectionPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Infecter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Infecter.js */ \"./dist/browser/Infecter.js\");\n\n\nconst minStage = 0;\nclass InfectionPluginInstance {\n
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPluginInstance: () => (/* binding */ InfectionPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Infecter_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Infecter.js */ \"./dist/browser/Infecter.js\");\n\n\nconst minStage = 0;\nclass InfectionPluginInstance {\n _container;\n constructor(container){\n this._container = container;\n this._container.infecter = new _Infecter_js__WEBPACK_IMPORTED_MODULE_1__.Infecter(this._container);\n }\n particleFillColor(particle) {\n const options = this._container.actualOptions;\n if (!particle.infection || !options.infection) {\n return;\n }\n const infectionStage = particle.infection.stage, infection = options.infection, infectionStages = infection.stages;\n return infectionStage === undefined ? undefined : infectionStages[infectionStage]?.color;\n }\n particleStrokeColor(particle) {\n return this.particleFillColor(particle);\n }\n particlesSetup() {\n const options = this._container.actualOptions;\n if (!options.infection) {\n return;\n }\n for(let i = 0; i < options.infection.infections; i++){\n const notInfected = this._container.particles.filter((p)=>{\n const infP = p;\n infP.infection ??= {};\n return infP.infection.stage === undefined;\n }), infected = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromArray)(notInfected);\n if (!infected) {\n continue;\n }\n this._container.infecter?.startInfection(infected, minStage);\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/InfectionPluginInstance.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ }
|
|
39
39
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*****************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPlugin: () => (/* binding */ InfectionPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Infection.js */ \"./dist/browser/Options/Classes/Infection.js\");\n\nclass InfectionPlugin {\n
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionPlugin: () => (/* binding */ InfectionPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Infection.js */ \"./dist/browser/Options/Classes/Infection.js\");\n\nclass InfectionPlugin {\n id = \"infection\";\n async getPlugin(container) {\n const { InfectionPluginInstance } = await __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPluginInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPluginInstance.js */ \"./dist/browser/InfectionPluginInstance.js\"));\n return new InfectionPluginInstance(container);\n }\n loadOptions(_container, options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let infectionOptions = options.infection;\n if (infectionOptions?.load === undefined) {\n options.infection = infectionOptions = new _Options_Classes_Infection_js__WEBPACK_IMPORTED_MODULE_0__.Infection();\n }\n infectionOptions.load(source?.infection);\n }\n needsPlugin(options) {\n return options?.infection?.enable ?? false;\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/InfectionPlugin.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -33,7 +33,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
33
33
|
\***************************************************/
|
|
34
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
35
|
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Infection: () => (/* binding */ Infection)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _InfectionStage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./InfectionStage.js */ \"./dist/browser/Options/Classes/InfectionStage.js\");\n\n\nclass Infection {\n
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Infection: () => (/* binding */ Infection)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _InfectionStage_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./InfectionStage.js */ \"./dist/browser/Options/Classes/InfectionStage.js\");\n\n\nclass Infection {\n cure;\n delay;\n enable;\n infections;\n stages;\n constructor(){\n this.cure = false;\n this.delay = 0;\n this.enable = false;\n this.infections = 0;\n this.stages = [];\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.cure !== undefined) {\n this.cure = data.cure;\n }\n if (data.delay !== undefined) {\n this.delay = data.delay;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.infections !== undefined) {\n this.infections = data.infections;\n }\n if (data.stages === undefined) {\n return;\n }\n this.stages = data.stages.map((t)=>{\n const s = new _InfectionStage_js__WEBPACK_IMPORTED_MODULE_1__.InfectionStage();\n s.load(t);\n return s;\n });\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/Options/Classes/Infection.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ },
|
|
39
39
|
|
|
@@ -43,7 +43,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
43
43
|
\********************************************************/
|
|
44
44
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
45
|
|
|
46
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionStage: () => (/* binding */ InfectionStage)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass InfectionStage {\n
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ InfectionStage: () => (/* binding */ InfectionStage)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass InfectionStage {\n color;\n duration;\n infectedStage;\n radius;\n rate;\n constructor(){\n this.color = new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor();\n this.color.value = \"#ff0000\";\n this.radius = 0;\n this.rate = 1;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.color !== undefined) {\n this.color = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(this.color, data.color);\n }\n this.duration = data.duration;\n this.infectedStage = data.infectedStage;\n if (data.radius !== undefined) {\n this.radius = data.radius;\n }\n if (data.rate !== undefined) {\n this.rate = data.rate;\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/Options/Classes/InfectionStage.js?\n}");
|
|
47
47
|
|
|
48
48
|
/***/ }
|
|
49
49
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-
|
|
7
|
+
* v4.0.0-beta.0
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*******************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesInfecter: () => (/* binding */ ParticlesInfecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n\n\nconst minStagesCount = 1;\nclass ParticlesInfecter extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ParticlesInteractorBase {\n
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesInfecter: () => (/* binding */ ParticlesInfecter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n\n\nconst minStagesCount = 1;\nclass ParticlesInfecter extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_1__.ParticlesInteractorBase {\n _maxDistance;\n constructor(container){\n super(container);\n this._maxDistance = 0;\n }\n get maxDistance() {\n return this._maxDistance;\n }\n clear() {}\n init() {}\n interact(p1, _interactivityData, delta) {\n const infecter = this.container.infecter;\n if (!infecter) {\n return;\n }\n infecter.updateInfection(p1, delta.value);\n if (p1.infection?.stage === undefined) {\n return;\n }\n const container = this.container, options = container.actualOptions, infectionOptions = options.infection;\n if (!infectionOptions?.enable || infectionOptions.stages.length < minStagesCount) {\n return;\n }\n const infectionStage1 = infectionOptions.stages[p1.infection.stage];\n if (!infectionStage1) {\n return;\n }\n this._maxDistance = Math.max(this._maxDistance, infectionStage1.radius);\n const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.grid.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;\n for (const p2 of query){\n const infP2 = p2;\n if (infP2 === p1 || infP2.destroyed || infP2.spawning || !(infP2.infection?.stage === undefined || infP2.infection.stage !== p1.infection.stage) || (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() >= infections / neighbors) {\n continue;\n }\n if (infP2.infection?.stage === undefined) {\n infecter.startInfection(infP2, infectedStage1);\n } else if (infP2.infection.stage < p1.infection.stage) {\n infecter.updateInfectionStage(infP2, infectedStage1);\n } else if (infP2.infection.stage > p1.infection.stage) {\n const infectionStage2 = infectionOptions.stages[infP2.infection.stage];\n if (!infectionStage2) {\n continue;\n }\n const infectedStage2 = infectionStage2.infectedStage ?? infP2.infection.stage;\n infecter.updateInfectionStage(p1, infectedStage2);\n }\n }\n }\n isEnabled() {\n return this.container.actualOptions.infection?.enable ?? false;\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/ParticlesInfecter.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ }
|
|
29
29
|
|
package/esm/Infecter.js
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import { millisecondsToSeconds } from "@tsparticles/engine";
|
|
2
2
|
const minStage = 0, minDuration = 0;
|
|
3
3
|
export class Infecter {
|
|
4
|
+
_container;
|
|
4
5
|
constructor(container) {
|
|
5
|
-
this._nextInfectionStage = particle => {
|
|
6
|
-
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
7
|
-
if (!infectionOptions || !infection) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const stagesCount = infectionOptions.stages.length;
|
|
11
|
-
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
infection.time = 0;
|
|
15
|
-
if (stagesCount <= ++infection.stage) {
|
|
16
|
-
if (infectionOptions.cure) {
|
|
17
|
-
delete infection.stage;
|
|
18
|
-
delete infection.time;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
infection.stage = 0;
|
|
22
|
-
infection.time = 0;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
6
|
this._container = container;
|
|
27
7
|
}
|
|
28
8
|
startInfection(particle, stage) {
|
|
@@ -93,4 +73,25 @@ export class Infecter {
|
|
|
93
73
|
infection.stage = stage;
|
|
94
74
|
infection.time = 0;
|
|
95
75
|
}
|
|
76
|
+
_nextInfectionStage = particle => {
|
|
77
|
+
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
78
|
+
if (!infectionOptions || !infection) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const stagesCount = infectionOptions.stages.length;
|
|
82
|
+
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
infection.time = 0;
|
|
86
|
+
if (stagesCount <= ++infection.stage) {
|
|
87
|
+
if (infectionOptions.cure) {
|
|
88
|
+
delete infection.stage;
|
|
89
|
+
delete infection.time;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
infection.stage = 0;
|
|
93
|
+
infection.time = 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
96
97
|
}
|
package/esm/InfectionPlugin.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Infection } from "./Options/Classes/Infection.js";
|
|
2
2
|
export class InfectionPlugin {
|
|
3
|
-
|
|
4
|
-
this.id = "infection";
|
|
5
|
-
}
|
|
3
|
+
id = "infection";
|
|
6
4
|
async getPlugin(container) {
|
|
7
5
|
const { InfectionPluginInstance } = await import("./InfectionPluginInstance.js");
|
|
8
6
|
return new InfectionPluginInstance(container);
|
|
@@ -2,6 +2,7 @@ import { itemFromArray } from "@tsparticles/engine";
|
|
|
2
2
|
import { Infecter } from "./Infecter.js";
|
|
3
3
|
const minStage = 0;
|
|
4
4
|
export class InfectionPluginInstance {
|
|
5
|
+
_container;
|
|
5
6
|
constructor(container) {
|
|
6
7
|
this._container = container;
|
|
7
8
|
this._container.infecter = new Infecter(this._container);
|
|
@@ -27,8 +28,7 @@ export class InfectionPluginInstance {
|
|
|
27
28
|
const infP = p;
|
|
28
29
|
infP.infection ??= {};
|
|
29
30
|
return infP.infection.stage === undefined;
|
|
30
|
-
});
|
|
31
|
-
const infected = itemFromArray(notInfected);
|
|
31
|
+
}), infected = itemFromArray(notInfected);
|
|
32
32
|
if (!infected) {
|
|
33
33
|
continue;
|
|
34
34
|
}
|
package/esm/ParticlesInfecter.js
CHANGED
|
@@ -2,8 +2,13 @@ import { double, getRandom } from "@tsparticles/engine";
|
|
|
2
2
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
const minStagesCount = 1;
|
|
4
4
|
export class ParticlesInfecter extends ParticlesInteractorBase {
|
|
5
|
+
_maxDistance;
|
|
5
6
|
constructor(container) {
|
|
6
7
|
super(container);
|
|
8
|
+
this._maxDistance = 0;
|
|
9
|
+
}
|
|
10
|
+
get maxDistance() {
|
|
11
|
+
return this._maxDistance;
|
|
7
12
|
}
|
|
8
13
|
clear() {
|
|
9
14
|
}
|
|
@@ -26,7 +31,8 @@ export class ParticlesInfecter extends ParticlesInteractorBase {
|
|
|
26
31
|
if (!infectionStage1) {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
|
-
|
|
34
|
+
this._maxDistance = Math.max(this._maxDistance, infectionStage1.radius);
|
|
35
|
+
const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * double + infectionStage1.radius * pxRatio, pos = p1.getPosition(), infectedStage1 = infectionStage1.infectedStage ?? p1.infection.stage, query = container.particles.grid.queryCircle(pos, radius), infections = infectionStage1.rate, neighbors = query.length;
|
|
30
36
|
for (const p2 of query) {
|
|
31
37
|
const infP2 = p2;
|
|
32
38
|
if (infP2 === p1 ||
|