@tsparticles/interaction-particles-repulse 4.0.0-alpha.25 → 4.0.0-alpha.26
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/321.min.js +1 -0
- package/browser/Repulser.js +14 -6
- package/browser/index.js +1 -1
- package/cjs/Repulser.js +14 -6
- package/cjs/index.js +1 -1
- package/dist_browser_Repulser_js.js +2 -2
- package/esm/Repulser.js +14 -6
- package/esm/index.js +1 -1
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.interaction.particles.repulse.js +2 -2
- package/tsparticles.interaction.particles.repulse.min.js +1 -1
- package/types/Repulser.d.ts +2 -0
- package/umd/Repulser.js +14 -6
- package/umd/index.js +1 -1
- package/309.min.js +0 -1
package/321.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_particles_repulse=this.webpackChunk_tsparticles_interaction_particles_repulse||[]).push([[321],{321(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/browser/Repulser.js
CHANGED
|
@@ -4,9 +4,13 @@ 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
6
|
_maxDistance;
|
|
7
|
+
_normVec;
|
|
8
|
+
_velocityVec;
|
|
7
9
|
constructor(container) {
|
|
8
10
|
super(container);
|
|
9
11
|
this._maxDistance = 0;
|
|
12
|
+
this._normVec = Vector.origin;
|
|
13
|
+
this._velocityVec = Vector.origin;
|
|
10
14
|
}
|
|
11
15
|
get maxDistance() {
|
|
12
16
|
return this._maxDistance;
|
|
@@ -32,19 +36,23 @@ export class Repulser extends ParticlesInteractorBase {
|
|
|
32
36
|
factor: getRangeValue(repulseOpt1.factor),
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance);
|
|
39
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
36
40
|
for (const p2 of query) {
|
|
37
41
|
if (p1 === p2 || p2.destroyed) {
|
|
38
42
|
continue;
|
|
39
43
|
}
|
|
40
|
-
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;
|
|
41
45
|
if (distance > minDistance) {
|
|
42
|
-
const repulseFactor = clamp((identity - Math.pow(distance
|
|
43
|
-
|
|
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);
|
|
44
51
|
}
|
|
45
52
|
else {
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
this._velocityVec.x = velocity;
|
|
54
|
+
this._velocityVec.y = velocity;
|
|
55
|
+
p2.position.addTo(this._velocityVec);
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadParticlesRepulseInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.26");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/cjs/Repulser.js
CHANGED
|
@@ -4,9 +4,13 @@ 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
6
|
_maxDistance;
|
|
7
|
+
_normVec;
|
|
8
|
+
_velocityVec;
|
|
7
9
|
constructor(container) {
|
|
8
10
|
super(container);
|
|
9
11
|
this._maxDistance = 0;
|
|
12
|
+
this._normVec = Vector.origin;
|
|
13
|
+
this._velocityVec = Vector.origin;
|
|
10
14
|
}
|
|
11
15
|
get maxDistance() {
|
|
12
16
|
return this._maxDistance;
|
|
@@ -32,19 +36,23 @@ export class Repulser extends ParticlesInteractorBase {
|
|
|
32
36
|
factor: getRangeValue(repulseOpt1.factor),
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance);
|
|
39
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
36
40
|
for (const p2 of query) {
|
|
37
41
|
if (p1 === p2 || p2.destroyed) {
|
|
38
42
|
continue;
|
|
39
43
|
}
|
|
40
|
-
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;
|
|
41
45
|
if (distance > minDistance) {
|
|
42
|
-
const repulseFactor = clamp((identity - Math.pow(distance
|
|
43
|
-
|
|
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);
|
|
44
51
|
}
|
|
45
52
|
else {
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
this._velocityVec.x = velocity;
|
|
54
|
+
this._velocityVec.y = velocity;
|
|
55
|
+
p2.position.addTo(this._velocityVec);
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadParticlesRepulseInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.26");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
@@ -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-alpha.
|
|
7
|
+
* v4.0.0-alpha.26
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -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, identity = 1, squareExp = 2, minVelocity = 0;\nclass Repulser extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.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) {\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);\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), 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
|
|
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
|
@@ -4,9 +4,13 @@ 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
6
|
_maxDistance;
|
|
7
|
+
_normVec;
|
|
8
|
+
_velocityVec;
|
|
7
9
|
constructor(container) {
|
|
8
10
|
super(container);
|
|
9
11
|
this._maxDistance = 0;
|
|
12
|
+
this._normVec = Vector.origin;
|
|
13
|
+
this._velocityVec = Vector.origin;
|
|
10
14
|
}
|
|
11
15
|
get maxDistance() {
|
|
12
16
|
return this._maxDistance;
|
|
@@ -32,19 +36,23 @@ export class Repulser extends ParticlesInteractorBase {
|
|
|
32
36
|
factor: getRangeValue(repulseOpt1.factor),
|
|
33
37
|
};
|
|
34
38
|
}
|
|
35
|
-
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance);
|
|
39
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
36
40
|
for (const p2 of query) {
|
|
37
41
|
if (p1 === p2 || p2.destroyed) {
|
|
38
42
|
continue;
|
|
39
43
|
}
|
|
40
|
-
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;
|
|
41
45
|
if (distance > minDistance) {
|
|
42
|
-
const repulseFactor = clamp((identity - Math.pow(distance
|
|
43
|
-
|
|
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);
|
|
44
51
|
}
|
|
45
52
|
else {
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
this._velocityVec.x = velocity;
|
|
54
|
+
this._velocityVec.y = velocity;
|
|
55
|
+
p2.position.addTo(this._velocityVec);
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadParticlesRepulseInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.26");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-particles-repulse",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.26",
|
|
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-alpha.
|
|
105
|
-
"@tsparticles/plugin-interactivity": "4.0.0-alpha.
|
|
104
|
+
"@tsparticles/engine": "4.0.0-alpha.26",
|
|
105
|
+
"@tsparticles/plugin-interactivity": "4.0.0-alpha.26"
|
|
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 [26 Feb 2026 at 18:08]</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-alpha.
|
|
7
|
+
* v4.0.0-alpha.26
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -54,7 +54,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
|
|
|
54
54
|
\*******************************/
|
|
55
55
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
56
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-alpha.
|
|
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-alpha.26\");\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
58
|
|
|
59
59
|
/***/ }
|
|
60
60
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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-alpha.
|
|
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-alpha.26"),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(321).then(s.bind(s,321));return new t(e)})})}return s.r(h),s.d(h,{loadParticlesRepulseInteraction:()=>g}),h})());
|
package/types/Repulser.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ type RepulseParticle = Particle & {
|
|
|
11
11
|
};
|
|
12
12
|
export declare class Repulser extends ParticlesInteractorBase {
|
|
13
13
|
private _maxDistance;
|
|
14
|
+
private readonly _normVec;
|
|
15
|
+
private readonly _velocityVec;
|
|
14
16
|
constructor(container: InteractivityContainer);
|
|
15
17
|
get maxDistance(): number;
|
|
16
18
|
clear(): void;
|
package/umd/Repulser.js
CHANGED
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
const minDistance = 0, identity = 1, squareExp = 2, minVelocity = 0;
|
|
17
17
|
class Repulser extends plugin_interactivity_1.ParticlesInteractorBase {
|
|
18
18
|
_maxDistance;
|
|
19
|
+
_normVec;
|
|
20
|
+
_velocityVec;
|
|
19
21
|
constructor(container) {
|
|
20
22
|
super(container);
|
|
21
23
|
this._maxDistance = 0;
|
|
24
|
+
this._normVec = engine_1.Vector.origin;
|
|
25
|
+
this._velocityVec = engine_1.Vector.origin;
|
|
22
26
|
}
|
|
23
27
|
get maxDistance() {
|
|
24
28
|
return this._maxDistance;
|
|
@@ -44,19 +48,23 @@
|
|
|
44
48
|
factor: (0, engine_1.getRangeValue)(repulseOpt1.factor),
|
|
45
49
|
};
|
|
46
50
|
}
|
|
47
|
-
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance);
|
|
51
|
+
const pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, p1.repulse.distance), p1DistanceFactor = identity / p1.repulse.distance;
|
|
48
52
|
for (const p2 of query) {
|
|
49
53
|
if (p1 === p2 || p2.destroyed) {
|
|
50
54
|
continue;
|
|
51
55
|
}
|
|
52
|
-
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;
|
|
53
57
|
if (distance > minDistance) {
|
|
54
|
-
const repulseFactor = (0, engine_1.clamp)((identity - Math.pow(distance
|
|
55
|
-
|
|
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);
|
|
56
63
|
}
|
|
57
64
|
else {
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
this._velocityVec.x = velocity;
|
|
66
|
+
this._velocityVec.y = velocity;
|
|
67
|
+
p2.position.addTo(this._velocityVec);
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
}
|
package/umd/index.js
CHANGED
|
@@ -45,7 +45,7 @@ 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-alpha.
|
|
48
|
+
engine.checkVersion("4.0.0-alpha.26");
|
|
49
49
|
await engine.register(async (e) => {
|
|
50
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
51
|
ensureInteractivityPluginLoaded(e);
|
package/309.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_interaction_particles_repulse=this.webpackChunk_tsparticles_interaction_particles_repulse||[]).push([[309],{309(e,t,s){s.d(t,{Repulser:()=>n});var a=s(702),i=s(303);class r extends i.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,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 n extends a.ParticlesInteractorBase{_maxDistance;constructor(e){super(e),this._maxDistance=0}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 a=(0,i.getRangeValue)(s.distance);a>this.maxDistance&&(this._maxDistance=a),e.repulse={distance:a*t.retina.pixelRatio,speed:(0,i.getRangeValue)(s.speed),factor:(0,i.getRangeValue)(s.factor)}}let s=e.getPosition();for(let a of t.particles.grid.queryCircle(s,e.repulse.distance)){if(e===a||a.destroyed)continue;let t=a.getPosition(),{dx:r,dy:n,distance:l}=(0,i.getDistances)(t,s),o=e.repulse.speed*e.repulse.factor;if(l>0){let t=(0,i.clamp)((1-Math.pow(l/e.repulse.distance,2))*o,0,o),s=i.Vector.create(r/l*t,n/l*t);a.position.addTo(s)}else{let e=i.Vector.create(o,o);a.position.addTo(e)}}}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(){}}}}]);
|