@tsparticles/interaction-particles-repulse 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/794.min.js +1 -0
- package/README.md +5 -0
- package/browser/Options/Classes/ParticlesRepulse.js +5 -0
- package/browser/Repulser.js +24 -7
- package/browser/index.js +3 -3
- package/cjs/Options/Classes/ParticlesRepulse.js +5 -0
- package/cjs/Repulser.js +24 -7
- package/cjs/index.js +3 -3
- package/dist_browser_Repulser_js.js +3 -3
- package/esm/Options/Classes/ParticlesRepulse.js +5 -0
- package/esm/Repulser.js +24 -7
- package/esm/index.js +3 -3
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.interaction.particles.repulse.js +31 -19
- package/tsparticles.interaction.particles.repulse.min.js +2 -2
- package/types/Repulser.d.ts +4 -0
- package/umd/Options/Classes/ParticlesRepulse.js +5 -0
- package/umd/Repulser.js +24 -7
- package/umd/index.js +3 -3
- package/753.min.js +0 -2
- package/753.min.js.LICENSE.txt +0 -1
- package/tsparticles.interaction.particles.repulse.min.js.LICENSE.txt +0 -1
package/794.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_particles_repulse=this.webpackChunk_tsparticles_interaction_particles_repulse||[]).push([[794],{794(e,t,s){s.d(t,{Repulser:()=>n});var i=s(702),a=s(303);class r extends a.ValueWithRandom{distance;duration;enabled;factor;speed;constructor(){super(),this.enabled=!1,this.distance=1,this.duration=1,this.factor=1,this.speed=1}load(e){super.load(e),(0,a.isNull)(e)||(void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.distance&&(this.distance=(0,a.setRangeValue)(e.distance)),void 0!==e.duration&&(this.duration=(0,a.setRangeValue)(e.duration)),void 0!==e.factor&&(this.factor=(0,a.setRangeValue)(e.factor)),void 0!==e.speed&&(this.speed=(0,a.setRangeValue)(e.speed)))}}class n extends i.ParticlesInteractorBase{_maxDistance;_normVec;_velocityVec;constructor(e){super(e),this._maxDistance=0,this._normVec=a.Vector.origin,this._velocityVec=a.Vector.origin}get maxDistance(){return this._maxDistance}clear(){}init(){}interact(e){let t=this.container;if(!e.repulse){let s=e.options.repulse;if(!s)return;let i=(0,a.getRangeValue)(s.distance);i>this.maxDistance&&(this._maxDistance=i),e.repulse={distance:i*t.retina.pixelRatio,speed:(0,a.getRangeValue)(s.speed),factor:(0,a.getRangeValue)(s.factor)}}let s=e.getPosition(),i=t.particles.grid.queryCircle(s,e.repulse.distance),r=1/e.repulse.distance;for(let t of i){if(e===t||t.destroyed)continue;let i=t.getPosition(),{dx:n,dy:o,distance:c}=(0,a.getDistances)(i,s),l=1/c,d=e.repulse.speed*e.repulse.factor;if(c>0){let e=(0,a.clamp)((1-Math.pow(c*r,2))*d,0,d)*l;this._normVec.x=n*e,this._normVec.y=o*e,t.position.addTo(this._normVec)}else this._velocityVec.x=d,this._velocityVec.y=d,t.position.addTo(this._velocityVec)}}isEnabled(e){return e.options.repulse?.enabled??!1}loadParticlesOptions(e,...t){for(let s of(e.repulse??=new r,t))e.repulse.load(s?.repulse)}reset(){}}}}]);
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ Once the scripts are loaded you can set up `tsParticles` and the interaction plu
|
|
|
27
27
|
|
|
28
28
|
```javascript
|
|
29
29
|
(async () => {
|
|
30
|
+
await loadInteractivityPlugin(tsParticles);
|
|
30
31
|
await loadParticlesRepulseInteraction(tsParticles);
|
|
31
32
|
|
|
32
33
|
await tsParticles.load({
|
|
@@ -56,9 +57,11 @@ Then you need to import it in the app, like this:
|
|
|
56
57
|
|
|
57
58
|
```javascript
|
|
58
59
|
const { tsParticles } = require("@tsparticles/engine");
|
|
60
|
+
const { loadInteractivityPlugin } = require("@tsparticles/plugin-interactivity");
|
|
59
61
|
const { loadParticlesRepulseInteraction } = require("@tsparticles/interaction-particles-repulse");
|
|
60
62
|
|
|
61
63
|
(async () => {
|
|
64
|
+
await loadInteractivityPlugin(tsParticles);
|
|
62
65
|
await loadParticlesRepulseInteraction(tsParticles);
|
|
63
66
|
})();
|
|
64
67
|
```
|
|
@@ -67,9 +70,11 @@ or
|
|
|
67
70
|
|
|
68
71
|
```javascript
|
|
69
72
|
import { tsParticles } from "@tsparticles/engine";
|
|
73
|
+
import { loadInteractivityPlugin } from "@tsparticles/plugin-interactivity";
|
|
70
74
|
import { loadParticlesRepulseInteraction } from "@tsparticles/interaction-particles-repulse";
|
|
71
75
|
|
|
72
76
|
(async () => {
|
|
77
|
+
await loadInteractivityPlugin(tsParticles);
|
|
73
78
|
await loadParticlesRepulseInteraction(tsParticles);
|
|
74
79
|
})();
|
|
75
80
|
```
|
package/browser/Repulser.js
CHANGED
|
@@ -3,8 +3,17 @@ import { Vector, clamp, getDistances, getRangeValue } from "@tsparticles/engine"
|
|
|
3
3
|
import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
|
|
4
4
|
const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
|
|
5
5
|
export class Repulser extends ParticlesInteractorBase {
|
|
6
|
+
_maxDistance;
|
|
7
|
+
_normVec;
|
|
8
|
+
_velocityVec;
|
|
6
9
|
constructor(container) {
|
|
7
10
|
super(container);
|
|
11
|
+
this._maxDistance = 0;
|
|
12
|
+
this._normVec = Vector.origin;
|
|
13
|
+
this._velocityVec = Vector.origin;
|
|
14
|
+
}
|
|
15
|
+
get maxDistance() {
|
|
16
|
+
return this._maxDistance;
|
|
8
17
|
}
|
|
9
18
|
clear() {
|
|
10
19
|
}
|
|
@@ -17,25 +26,33 @@ export class Repulser extends ParticlesInteractorBase {
|
|
|
17
26
|
if (!repulseOpt1) {
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
29
|
+
const repulseDistance = getRangeValue(repulseOpt1.distance);
|
|
30
|
+
if (repulseDistance > this.maxDistance) {
|
|
31
|
+
this._maxDistance = repulseDistance;
|
|
32
|
+
}
|
|
20
33
|
p1.repulse = {
|
|
21
|
-
distance:
|
|
34
|
+
distance: repulseDistance * container.retina.pixelRatio,
|
|
22
35
|
speed: getRangeValue(repulseOpt1.speed),
|
|
23
36
|
factor: getRangeValue(repulseOpt1.factor),
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
|
-
const pos1 = p1.getPosition(), query = container.particles.
|
|
39
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
27
40
|
for (const p2 of query) {
|
|
28
41
|
if (p1 === p2 || p2.destroyed) {
|
|
29
42
|
continue;
|
|
30
43
|
}
|
|
31
|
-
const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), velocity = p1.repulse.speed * p1.repulse.factor;
|
|
44
|
+
const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), distanceFactor = identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;
|
|
32
45
|
if (distance > minDistance) {
|
|
33
|
-
const repulseFactor = clamp((identity - Math.pow(distance
|
|
34
|
-
|
|
46
|
+
const repulseFactor = clamp((identity - Math.pow(distance * p1DistanceFactor, squareExp)) * velocity, minVelocity, velocity) *
|
|
47
|
+
distanceFactor;
|
|
48
|
+
this._normVec.x = dx * repulseFactor;
|
|
49
|
+
this._normVec.y = dy * repulseFactor;
|
|
50
|
+
p2.position.addTo(this._normVec);
|
|
35
51
|
}
|
|
36
52
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
this._velocityVec.x = velocity;
|
|
54
|
+
this._velocityVec.y = velocity;
|
|
55
|
+
p2.position.addTo(this._velocityVec);
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadParticlesRepulseInteraction(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 } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("particlesRepulse", async (container) => {
|
|
7
7
|
const { Repulser } = await import("./Repulser.js");
|
|
8
8
|
return new Repulser(container);
|
package/cjs/Repulser.js
CHANGED
|
@@ -3,8 +3,17 @@ import { Vector, clamp, getDistances, getRangeValue } from "@tsparticles/engine"
|
|
|
3
3
|
import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
|
|
4
4
|
const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
|
|
5
5
|
export class Repulser extends ParticlesInteractorBase {
|
|
6
|
+
_maxDistance;
|
|
7
|
+
_normVec;
|
|
8
|
+
_velocityVec;
|
|
6
9
|
constructor(container) {
|
|
7
10
|
super(container);
|
|
11
|
+
this._maxDistance = 0;
|
|
12
|
+
this._normVec = Vector.origin;
|
|
13
|
+
this._velocityVec = Vector.origin;
|
|
14
|
+
}
|
|
15
|
+
get maxDistance() {
|
|
16
|
+
return this._maxDistance;
|
|
8
17
|
}
|
|
9
18
|
clear() {
|
|
10
19
|
}
|
|
@@ -17,25 +26,33 @@ export class Repulser extends ParticlesInteractorBase {
|
|
|
17
26
|
if (!repulseOpt1) {
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
29
|
+
const repulseDistance = getRangeValue(repulseOpt1.distance);
|
|
30
|
+
if (repulseDistance > this.maxDistance) {
|
|
31
|
+
this._maxDistance = repulseDistance;
|
|
32
|
+
}
|
|
20
33
|
p1.repulse = {
|
|
21
|
-
distance:
|
|
34
|
+
distance: repulseDistance * container.retina.pixelRatio,
|
|
22
35
|
speed: getRangeValue(repulseOpt1.speed),
|
|
23
36
|
factor: getRangeValue(repulseOpt1.factor),
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
|
-
const pos1 = p1.getPosition(), query = container.particles.
|
|
39
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
27
40
|
for (const p2 of query) {
|
|
28
41
|
if (p1 === p2 || p2.destroyed) {
|
|
29
42
|
continue;
|
|
30
43
|
}
|
|
31
|
-
const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), velocity = p1.repulse.speed * p1.repulse.factor;
|
|
44
|
+
const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), distanceFactor = identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;
|
|
32
45
|
if (distance > minDistance) {
|
|
33
|
-
const repulseFactor = clamp((identity - Math.pow(distance
|
|
34
|
-
|
|
46
|
+
const repulseFactor = clamp((identity - Math.pow(distance * p1DistanceFactor, squareExp)) * velocity, minVelocity, velocity) *
|
|
47
|
+
distanceFactor;
|
|
48
|
+
this._normVec.x = dx * repulseFactor;
|
|
49
|
+
this._normVec.y = dy * repulseFactor;
|
|
50
|
+
p2.position.addTo(this._normVec);
|
|
35
51
|
}
|
|
36
52
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
this._velocityVec.x = velocity;
|
|
54
|
+
this._velocityVec.y = velocity;
|
|
55
|
+
p2.position.addTo(this._velocityVec);
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadParticlesRepulseInteraction(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 } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("particlesRepulse", async (container) => {
|
|
7
7
|
const { Repulser } = await import("./Repulser.js");
|
|
8
8
|
return new Repulser(container);
|
|
@@ -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 */ ParticlesRepulse: () => (/* binding */ ParticlesRepulse)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass ParticlesRepulse extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesRepulse: () => (/* binding */ ParticlesRepulse)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass ParticlesRepulse extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n distance;\n duration;\n enabled;\n factor;\n speed;\n constructor(){\n super();\n this.enabled = false;\n this.distance = 1;\n this.duration = 1;\n this.factor = 1;\n this.speed = 1;\n }\n load(data) {\n super.load(data);\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enabled !== undefined) {\n this.enabled = data.enabled;\n }\n if (data.distance !== undefined) {\n this.distance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.distance);\n }\n if (data.duration !== undefined) {\n this.duration = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.duration);\n }\n if (data.factor !== undefined) {\n this.factor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.factor);\n }\n if (data.speed !== undefined) {\n this.speed = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.speed);\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-repulse/./dist/browser/Options/Classes/ParticlesRepulse.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 */ Repulser: () => (/* binding */ Repulser)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_ParticlesRepulse_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/ParticlesRepulse.js */ \"./dist/browser/Options/Classes/ParticlesRepulse.js\");\n\n\n\nconst minDistance = 0
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Repulser: () => (/* binding */ Repulser)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_ParticlesRepulse_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Options/Classes/ParticlesRepulse.js */ \"./dist/browser/Options/Classes/ParticlesRepulse.js\");\n\n\n\nconst minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;\nclass Repulser extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.ParticlesInteractorBase {\n _maxDistance;\n _normVec;\n _velocityVec;\n constructor(container){\n super(container);\n this._maxDistance = 0;\n this._normVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.Vector.origin;\n this._velocityVec = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.Vector.origin;\n }\n get maxDistance() {\n return this._maxDistance;\n }\n clear() {}\n init() {}\n interact(p1) {\n const container = this.container;\n if (!p1.repulse) {\n const repulseOpt1 = p1.options.repulse;\n if (!repulseOpt1) {\n return;\n }\n const repulseDistance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.getRangeValue)(repulseOpt1.distance);\n if (repulseDistance > this.maxDistance) {\n this._maxDistance = repulseDistance;\n }\n p1.repulse = {\n distance: repulseDistance * container.retina.pixelRatio,\n speed: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.getRangeValue)(repulseOpt1.speed),\n factor: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.getRangeValue)(repulseOpt1.factor)\n };\n }\n const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;\n for (const p2 of query){\n if (p1 === p2 || p2.destroyed) {\n continue;\n }\n const pos2 = p2.getPosition(), { dx, dy, distance } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.getDistances)(pos2, pos1), distanceFactor = identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;\n if (distance > minDistance) {\n const repulseFactor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.clamp)((identity - Math.pow(distance * p1DistanceFactor, squareExp)) * velocity, minVelocity, velocity) * distanceFactor;\n this._normVec.x = dx * repulseFactor;\n this._normVec.y = dy * repulseFactor;\n p2.position.addTo(this._normVec);\n } else {\n this._velocityVec.x = velocity;\n this._velocityVec.y = velocity;\n p2.position.addTo(this._velocityVec);\n }\n }\n }\n isEnabled(particle) {\n return particle.options.repulse?.enabled ?? false;\n }\n loadParticlesOptions(options, ...sources) {\n options.repulse ??= new _Options_Classes_ParticlesRepulse_js__WEBPACK_IMPORTED_MODULE_2__.ParticlesRepulse();\n for (const source of sources){\n options.repulse.load(source?.repulse);\n }\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-repulse/./dist/browser/Repulser.js?\n}");
|
|
37
37
|
|
|
38
38
|
/***/ }
|
|
39
39
|
|
package/esm/Repulser.js
CHANGED
|
@@ -3,8 +3,17 @@ import { Vector, clamp, getDistances, getRangeValue } from "@tsparticles/engine"
|
|
|
3
3
|
import { ParticlesRepulse } from "./Options/Classes/ParticlesRepulse.js";
|
|
4
4
|
const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
|
|
5
5
|
export class Repulser extends ParticlesInteractorBase {
|
|
6
|
+
_maxDistance;
|
|
7
|
+
_normVec;
|
|
8
|
+
_velocityVec;
|
|
6
9
|
constructor(container) {
|
|
7
10
|
super(container);
|
|
11
|
+
this._maxDistance = 0;
|
|
12
|
+
this._normVec = Vector.origin;
|
|
13
|
+
this._velocityVec = Vector.origin;
|
|
14
|
+
}
|
|
15
|
+
get maxDistance() {
|
|
16
|
+
return this._maxDistance;
|
|
8
17
|
}
|
|
9
18
|
clear() {
|
|
10
19
|
}
|
|
@@ -17,25 +26,33 @@ export class Repulser extends ParticlesInteractorBase {
|
|
|
17
26
|
if (!repulseOpt1) {
|
|
18
27
|
return;
|
|
19
28
|
}
|
|
29
|
+
const repulseDistance = getRangeValue(repulseOpt1.distance);
|
|
30
|
+
if (repulseDistance > this.maxDistance) {
|
|
31
|
+
this._maxDistance = repulseDistance;
|
|
32
|
+
}
|
|
20
33
|
p1.repulse = {
|
|
21
|
-
distance:
|
|
34
|
+
distance: repulseDistance * container.retina.pixelRatio,
|
|
22
35
|
speed: getRangeValue(repulseOpt1.speed),
|
|
23
36
|
factor: getRangeValue(repulseOpt1.factor),
|
|
24
37
|
};
|
|
25
38
|
}
|
|
26
|
-
const pos1 = p1.getPosition(), query = container.particles.
|
|
39
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
27
40
|
for (const p2 of query) {
|
|
28
41
|
if (p1 === p2 || p2.destroyed) {
|
|
29
42
|
continue;
|
|
30
43
|
}
|
|
31
|
-
const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), velocity = p1.repulse.speed * p1.repulse.factor;
|
|
44
|
+
const pos2 = p2.getPosition(), { dx, dy, distance } = getDistances(pos2, pos1), distanceFactor = identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;
|
|
32
45
|
if (distance > minDistance) {
|
|
33
|
-
const repulseFactor = clamp((identity - Math.pow(distance
|
|
34
|
-
|
|
46
|
+
const repulseFactor = clamp((identity - Math.pow(distance * p1DistanceFactor, squareExp)) * velocity, minVelocity, velocity) *
|
|
47
|
+
distanceFactor;
|
|
48
|
+
this._normVec.x = dx * repulseFactor;
|
|
49
|
+
this._normVec.y = dy * repulseFactor;
|
|
50
|
+
p2.position.addTo(this._normVec);
|
|
35
51
|
}
|
|
36
52
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
this._velocityVec.x = velocity;
|
|
54
|
+
this._velocityVec.y = velocity;
|
|
55
|
+
p2.position.addTo(this._velocityVec);
|
|
39
56
|
}
|
|
40
57
|
}
|
|
41
58
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export async function loadParticlesRepulseInteraction(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 } = await import("@tsparticles/plugin-interactivity");
|
|
5
|
+
ensureInteractivityPluginLoaded(e);
|
|
6
6
|
e.addInteractor?.("particlesRepulse", async (container) => {
|
|
7
7
|
const { Repulser } = await import("./Repulser.js");
|
|
8
8
|
return new Repulser(container);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-particles-repulse",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles repulse particles interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"./package.json": "./package.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@tsparticles/engine": "4.0.0-
|
|
105
|
-
"@tsparticles/plugin-interactivity": "4.0.0-
|
|
104
|
+
"@tsparticles/engine": "4.0.0-beta.0",
|
|
105
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.0"
|
|
106
106
|
},
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"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/interaction-particles-repulse [
|
|
6
|
+
<title>@tsparticles/interaction-particles-repulse [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 */ loadParticlesRepulseInteraction: () => (/* binding */ loadParticlesRepulseInteraction)\n/* harmony export */ });\nasync function loadParticlesRepulseInteraction(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 await loadInteractivityPlugin(e);\n e.addInteractor?.(\"particlesRepulse\", async container => {\n const {\n Repulser\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_Repulser_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Repulser.js */ \"./dist/browser/Repulser.js\"));\n return new Repulser(container);\n });\n });\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-repulse/./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 */ loadParticlesRepulseInteraction: () => (/* binding */ loadParticlesRepulseInteraction)\n/* harmony export */ });\nasync function loadParticlesRepulseInteraction(engine) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register(async (e)=>{\n const { ensureInteractivityPluginLoaded } = await Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19));\n ensureInteractivityPluginLoaded(e);\n e.addInteractor?.(\"particlesRepulse\", async (container)=>{\n const { Repulser } = await __webpack_require__.e(/*! import() */ \"dist_browser_Repulser_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Repulser.js */ \"./dist/browser/Repulser.js\"));\n return new Repulser(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-repulse/./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,o,n={303(e){e.exports=t},702(t){t.exports=e}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,s),r.exports}s.m=n,p=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.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);s.r(r);var i={};c=c||[null,p({}),p([]),p(p)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~c.indexOf(o);o=p(o))Object.getOwnPropertyNames(o).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var r in t)s.o(t,r)&&!s.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce((t,r)=>(s.f[r](e,t),t),[])),s.u=e=>""+e+".min.js",s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},s.l=(e,t,r,i)=>{if(l[e])return void l[e].push(t);if(void 0!==r)for(var o,n,a=document.getElementsByTagName("script"),c=0;c<a.length;c++){var p=a[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/interaction-particles-repulse:"+r){o=p;break}}o||(n=!0,(o=document.createElement("script")).charset="utf-8",s.nc&&o.setAttribute("nonce",s.nc),o.setAttribute("data-webpack","@tsparticles/interaction-particles-repulse:"+r),o.src=e),l[e]=[t];var u=(t,r)=>{o.onerror=o.onload=null,clearTimeout(f);var i=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach(e=>e(r)),t)return t(r)},f=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),n&&document.head.appendChild(o)},s.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.g.importScripts&&(u=s.g.location+"");var c,p,l,u,f=s.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");s.p=u=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={954:0},s.f.j=(e,t)=>{var i=s.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var o=new Promise((t,o)=>i=r[e]=[t,o]);t.push(i[2]=o);var n=s.p+s.u(e),a=Error();s.l(n,t=>{if(s.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var o=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+o+": "+n+")",a.name="ChunkLoadError",a.type=o,a.request=n,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,o,[n,a,c]=t,p=0;if(n.some(e=>0!==r[e])){for(i in a)s.o(a,i)&&(s.m[i]=a[i]);c&&c(s)}for(e&&e(t);p<n.length;p++)o=n[p],s.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_interaction_particles_repulse=this.webpackChunk_tsparticles_interaction_particles_repulse||[]).forEach(i.bind(null,0)),o.push=i.bind(null,o.push.bind(o));var h={};async function g(e){e.checkVersion("4.0.0-beta.0"),await e.register(async e=>{let{ensureInteractivityPluginLoaded:t}=await Promise.resolve().then(s.t.bind(s,702,19));t(e),e.addInteractor?.("particlesRepulse",async e=>{let{Repulser:t}=await s.e(794).then(s.bind(s,794));return new t(e)})})}return s.r(h),s.d(h,{loadParticlesRepulseInteraction:()=>g}),h})());
|
package/types/Repulser.d.ts
CHANGED
|
@@ -10,7 +10,11 @@ type RepulseParticle = Particle & {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
export declare class Repulser extends ParticlesInteractorBase {
|
|
13
|
+
private _maxDistance;
|
|
14
|
+
private readonly _normVec;
|
|
15
|
+
private readonly _velocityVec;
|
|
13
16
|
constructor(container: InteractivityContainer);
|
|
17
|
+
get maxDistance(): number;
|
|
14
18
|
clear(): void;
|
|
15
19
|
init(): void;
|
|
16
20
|
interact(p1: RepulseParticle): void;
|
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
exports.ParticlesRepulse = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
class ParticlesRepulse extends engine_1.ValueWithRandom {
|
|
15
|
+
distance;
|
|
16
|
+
duration;
|
|
17
|
+
enabled;
|
|
18
|
+
factor;
|
|
19
|
+
speed;
|
|
15
20
|
constructor() {
|
|
16
21
|
super();
|
|
17
22
|
this.enabled = false;
|
package/umd/Repulser.js
CHANGED
|
@@ -15,8 +15,17 @@
|
|
|
15
15
|
const ParticlesRepulse_js_1 = require("./Options/Classes/ParticlesRepulse.js");
|
|
16
16
|
const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
|
|
17
17
|
class Repulser extends plugin_interactivity_1.ParticlesInteractorBase {
|
|
18
|
+
_maxDistance;
|
|
19
|
+
_normVec;
|
|
20
|
+
_velocityVec;
|
|
18
21
|
constructor(container) {
|
|
19
22
|
super(container);
|
|
23
|
+
this._maxDistance = 0;
|
|
24
|
+
this._normVec = engine_1.Vector.origin;
|
|
25
|
+
this._velocityVec = engine_1.Vector.origin;
|
|
26
|
+
}
|
|
27
|
+
get maxDistance() {
|
|
28
|
+
return this._maxDistance;
|
|
20
29
|
}
|
|
21
30
|
clear() {
|
|
22
31
|
}
|
|
@@ -29,25 +38,33 @@
|
|
|
29
38
|
if (!repulseOpt1) {
|
|
30
39
|
return;
|
|
31
40
|
}
|
|
41
|
+
const repulseDistance = (0, engine_1.getRangeValue)(repulseOpt1.distance);
|
|
42
|
+
if (repulseDistance > this.maxDistance) {
|
|
43
|
+
this._maxDistance = repulseDistance;
|
|
44
|
+
}
|
|
32
45
|
p1.repulse = {
|
|
33
|
-
distance:
|
|
46
|
+
distance: repulseDistance * container.retina.pixelRatio,
|
|
34
47
|
speed: (0, engine_1.getRangeValue)(repulseOpt1.speed),
|
|
35
48
|
factor: (0, engine_1.getRangeValue)(repulseOpt1.factor),
|
|
36
49
|
};
|
|
37
50
|
}
|
|
38
|
-
const pos1 = p1.getPosition(), query = container.particles.
|
|
51
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
39
52
|
for (const p2 of query) {
|
|
40
53
|
if (p1 === p2 || p2.destroyed) {
|
|
41
54
|
continue;
|
|
42
55
|
}
|
|
43
|
-
const pos2 = p2.getPosition(), { dx, dy, distance } = (0, engine_1.getDistances)(pos2, pos1), velocity = p1.repulse.speed * p1.repulse.factor;
|
|
56
|
+
const pos2 = p2.getPosition(), { dx, dy, distance } = (0, engine_1.getDistances)(pos2, pos1), distanceFactor = identity / distance, velocity = p1.repulse.speed * p1.repulse.factor;
|
|
44
57
|
if (distance > minDistance) {
|
|
45
|
-
const repulseFactor = (0, engine_1.clamp)((identity - Math.pow(distance
|
|
46
|
-
|
|
58
|
+
const repulseFactor = (0, engine_1.clamp)((identity - Math.pow(distance * p1DistanceFactor, squareExp)) * velocity, minVelocity, velocity) *
|
|
59
|
+
distanceFactor;
|
|
60
|
+
this._normVec.x = dx * repulseFactor;
|
|
61
|
+
this._normVec.y = dy * repulseFactor;
|
|
62
|
+
p2.position.addTo(this._normVec);
|
|
47
63
|
}
|
|
48
64
|
else {
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
this._velocityVec.x = velocity;
|
|
66
|
+
this._velocityVec.y = velocity;
|
|
67
|
+
p2.position.addTo(this._velocityVec);
|
|
51
68
|
}
|
|
52
69
|
}
|
|
53
70
|
}
|
package/umd/index.js
CHANGED
|
@@ -45,10 +45,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadParticlesRepulseInteraction = loadParticlesRepulseInteraction;
|
|
47
47
|
async function loadParticlesRepulseInteraction(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 } = await (__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));
|
|
51
|
+
ensureInteractivityPluginLoaded(e);
|
|
52
52
|
e.addInteractor?.("particlesRepulse", async (container) => {
|
|
53
53
|
const { Repulser } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Repulser.js"))) : new Promise((resolve_2, reject_2) => { require(["./Repulser.js"], resolve_2, reject_2); }).then(__importStar));
|
|
54
54
|
return new Repulser(container);
|
package/753.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 753.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_interaction_particles_repulse=this.webpackChunk_tsparticles_interaction_particles_repulse||[]).push([[753],{753(e,t,s){s.d(t,{Repulser:()=>r});var a=s(702),i=s(303);class n extends i.ValueWithRandom{constructor(){super(),this.enabled=!1,this.distance=1,this.duration=1,this.factor=1,this.speed=1}load(e){super.load(e),(0,i.isNull)(e)||(void 0!==e.enabled&&(this.enabled=e.enabled),void 0!==e.distance&&(this.distance=(0,i.setRangeValue)(e.distance)),void 0!==e.duration&&(this.duration=(0,i.setRangeValue)(e.duration)),void 0!==e.factor&&(this.factor=(0,i.setRangeValue)(e.factor)),void 0!==e.speed&&(this.speed=(0,i.setRangeValue)(e.speed)))}}class r extends a.ParticlesInteractorBase{constructor(e){super(e)}clear(){}init(){}interact(e){const t=this.container;if(!e.repulse){const s=e.options.repulse;if(!s)return;e.repulse={distance:(0,i.getRangeValue)(s.distance)*t.retina.pixelRatio,speed:(0,i.getRangeValue)(s.speed),factor:(0,i.getRangeValue)(s.factor)}}const s=e.getPosition(),a=t.particles.quadTree.queryCircle(s,e.repulse.distance);for(const t of a){if(e===t||t.destroyed)continue;const a=t.getPosition(),{dx:n,dy:r,distance:o}=(0,i.getDistances)(a,s),c=e.repulse.speed*e.repulse.factor;if(o>0){const s=(0,i.clamp)((1-Math.pow(o/e.repulse.distance,2))*c,0,c),a=i.Vector.create(n/o*s,r/o*s);t.position.addTo(a)}else{const e=i.Vector.create(c,c);t.position.addTo(e)}}}isEnabled(e){return e.options.repulse?.enabled??!1}loadParticlesOptions(e,...t){e.repulse??=new n;for(const s of t)e.repulse.load(s?.repulse)}reset(){}}}}]);
|
package/753.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Repulse Particles Interaction v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Repulse Particles Interaction v4.0.0-alpha.8 by Matteo Bruni */
|