@tsparticles/interaction-particles-attract 4.0.0-alpha.25 → 4.0.0-alpha.27
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/356.min.js +1 -0
- package/browser/Attractor.js +14 -4
- package/browser/Options/Classes/Attract.js +35 -0
- package/browser/index.js +1 -1
- package/cjs/Attractor.js +14 -4
- package/cjs/Options/Classes/Attract.js +35 -0
- package/cjs/Types.js +1 -0
- package/cjs/index.js +1 -1
- package/dist_browser_Attractor_js.js +12 -2
- package/esm/Attractor.js +14 -4
- package/esm/Options/Classes/Attract.js +35 -0
- package/esm/Options/Interfaces/IAttract.js +1 -0
- package/esm/Types.js +1 -0
- package/esm/index.js +1 -1
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.interaction.particles.attract.js +8 -8
- package/tsparticles.interaction.particles.attract.min.js +1 -1
- package/types/Attractor.d.ts +4 -3
- package/types/Options/Classes/Attract.d.ts +9 -0
- package/types/Options/Interfaces/IAttract.d.ts +6 -0
- package/types/Types.d.ts +13 -0
- package/umd/Attractor.js +15 -5
- package/umd/Options/Classes/Attract.js +49 -0
- package/umd/Types.js +12 -0
- package/umd/index.js +1 -1
- package/360.min.js +0 -1
- package/types/AttractParticle.d.ts +0 -4
- /package/browser/{AttractParticle.js → Options/Interfaces/IAttract.js} +0 -0
- /package/{cjs/AttractParticle.js → browser/Types.js} +0 -0
- /package/{esm/AttractParticle.js → cjs/Options/Interfaces/IAttract.js} +0 -0
- /package/umd/{AttractParticle.js → Options/Interfaces/IAttract.js} +0 -0
package/356.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).push([[356],{356(t,e,a){a.d(e,{Attractor:()=>c});var i=a(303);class s{distance;enable;rotate;constructor(){this.distance=200,this.enable=!1,this.rotate={x:3e3,y:3e3}}load(t){if(!(0,i.isNull)(t)&&(void 0!==t.distance&&(this.distance=(0,i.setRangeValue)(t.distance)),void 0!==t.enable&&(this.enable=t.enable),t.rotate)){let e=t.rotate.x;void 0!==e&&(this.rotate.x=e);let a=t.rotate.y;void 0!==a&&(this.rotate.y=a)}}}var r=a(702);class c extends r.ParticlesInteractorBase{_maxDistance;constructor(t){super(t),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(){}init(){}interact(t){if(!t.options.attract?.enable)return;let e=this.container;if((0,i.isNull)(t.attractDistance)){let a=(0,i.getRangeValue)(t.options.attract.distance);a>this._maxDistance&&(this._maxDistance=a),t.attractDistance=a*e.retina.pixelRatio}let a=t.attractDistance,s=t.getPosition();for(let r of e.particles.grid.queryCircle(s,a)){if(t===r||!r.options.attract?.enable||r.destroyed||r.spawning)continue;let e=r.getPosition(),{dx:a,dy:c}=(0,i.getDistances)(s,e),n=t.options.attract.rotate,o=a/(1e3*n.x),l=c/(1e3*n.y),d=r.size.value/t.size.value,u=1/d;t.velocity.x-=o*d,t.velocity.y-=l*d,r.velocity.x+=o*u,r.velocity.y+=l*u}}isEnabled(t){return t.options.attract?.enable??!1}loadParticlesOptions(t,...e){for(let a of(t.attract??=new s,e))t.attract.load(a?.attract)}reset(){}}}}]);
|
package/browser/Attractor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getDistances, getRangeValue, isNull } from "@tsparticles/engine";
|
|
2
|
+
import { Attract } from "./Options/Classes/Attract.js";
|
|
2
3
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
4
|
const attractFactor = 1000, identity = 1;
|
|
4
5
|
export class Attractor extends ParticlesInteractorBase {
|
|
@@ -15,9 +16,12 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
15
16
|
init() {
|
|
16
17
|
}
|
|
17
18
|
interact(p1) {
|
|
19
|
+
if (!p1.options.attract?.enable) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
const container = this.container;
|
|
19
23
|
if (isNull(p1.attractDistance)) {
|
|
20
|
-
const attractDistance = getRangeValue(p1.options.
|
|
24
|
+
const attractDistance = getRangeValue(p1.options.attract.distance);
|
|
21
25
|
if (attractDistance > this._maxDistance) {
|
|
22
26
|
this._maxDistance = attractDistance;
|
|
23
27
|
}
|
|
@@ -25,10 +29,10 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
25
29
|
}
|
|
26
30
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, distance);
|
|
27
31
|
for (const p2 of query) {
|
|
28
|
-
if (p1 === p2 || !p2.options.
|
|
32
|
+
if (p1 === p2 || !p2.options.attract?.enable || p2.destroyed || p2.spawning) {
|
|
29
33
|
continue;
|
|
30
34
|
}
|
|
31
|
-
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.
|
|
35
|
+
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;
|
|
32
36
|
p1.velocity.x -= ax * p1Factor;
|
|
33
37
|
p1.velocity.y -= ay * p1Factor;
|
|
34
38
|
p2.velocity.x += ax * p2Factor;
|
|
@@ -36,7 +40,13 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
isEnabled(particle) {
|
|
39
|
-
return particle.options.
|
|
43
|
+
return particle.options.attract?.enable ?? false;
|
|
44
|
+
}
|
|
45
|
+
loadParticlesOptions(options, ...sources) {
|
|
46
|
+
options.attract ??= new Attract();
|
|
47
|
+
for (const source of sources) {
|
|
48
|
+
options.attract.load(source?.attract);
|
|
49
|
+
}
|
|
40
50
|
}
|
|
41
51
|
reset() {
|
|
42
52
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
export class Attract {
|
|
3
|
+
distance;
|
|
4
|
+
enable;
|
|
5
|
+
rotate;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.distance = 200;
|
|
8
|
+
this.enable = false;
|
|
9
|
+
this.rotate = {
|
|
10
|
+
x: 3000,
|
|
11
|
+
y: 3000,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
load(data) {
|
|
15
|
+
if (isNull(data)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (data.distance !== undefined) {
|
|
19
|
+
this.distance = setRangeValue(data.distance);
|
|
20
|
+
}
|
|
21
|
+
if (data.enable !== undefined) {
|
|
22
|
+
this.enable = data.enable;
|
|
23
|
+
}
|
|
24
|
+
if (data.rotate) {
|
|
25
|
+
const rotateX = data.rotate.x;
|
|
26
|
+
if (rotateX !== undefined) {
|
|
27
|
+
this.rotate.x = rotateX;
|
|
28
|
+
}
|
|
29
|
+
const rotateY = data.rotate.y;
|
|
30
|
+
if (rotateY !== undefined) {
|
|
31
|
+
this.rotate.y = rotateY;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadParticlesAttractInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.27");
|
|
3
3
|
await engine.register(async (e) => {
|
|
4
4
|
const { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
package/cjs/Attractor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getDistances, getRangeValue, isNull } from "@tsparticles/engine";
|
|
2
|
+
import { Attract } from "./Options/Classes/Attract.js";
|
|
2
3
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
4
|
const attractFactor = 1000, identity = 1;
|
|
4
5
|
export class Attractor extends ParticlesInteractorBase {
|
|
@@ -15,9 +16,12 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
15
16
|
init() {
|
|
16
17
|
}
|
|
17
18
|
interact(p1) {
|
|
19
|
+
if (!p1.options.attract?.enable) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
const container = this.container;
|
|
19
23
|
if (isNull(p1.attractDistance)) {
|
|
20
|
-
const attractDistance = getRangeValue(p1.options.
|
|
24
|
+
const attractDistance = getRangeValue(p1.options.attract.distance);
|
|
21
25
|
if (attractDistance > this._maxDistance) {
|
|
22
26
|
this._maxDistance = attractDistance;
|
|
23
27
|
}
|
|
@@ -25,10 +29,10 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
25
29
|
}
|
|
26
30
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, distance);
|
|
27
31
|
for (const p2 of query) {
|
|
28
|
-
if (p1 === p2 || !p2.options.
|
|
32
|
+
if (p1 === p2 || !p2.options.attract?.enable || p2.destroyed || p2.spawning) {
|
|
29
33
|
continue;
|
|
30
34
|
}
|
|
31
|
-
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.
|
|
35
|
+
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;
|
|
32
36
|
p1.velocity.x -= ax * p1Factor;
|
|
33
37
|
p1.velocity.y -= ay * p1Factor;
|
|
34
38
|
p2.velocity.x += ax * p2Factor;
|
|
@@ -36,7 +40,13 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
isEnabled(particle) {
|
|
39
|
-
return particle.options.
|
|
43
|
+
return particle.options.attract?.enable ?? false;
|
|
44
|
+
}
|
|
45
|
+
loadParticlesOptions(options, ...sources) {
|
|
46
|
+
options.attract ??= new Attract();
|
|
47
|
+
for (const source of sources) {
|
|
48
|
+
options.attract.load(source?.attract);
|
|
49
|
+
}
|
|
40
50
|
}
|
|
41
51
|
reset() {
|
|
42
52
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
export class Attract {
|
|
3
|
+
distance;
|
|
4
|
+
enable;
|
|
5
|
+
rotate;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.distance = 200;
|
|
8
|
+
this.enable = false;
|
|
9
|
+
this.rotate = {
|
|
10
|
+
x: 3000,
|
|
11
|
+
y: 3000,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
load(data) {
|
|
15
|
+
if (isNull(data)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (data.distance !== undefined) {
|
|
19
|
+
this.distance = setRangeValue(data.distance);
|
|
20
|
+
}
|
|
21
|
+
if (data.enable !== undefined) {
|
|
22
|
+
this.enable = data.enable;
|
|
23
|
+
}
|
|
24
|
+
if (data.rotate) {
|
|
25
|
+
const rotateX = data.rotate.x;
|
|
26
|
+
if (rotateX !== undefined) {
|
|
27
|
+
this.rotate.x = rotateX;
|
|
28
|
+
}
|
|
29
|
+
const rotateY = data.rotate.y;
|
|
30
|
+
if (rotateY !== undefined) {
|
|
31
|
+
this.rotate.y = rotateY;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/cjs/Types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadParticlesAttractInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.27");
|
|
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.27
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,17 @@
|
|
|
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 */ Attractor: () => (/* binding */ Attractor)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attractor: () => (/* binding */ Attractor)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Attract.js */ \"./dist/browser/Options/Classes/Attract.js\");\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n\n\n\nconst attractFactor = 1000, identity = 1;\nclass Attractor extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_2__.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 if (!p1.options.attract?.enable) {\n return;\n }\n const container = this.container;\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(p1.attractDistance)) {\n const attractDistance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(p1.options.attract.distance);\n if (attractDistance > this._maxDistance) {\n this._maxDistance = attractDistance;\n }\n p1.attractDistance = attractDistance * container.retina.pixelRatio;\n }\n const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, distance);\n for (const p2 of query){\n if (p1 === p2 || !p2.options.attract?.enable || p2.destroyed || p2.spawning) {\n continue;\n }\n const pos2 = p2.getPosition(), { dx, dy } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(pos1, pos2), rotate = p1.options.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;\n p1.velocity.x -= ax * p1Factor;\n p1.velocity.y -= ay * p1Factor;\n p2.velocity.x += ax * p2Factor;\n p2.velocity.y += ay * p2Factor;\n }\n }\n isEnabled(particle) {\n return particle.options.attract?.enable ?? false;\n }\n loadParticlesOptions(options, ...sources) {\n options.attract ??= new _Options_Classes_Attract_js__WEBPACK_IMPORTED_MODULE_1__.Attract();\n for (const source of sources){\n options.attract.load(source?.attract);\n }\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-attract/./dist/browser/Attractor.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Options/Classes/Attract.js"
|
|
31
|
+
/*!*************************************************!*\
|
|
32
|
+
!*** ./dist/browser/Options/Classes/Attract.js ***!
|
|
33
|
+
\*************************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Attract: () => (/* binding */ Attract)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass Attract {\n distance;\n enable;\n rotate;\n constructor(){\n this.distance = 200;\n this.enable = false;\n this.rotate = {\n x: 3000,\n y: 3000\n };\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.distance !== undefined) {\n this.distance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.distance);\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.rotate) {\n const rotateX = data.rotate.x;\n if (rotateX !== undefined) {\n this.rotate.x = rotateX;\n }\n const rotateY = data.rotate.y;\n if (rotateY !== undefined) {\n this.rotate.y = rotateY;\n }\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-attract/./dist/browser/Options/Classes/Attract.js?\n}");
|
|
27
37
|
|
|
28
38
|
/***/ }
|
|
29
39
|
|
package/esm/Attractor.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getDistances, getRangeValue, isNull } from "@tsparticles/engine";
|
|
2
|
+
import { Attract } from "./Options/Classes/Attract.js";
|
|
2
3
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
3
4
|
const attractFactor = 1000, identity = 1;
|
|
4
5
|
export class Attractor extends ParticlesInteractorBase {
|
|
@@ -15,9 +16,12 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
15
16
|
init() {
|
|
16
17
|
}
|
|
17
18
|
interact(p1) {
|
|
19
|
+
if (!p1.options.attract?.enable) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
18
22
|
const container = this.container;
|
|
19
23
|
if (isNull(p1.attractDistance)) {
|
|
20
|
-
const attractDistance = getRangeValue(p1.options.
|
|
24
|
+
const attractDistance = getRangeValue(p1.options.attract.distance);
|
|
21
25
|
if (attractDistance > this._maxDistance) {
|
|
22
26
|
this._maxDistance = attractDistance;
|
|
23
27
|
}
|
|
@@ -25,10 +29,10 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
25
29
|
}
|
|
26
30
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, distance);
|
|
27
31
|
for (const p2 of query) {
|
|
28
|
-
if (p1 === p2 || !p2.options.
|
|
32
|
+
if (p1 === p2 || !p2.options.attract?.enable || p2.destroyed || p2.spawning) {
|
|
29
33
|
continue;
|
|
30
34
|
}
|
|
31
|
-
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.
|
|
35
|
+
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;
|
|
32
36
|
p1.velocity.x -= ax * p1Factor;
|
|
33
37
|
p1.velocity.y -= ay * p1Factor;
|
|
34
38
|
p2.velocity.x += ax * p2Factor;
|
|
@@ -36,7 +40,13 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
isEnabled(particle) {
|
|
39
|
-
return particle.options.
|
|
43
|
+
return particle.options.attract?.enable ?? false;
|
|
44
|
+
}
|
|
45
|
+
loadParticlesOptions(options, ...sources) {
|
|
46
|
+
options.attract ??= new Attract();
|
|
47
|
+
for (const source of sources) {
|
|
48
|
+
options.attract.load(source?.attract);
|
|
49
|
+
}
|
|
40
50
|
}
|
|
41
51
|
reset() {
|
|
42
52
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
export class Attract {
|
|
3
|
+
distance;
|
|
4
|
+
enable;
|
|
5
|
+
rotate;
|
|
6
|
+
constructor() {
|
|
7
|
+
this.distance = 200;
|
|
8
|
+
this.enable = false;
|
|
9
|
+
this.rotate = {
|
|
10
|
+
x: 3000,
|
|
11
|
+
y: 3000,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
load(data) {
|
|
15
|
+
if (isNull(data)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (data.distance !== undefined) {
|
|
19
|
+
this.distance = setRangeValue(data.distance);
|
|
20
|
+
}
|
|
21
|
+
if (data.enable !== undefined) {
|
|
22
|
+
this.enable = data.enable;
|
|
23
|
+
}
|
|
24
|
+
if (data.rotate) {
|
|
25
|
+
const rotateX = data.rotate.x;
|
|
26
|
+
if (rotateX !== undefined) {
|
|
27
|
+
this.rotate.x = rotateX;
|
|
28
|
+
}
|
|
29
|
+
const rotateY = data.rotate.y;
|
|
30
|
+
if (rotateY !== undefined) {
|
|
31
|
+
this.rotate.y = rotateY;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/Types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadParticlesAttractInteraction(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.27");
|
|
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-attract",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.27",
|
|
4
4
|
"description": "tsParticles attract particles interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "4.0.0-alpha.
|
|
91
|
-
"@tsparticles/plugin-interactivity": "4.0.0-alpha.
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.27",
|
|
91
|
+
"@tsparticles/plugin-interactivity": "4.0.0-alpha.27"
|
|
92
92
|
},
|
|
93
93
|
"publishConfig": {
|
|
94
94
|
"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-attract [
|
|
6
|
+
<title>@tsparticles/interaction-particles-attract [9 Mar 2026 at 17:23]</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.27
|
|
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 */ loadParticlesAttractInteraction: () => (/* binding */ loadParticlesAttractInteraction)\n/* harmony export */ });\nasync function loadParticlesAttractInteraction(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 */ loadParticlesAttractInteraction: () => (/* binding */ loadParticlesAttractInteraction)\n/* harmony export */ });\nasync function loadParticlesAttractInteraction(engine) {\n engine.checkVersion(\"4.0.0-alpha.27\");\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?.(\"particlesAttract\", async (container)=>{\n const { Attractor } = await __webpack_require__.e(/*! import() */ \"dist_browser_Attractor_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Attractor.js */ \"./dist/browser/Attractor.js\"));\n return new Attractor(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-attract/./dist/browser/index.js?\n}");
|
|
58
58
|
|
|
59
59
|
/***/ }
|
|
60
60
|
|
|
@@ -70,12 +70,6 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
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 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
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
|
|
@@ -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 c(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return n[e](r,r.exports,c),r.exports}c.m=n,p=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,p({}),p([]),p(p)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~s.indexOf(o);o=p(o))Object.getOwnPropertyNames(o).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),l={},c.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"),s=0;s<a.length;s++){var p=a[s];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/interaction-particles-attract:"+r){o=p;break}}o||(n=!0,(o=document.createElement("script")).charset="utf-8",c.nc&&o.setAttribute("nonce",c.nc),o.setAttribute("data-webpack","@tsparticles/interaction-particles-attract:"+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)},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,p,l,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={807: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 o=new Promise((t,o)=>i=r[e]=[t,o]);t.push(i[2]=o);var n=c.p+c.u(e),a=Error();c.l(n,t=>{if(c.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,s]=t,p=0;if(n.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);p<n.length;p++)o=n[p],c.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).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,s]=t,p=0;if(n.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);p<n.length;p++)o=n[p],c.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).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.27"),await e.register(async e=>{let{ensureInteractivityPluginLoaded:t}=await Promise.resolve().then(c.t.bind(c,702,19));t(e),e.addInteractor?.("particlesAttract",async e=>{let{Attractor:t}=await c.e(356).then(c.bind(c,356));return new t(e)})})}return c.r(h),c.d(h,{loadParticlesAttractInteraction:()=>g}),h})());
|
package/types/Attractor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
1
|
+
import type { AttractParticle, IParticlesAttractOptions, ParticlesAttractOptions } from "./Types.js";
|
|
2
|
+
import { type Container, type RecursivePartial } from "@tsparticles/engine";
|
|
3
3
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
4
4
|
export declare class Attractor extends ParticlesInteractorBase<Container, AttractParticle> {
|
|
5
5
|
private _maxDistance;
|
|
@@ -8,6 +8,7 @@ export declare class Attractor extends ParticlesInteractorBase<Container, Attrac
|
|
|
8
8
|
clear(): void;
|
|
9
9
|
init(): void;
|
|
10
10
|
interact(p1: AttractParticle): void;
|
|
11
|
-
isEnabled(particle:
|
|
11
|
+
isEnabled(particle: AttractParticle): boolean;
|
|
12
|
+
loadParticlesOptions(options: ParticlesAttractOptions, ...sources: (RecursivePartial<IParticlesAttractOptions> | undefined)[]): void;
|
|
12
13
|
reset(): void;
|
|
13
14
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ICoordinates, type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IAttract } from "../Interfaces/IAttract.js";
|
|
3
|
+
export declare class Attract implements IAttract, IOptionLoader<IAttract> {
|
|
4
|
+
distance: RangeValue;
|
|
5
|
+
enable: boolean;
|
|
6
|
+
rotate: ICoordinates;
|
|
7
|
+
constructor();
|
|
8
|
+
load(data?: RecursivePartial<IAttract>): void;
|
|
9
|
+
}
|
package/types/Types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IInteractivityParticlesOptions, InteractivityParticle, InteractivityParticlesOptions } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import type { Attract } from "./Options/Classes/Attract.js";
|
|
3
|
+
import type { IAttract } from "./Options/Interfaces/IAttract.js";
|
|
4
|
+
export type IParticlesAttractOptions = IInteractivityParticlesOptions & {
|
|
5
|
+
attract?: IAttract;
|
|
6
|
+
};
|
|
7
|
+
export type ParticlesAttractOptions = InteractivityParticlesOptions & {
|
|
8
|
+
attract?: Attract;
|
|
9
|
+
};
|
|
10
|
+
export type AttractParticle = InteractivityParticle & {
|
|
11
|
+
attractDistance?: number;
|
|
12
|
+
options: ParticlesAttractOptions;
|
|
13
|
+
};
|
package/umd/Attractor.js
CHANGED
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "@tsparticles/plugin-interactivity"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Attract.js", "@tsparticles/plugin-interactivity"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Attractor = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Attract_js_1 = require("./Options/Classes/Attract.js");
|
|
14
15
|
const plugin_interactivity_1 = require("@tsparticles/plugin-interactivity");
|
|
15
16
|
const attractFactor = 1000, identity = 1;
|
|
16
17
|
class Attractor extends plugin_interactivity_1.ParticlesInteractorBase {
|
|
@@ -27,9 +28,12 @@
|
|
|
27
28
|
init() {
|
|
28
29
|
}
|
|
29
30
|
interact(p1) {
|
|
31
|
+
if (!p1.options.attract?.enable) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
30
34
|
const container = this.container;
|
|
31
35
|
if ((0, engine_1.isNull)(p1.attractDistance)) {
|
|
32
|
-
const attractDistance = (0, engine_1.getRangeValue)(p1.options.
|
|
36
|
+
const attractDistance = (0, engine_1.getRangeValue)(p1.options.attract.distance);
|
|
33
37
|
if (attractDistance > this._maxDistance) {
|
|
34
38
|
this._maxDistance = attractDistance;
|
|
35
39
|
}
|
|
@@ -37,10 +41,10 @@
|
|
|
37
41
|
}
|
|
38
42
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.grid.queryCircle(pos1, distance);
|
|
39
43
|
for (const p2 of query) {
|
|
40
|
-
if (p1 === p2 || !p2.options.
|
|
44
|
+
if (p1 === p2 || !p2.options.attract?.enable || p2.destroyed || p2.spawning) {
|
|
41
45
|
continue;
|
|
42
46
|
}
|
|
43
|
-
const pos2 = p2.getPosition(), { dx, dy } = (0, engine_1.getDistances)(pos1, pos2), rotate = p1.options.
|
|
47
|
+
const pos2 = p2.getPosition(), { dx, dy } = (0, engine_1.getDistances)(pos1, pos2), rotate = p1.options.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;
|
|
44
48
|
p1.velocity.x -= ax * p1Factor;
|
|
45
49
|
p1.velocity.y -= ay * p1Factor;
|
|
46
50
|
p2.velocity.x += ax * p2Factor;
|
|
@@ -48,7 +52,13 @@
|
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
isEnabled(particle) {
|
|
51
|
-
return particle.options.
|
|
55
|
+
return particle.options.attract?.enable ?? false;
|
|
56
|
+
}
|
|
57
|
+
loadParticlesOptions(options, ...sources) {
|
|
58
|
+
options.attract ??= new Attract_js_1.Attract();
|
|
59
|
+
for (const source of sources) {
|
|
60
|
+
options.attract.load(source?.attract);
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
reset() {
|
|
54
64
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Attract = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class Attract {
|
|
15
|
+
distance;
|
|
16
|
+
enable;
|
|
17
|
+
rotate;
|
|
18
|
+
constructor() {
|
|
19
|
+
this.distance = 200;
|
|
20
|
+
this.enable = false;
|
|
21
|
+
this.rotate = {
|
|
22
|
+
x: 3000,
|
|
23
|
+
y: 3000,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
load(data) {
|
|
27
|
+
if ((0, engine_1.isNull)(data)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (data.distance !== undefined) {
|
|
31
|
+
this.distance = (0, engine_1.setRangeValue)(data.distance);
|
|
32
|
+
}
|
|
33
|
+
if (data.enable !== undefined) {
|
|
34
|
+
this.enable = data.enable;
|
|
35
|
+
}
|
|
36
|
+
if (data.rotate) {
|
|
37
|
+
const rotateX = data.rotate.x;
|
|
38
|
+
if (rotateX !== undefined) {
|
|
39
|
+
this.rotate.x = rotateX;
|
|
40
|
+
}
|
|
41
|
+
const rotateY = data.rotate.y;
|
|
42
|
+
if (rotateY !== undefined) {
|
|
43
|
+
this.rotate.y = rotateY;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.Attract = Attract;
|
|
49
|
+
});
|
package/umd/Types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
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.loadParticlesAttractInteraction = loadParticlesAttractInteraction;
|
|
47
47
|
async function loadParticlesAttractInteraction(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-alpha.
|
|
48
|
+
engine.checkVersion("4.0.0-alpha.27");
|
|
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/360.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).push([[360],{360(t,e,a){a.d(e,{Attractor:()=>c});var i=a(303),s=a(702);class c extends s.ParticlesInteractorBase{_maxDistance;constructor(t){super(t),this._maxDistance=0}get maxDistance(){return this._maxDistance}clear(){}init(){}interact(t){let e=this.container;if((0,i.isNull)(t.attractDistance)){let a=(0,i.getRangeValue)(t.options.move.attract.distance);a>this._maxDistance&&(this._maxDistance=a),t.attractDistance=a*e.retina.pixelRatio}let a=t.attractDistance,s=t.getPosition();for(let c of e.particles.grid.queryCircle(s,a)){if(t===c||!c.options.move.attract.enable||c.destroyed||c.spawning)continue;let e=c.getPosition(),{dx:a,dy:n}=(0,i.getDistances)(s,e),r=t.options.move.attract.rotate,o=a/(1e3*r.x),l=n/(1e3*r.y),p=c.size.value/t.size.value,u=1/p;t.velocity.x-=o*p,t.velocity.y-=l*p,c.velocity.x+=o*u,c.velocity.y+=l*u}}isEnabled(t){return t.options.move.attract.enable}reset(){}}}}]);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|