@tsparticles/plugin-infection 4.0.0-alpha.8 → 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 +1 -1
- 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 ||
|
package/esm/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-infection",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles infection plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -100,8 +100,8 @@
|
|
|
100
100
|
"./package.json": "./package.json"
|
|
101
101
|
},
|
|
102
102
|
"dependencies": {
|
|
103
|
-
"@tsparticles/engine": "4.0.0-
|
|
104
|
-
"@tsparticles/plugin-interactivity": "4.0.0-
|
|
103
|
+
"@tsparticles/engine": "4.0.0-beta.0",
|
|
104
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.0"
|
|
105
105
|
},
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/plugin-infection [
|
|
6
|
+
<title>@tsparticles/plugin-infection [19 Mar 2026 at 14:03]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -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
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -28,16 +28,6 @@ return /******/ (() => { // webpackBootstrap
|
|
|
28
28
|
/******/ "use strict";
|
|
29
29
|
/******/ var __webpack_modules__ = ({
|
|
30
30
|
|
|
31
|
-
/***/ "./dist/browser/index.js"
|
|
32
|
-
/*!*******************************!*\
|
|
33
|
-
!*** ./dist/browser/index.js ***!
|
|
34
|
-
\*******************************/
|
|
35
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
36
|
-
|
|
37
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadInfectionPlugin: () => (/* binding */ loadInfectionPlugin)\n/* harmony export */ });\nasync function loadInfectionPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.8\");\n await engine.register(async e => {\n const {\n loadInteractivityPlugin\n } = await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19)),\n {\n InfectionPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPlugin.js */ \"./dist/browser/InfectionPlugin.js\"));\n await loadInteractivityPlugin(e);\n e.addPlugin(new InfectionPlugin());\n e.addInteractor?.(\"particlesInfection\", async container => {\n const {\n ParticlesInfecter\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ParticlesInfecter_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ParticlesInfecter.js */ \"./dist/browser/ParticlesInfecter.js\"));\n return new ParticlesInfecter(container);\n });\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/index.js?\n}");
|
|
38
|
-
|
|
39
|
-
/***/ },
|
|
40
|
-
|
|
41
31
|
/***/ "@tsparticles/engine"
|
|
42
32
|
/*!*********************************************************************************************************************************!*\
|
|
43
33
|
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
@@ -56,6 +46,16 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
56
46
|
|
|
57
47
|
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
58
48
|
|
|
49
|
+
/***/ },
|
|
50
|
+
|
|
51
|
+
/***/ "./dist/browser/index.js"
|
|
52
|
+
/*!*******************************!*\
|
|
53
|
+
!*** ./dist/browser/index.js ***!
|
|
54
|
+
\*******************************/
|
|
55
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
56
|
+
|
|
57
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadInfectionPlugin: () => (/* binding */ loadInfectionPlugin)\n/* harmony export */ });\nasync function loadInfectionPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register(async (e)=>{\n const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin }] = await Promise.all([\n Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19)),\n __webpack_require__.e(/*! import() */ \"dist_browser_InfectionPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./InfectionPlugin.js */ \"./dist/browser/InfectionPlugin.js\"))\n ]);\n ensureInteractivityPluginLoaded(e);\n e.addPlugin(new InfectionPlugin());\n e.addInteractor?.(\"particlesInfection\", async (container)=>{\n const { ParticlesInfecter } = await __webpack_require__.e(/*! import() */ \"dist_browser_ParticlesInfecter_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ParticlesInfecter.js */ \"./dist/browser/ParticlesInfecter.js\"));\n return new ParticlesInfecter(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-infection/./dist/browser/index.js?\n}");
|
|
58
|
+
|
|
59
59
|
/***/ }
|
|
60
60
|
|
|
61
61
|
/******/ });
|
|
@@ -70,12 +70,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
70
70
|
/******/ if (cachedModule !== undefined) {
|
|
71
71
|
/******/ return cachedModule.exports;
|
|
72
72
|
/******/ }
|
|
73
|
-
/******/ // Check if module exists (development only)
|
|
74
|
-
/******/ if (__webpack_modules__[moduleId] === undefined) {
|
|
75
|
-
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
76
|
-
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
77
|
-
/******/ throw e;
|
|
78
|
-
/******/ }
|
|
79
73
|
/******/ // Create a new module (and put it into the cache)
|
|
80
74
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
81
75
|
/******/ // no module.id needed
|
|
@@ -84,6 +78,12 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
84
78
|
/******/ };
|
|
85
79
|
/******/
|
|
86
80
|
/******/ // Execute the module function
|
|
81
|
+
/******/ if (!(moduleId in __webpack_modules__)) {
|
|
82
|
+
/******/ delete __webpack_module_cache__[moduleId];
|
|
83
|
+
/******/ var e = new Error("Cannot find module '" + moduleId + "'");
|
|
84
|
+
/******/ e.code = 'MODULE_NOT_FOUND';
|
|
85
|
+
/******/ throw e;
|
|
86
|
+
/******/ }
|
|
87
87
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
88
88
|
/******/
|
|
89
89
|
/******/ // Return the exports of the module
|
|
@@ -158,6 +158,18 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
158
158
|
/******/ };
|
|
159
159
|
/******/ })();
|
|
160
160
|
/******/
|
|
161
|
+
/******/ /* webpack/runtime/global */
|
|
162
|
+
/******/ (() => {
|
|
163
|
+
/******/ __webpack_require__.g = (function() {
|
|
164
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
165
|
+
/******/ try {
|
|
166
|
+
/******/ return this || new Function('return this')();
|
|
167
|
+
/******/ } catch (e) {
|
|
168
|
+
/******/ if (typeof window === 'object') return window;
|
|
169
|
+
/******/ }
|
|
170
|
+
/******/ })();
|
|
171
|
+
/******/ })();
|
|
172
|
+
/******/
|
|
161
173
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
162
174
|
/******/ (() => {
|
|
163
175
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
@@ -222,8 +234,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
222
234
|
/******/ /* webpack/runtime/publicPath */
|
|
223
235
|
/******/ (() => {
|
|
224
236
|
/******/ var scriptUrl;
|
|
225
|
-
/******/ if (
|
|
226
|
-
/******/ var document =
|
|
237
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
238
|
+
/******/ var document = __webpack_require__.g.document;
|
|
227
239
|
/******/ if (!scriptUrl && document) {
|
|
228
240
|
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
|
229
241
|
/******/ scriptUrl = document.currentScript.src;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-interactivity","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,n,o={303(e){e.exports=t},702(t){t.exports=e}},a={};function c(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return o[e](r,r.exports,c),r.exports}c.m=o,l=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,c.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);c.r(r);var i={};s=s||[null,l({}),l([]),l(l)];for(var n=2&t&&e;("object"==typeof n||"function"==typeof n)&&!~s.indexOf(n);n=l(n))Object.getOwnPropertyNames(n).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,c.d(r,i),r},c.d=(e,t)=>{for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.f={},c.e=e=>Promise.all(Object.keys(c.f).reduce((t,r)=>(c.f[r](e,t),t),[])),c.u=e=>""+e+".min.js",c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p={},c.l=(e,t,r,i)=>{if(p[e])return void p[e].push(t);if(void 0!==r)for(var n,o,a=document.getElementsByTagName("script"),s=0;s<a.length;s++){var l=a[s];if(l.getAttribute("src")==e||l.getAttribute("data-webpack")=="@tsparticles/plugin-infection:"+r){n=l;break}}n||(o=!0,(n=document.createElement("script")).charset="utf-8",c.nc&&n.setAttribute("nonce",c.nc),n.setAttribute("data-webpack","@tsparticles/plugin-infection:"+r),n.src=e),p[e]=[t];var u=(t,r)=>{n.onerror=n.onload=null,clearTimeout(f);var i=p[e];if(delete p[e],n.parentNode&&n.parentNode.removeChild(n),i&&i.forEach(e=>e(r)),t)return t(r)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:n}),12e4);n.onerror=u.bind(null,n.onerror),n.onload=u.bind(null,n.onload),o&&document.head.appendChild(n)},c.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(u=c.g.location+"");var s,l,p,u,f=c.g.document;if(!u&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(u=f.currentScript.src),!u)){var d=f.getElementsByTagName("script");if(d.length)for(var b=d.length-1;b>-1&&(!u||!/^http(s?):/.test(u));)u=d[b--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");c.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={587:0},c.f.j=(e,t)=>{var i=c.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var n=new Promise((t,n)=>i=r[e]=[t,n]);t.push(i[2]=n);var o=c.p+c.u(e),a=Error();c.l(o,t=>{if(c.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var n=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+n+": "+o+")",a.name="ChunkLoadError",a.type=n,a.request=o,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,n,[o,a,s]=t,l=0;if(o.some(e=>0!==r[e])){for(i in a)c.o(a,i)&&(c.m[i]=a[i]);s&&s(c)}for(e&&e(t);l<o.length;l++)n=o[l],c.o(r,n)&&r[n]&&r[n][0](),r[n]=0},(n=this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).forEach(i.bind(null,0)),n.push=i.bind(null,n.push.bind(n));var g={};async function h(e){e.checkVersion("4.0.0-beta.0"),await e.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{InfectionPlugin:r}]=await Promise.all([Promise.resolve().then(c.t.bind(c,702,19)),c.e(392).then(c.bind(c,392))]);t(e),e.addPlugin(new r),e.addInteractor?.("particlesInfection",async e=>{let{ParticlesInfecter:t}=await c.e(91).then(c.bind(c,91));return new t(e)})})}return c.r(g),c.d(g,{loadInfectionPlugin:()=>h}),g})());
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { Container, IContainerPlugin, IPlugin, RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { IInfectionOptions, InfectionOptions } from "./Types.js";
|
|
3
3
|
export declare class InfectionPlugin implements IPlugin {
|
|
4
|
-
readonly id
|
|
5
|
-
constructor();
|
|
4
|
+
readonly id = "infection";
|
|
6
5
|
getPlugin(container: Container): Promise<IContainerPlugin>;
|
|
7
6
|
loadOptions(_container: Container, options: InfectionOptions, source?: RecursivePartial<IInfectionOptions>): void;
|
|
8
7
|
needsPlugin(options?: RecursivePartial<IInfectionOptions>): boolean;
|
|
@@ -2,7 +2,9 @@ import { type IDelta } from "@tsparticles/engine";
|
|
|
2
2
|
import { type IInteractivityData, ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
3
|
import type { InfectableContainer, InfectableParticle } from "./Types.js";
|
|
4
4
|
export declare class ParticlesInfecter extends ParticlesInteractorBase<InfectableContainer> {
|
|
5
|
+
private _maxDistance;
|
|
5
6
|
constructor(container: InfectableContainer);
|
|
7
|
+
get maxDistance(): number;
|
|
6
8
|
clear(): void;
|
|
7
9
|
init(): void;
|
|
8
10
|
interact(p1: InfectableParticle, _interactivityData: IInteractivityData, delta: IDelta): void;
|
package/umd/Infecter.js
CHANGED
|
@@ -13,28 +13,8 @@
|
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const minStage = 0, minDuration = 0;
|
|
15
15
|
class Infecter {
|
|
16
|
+
_container;
|
|
16
17
|
constructor(container) {
|
|
17
|
-
this._nextInfectionStage = particle => {
|
|
18
|
-
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
19
|
-
if (!infectionOptions || !infection) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const stagesCount = infectionOptions.stages.length;
|
|
23
|
-
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
infection.time = 0;
|
|
27
|
-
if (stagesCount <= ++infection.stage) {
|
|
28
|
-
if (infectionOptions.cure) {
|
|
29
|
-
delete infection.stage;
|
|
30
|
-
delete infection.time;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
infection.stage = 0;
|
|
34
|
-
infection.time = 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
18
|
this._container = container;
|
|
39
19
|
}
|
|
40
20
|
startInfection(particle, stage) {
|
|
@@ -105,6 +85,27 @@
|
|
|
105
85
|
infection.stage = stage;
|
|
106
86
|
infection.time = 0;
|
|
107
87
|
}
|
|
88
|
+
_nextInfectionStage = particle => {
|
|
89
|
+
const infectionOptions = this._container.actualOptions.infection, { infection } = particle;
|
|
90
|
+
if (!infectionOptions || !infection) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const stagesCount = infectionOptions.stages.length;
|
|
94
|
+
if (stagesCount <= minStage || infection.stage === undefined) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
infection.time = 0;
|
|
98
|
+
if (stagesCount <= ++infection.stage) {
|
|
99
|
+
if (infectionOptions.cure) {
|
|
100
|
+
delete infection.stage;
|
|
101
|
+
delete infection.time;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
infection.stage = 0;
|
|
105
|
+
infection.time = 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
108
109
|
}
|
|
109
110
|
exports.Infecter = Infecter;
|
|
110
111
|
});
|
package/umd/InfectionPlugin.js
CHANGED
|
@@ -46,9 +46,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
46
46
|
exports.InfectionPlugin = void 0;
|
|
47
47
|
const Infection_js_1 = require("./Options/Classes/Infection.js");
|
|
48
48
|
class InfectionPlugin {
|
|
49
|
-
|
|
50
|
-
this.id = "infection";
|
|
51
|
-
}
|
|
49
|
+
id = "infection";
|
|
52
50
|
async getPlugin(container) {
|
|
53
51
|
const { InfectionPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./InfectionPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./InfectionPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
|
|
54
52
|
return new InfectionPluginInstance(container);
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
const Infecter_js_1 = require("./Infecter.js");
|
|
15
15
|
const minStage = 0;
|
|
16
16
|
class InfectionPluginInstance {
|
|
17
|
+
_container;
|
|
17
18
|
constructor(container) {
|
|
18
19
|
this._container = container;
|
|
19
20
|
this._container.infecter = new Infecter_js_1.Infecter(this._container);
|
|
@@ -39,8 +40,7 @@
|
|
|
39
40
|
const infP = p;
|
|
40
41
|
infP.infection ??= {};
|
|
41
42
|
return infP.infection.stage === undefined;
|
|
42
|
-
});
|
|
43
|
-
const infected = (0, engine_1.itemFromArray)(notInfected);
|
|
43
|
+
}), infected = (0, engine_1.itemFromArray)(notInfected);
|
|
44
44
|
if (!infected) {
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
exports.InfectionStage = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
class InfectionStage {
|
|
15
|
+
color;
|
|
16
|
+
duration;
|
|
17
|
+
infectedStage;
|
|
18
|
+
radius;
|
|
19
|
+
rate;
|
|
15
20
|
constructor() {
|
|
16
21
|
this.color = new engine_1.OptionsColor();
|
|
17
22
|
this.color.value = "#ff0000";
|
package/umd/ParticlesInfecter.js
CHANGED
|
@@ -14,8 +14,13 @@
|
|
|
14
14
|
const plugin_interactivity_1 = require("@tsparticles/plugin-interactivity");
|
|
15
15
|
const minStagesCount = 1;
|
|
16
16
|
class ParticlesInfecter extends plugin_interactivity_1.ParticlesInteractorBase {
|
|
17
|
+
_maxDistance;
|
|
17
18
|
constructor(container) {
|
|
18
19
|
super(container);
|
|
20
|
+
this._maxDistance = 0;
|
|
21
|
+
}
|
|
22
|
+
get maxDistance() {
|
|
23
|
+
return this._maxDistance;
|
|
19
24
|
}
|
|
20
25
|
clear() {
|
|
21
26
|
}
|
|
@@ -38,7 +43,8 @@
|
|
|
38
43
|
if (!infectionStage1) {
|
|
39
44
|
return;
|
|
40
45
|
}
|
|
41
|
-
|
|
46
|
+
this._maxDistance = Math.max(this._maxDistance, infectionStage1.radius);
|
|
47
|
+
const pxRatio = container.retina.pixelRatio, radius = p1.getRadius() * engine_1.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;
|
|
42
48
|
for (const p2 of query) {
|
|
43
49
|
const infP2 = p2;
|
|
44
50
|
if (infP2 === p1 ||
|
package/umd/index.js
CHANGED
|
@@ -45,10 +45,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadInfectionPlugin = loadInfectionPlugin;
|
|
47
47
|
async function loadInfectionPlugin(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-
|
|
48
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
49
49
|
await engine.register(async (e) => {
|
|
50
|
-
const {
|
|
51
|
-
|
|
50
|
+
const [{ ensureInteractivityPluginLoaded }, { InfectionPlugin },] = await Promise.all([
|
|
51
|
+
__syncRequire ? Promise.resolve().then(() => __importStar(require("@tsparticles/plugin-interactivity"))) : new Promise((resolve_1, reject_1) => { require(["@tsparticles/plugin-interactivity"], resolve_1, reject_1); }).then(__importStar),
|
|
52
|
+
__syncRequire ? Promise.resolve().then(() => __importStar(require("./InfectionPlugin.js"))) : new Promise((resolve_2, reject_2) => { require(["./InfectionPlugin.js"], resolve_2, reject_2); }).then(__importStar),
|
|
53
|
+
]);
|
|
54
|
+
ensureInteractivityPluginLoaded(e);
|
|
52
55
|
e.addPlugin(new InfectionPlugin());
|
|
53
56
|
e.addInteractor?.("particlesInfection", async (container) => {
|
|
54
57
|
const { ParticlesInfecter } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ParticlesInfecter.js"))) : new Promise((resolve_3, reject_3) => { require(["./ParticlesInfecter.js"], resolve_3, reject_3); }).then(__importStar));
|
package/249.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 249.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[249],{249(e,t,n){n.d(t,{ParticlesInfecter:()=>a});var i=n(303),s=n(702);class a extends s.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}interact(e,t,n){const s=this.container.infecter;if(!s)return;if(s.updateInfection(e,n.value),void 0===e.infection?.stage)return;const a=this.container,c=a.actualOptions.infection;if(!c?.enable||c.stages.length<1)return;const o=c.stages[e.infection.stage];if(!o)return;const r=a.retina.pixelRatio,f=e.getRadius()*i.double+o.radius*r,g=e.getPosition(),u=o.infectedStage??e.infection.stage,l=a.particles.quadTree.queryCircle(g,f),d=o.rate,p=l.length;for(const t of l){const n=t;if(!(n===e||n.destroyed||n.spawning||void 0!==n.infection?.stage&&n.infection.stage===e.infection.stage||(0,i.getRandom)()>=d/p))if(void 0===n.infection?.stage)s.startInfection(n,u);else if(n.infection.stage<e.infection.stage)s.updateInfectionStage(n,u);else if(n.infection.stage>e.infection.stage){const t=c.stages[n.infection.stage];if(!t)continue;const i=t.infectedStage??n.infection.stage;s.updateInfectionStage(e,i)}}}isEnabled(){return this.container.actualOptions.infection?.enable??!1}reset(){}}}}]);
|
package/249.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Infection Plugin v4.0.0-alpha.8 by Matteo Bruni */
|
package/713.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 713.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[713],{713(i,t,e){e.d(t,{InfectionPlugin:()=>a});var n=e(303);class s{constructor(){this.color=new n.OptionsColor,this.color.value="#ff0000",this.radius=0,this.rate=1}load(i){(0,n.isNull)(i)||(void 0!==i.color&&(this.color=n.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{constructor(){this.cure=!1,this.delay=0,this.enable=!1,this.infections=0,this.stages=[]}load(i){(0,n.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=>{const t=new s;return t.load(i),t}))))}}class a{constructor(){this.id="infection"}async getPlugin(i){const{InfectionPluginInstance:t}=await e.e(835).then(e.bind(e,835));return new t(i)}loadOptions(i,t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let n=t.infection;void 0===n?.load&&(t.infection=n=new o),n.load(e?.infection)}needsPlugin(i){return i?.infection?.enable??!1}}}}]);
|
package/713.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Infection Plugin v4.0.0-alpha.8 by Matteo Bruni */
|
package/835.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 835.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_infection=this.webpackChunk_tsparticles_plugin_infection||[]).push([[835],{835(t,e,i){i.d(e,{InfectionPluginInstance:()=>s});var n=i(303);class o{constructor(t){this._nextInfectionStage=t=>{const e=this._container.actualOptions.infection,{infection:i}=t;if(!e||!i)return;const n=e.stages.length;n<=0||void 0===i.stage||(i.time=0,n<=++i.stage&&(e.cure?(delete i.stage,delete i.time):(i.stage=0,i.time=0)))},this._container=t}startInfection(t,e){const i=this._container.actualOptions.infection,{infection:n}=t;if(!i||!n)return;e>i.stages.length||e<0||(n.delay=0,n.delayStage=e)}updateInfection(t,e){const i=this._container.actualOptions.infection,{infection:o}=t;if(!i||!o)return;const s=i.stages,a=s.length;if(void 0!==o.delay&&void 0!==o.delayStage){const t=o.delayStage;if(t>a||t<0)return;o.delay>=i.delay*n.millisecondsToSeconds?(o.stage=t,o.time=0,delete o.delay,delete o.delayStage):o.delay+=e}else delete o.delay,delete o.delayStage;if(void 0!==o.stage&&void 0!==o.time){const i=s[o.stage];void 0!==i?.duration&&i.duration>=0&&o.time>i.duration*n.millisecondsToSeconds?this._nextInfectionStage(t):o.time+=e}else delete o.stage,delete o.time}updateInfectionStage(t,e){const i=this._container.actualOptions,{infection:n}=t;if(!i.infection||!n)return;e>i.infection.stages.length||e<0||void 0!==n.stage&&n.stage>e||(n.stage=e,n.time=0)}}class s{constructor(t){this._container=t,this._container.infecter=new o(this._container)}particleFillColor(t){const e=this._container.actualOptions;if(!t.infection||!e.infection)return;const i=t.infection.stage,n=e.infection.stages;return void 0===i?void 0:n[i]?.color}particleStrokeColor(t){return this.particleFillColor(t)}particlesSetup(){const t=this._container.actualOptions;if(t.infection)for(let e=0;e<t.infection.infections;e++){const t=this._container.particles.filter((t=>{const e=t;return e.infection??={},void 0===e.infection.stage})),e=(0,n.itemFromArray)(t);e&&this._container.infecter?.startInfection(e,0)}}}}}]);
|
package/835.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Infection Plugin v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Infection Plugin v4.0.0-alpha.8 by Matteo Bruni */
|