@tsparticles/interaction-particles-attract 3.9.1 → 4.0.0-alpha.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/838.min.js +2 -0
- package/838.min.js.LICENSE.txt +1 -0
- package/browser/Attractor.js +1 -3
- package/browser/index.js +8 -6
- package/cjs/AttractParticle.js +1 -2
- package/cjs/Attractor.js +4 -10
- package/cjs/index.js +8 -9
- package/dist_browser_Attractor_js.js +30 -0
- package/esm/Attractor.js +1 -3
- package/esm/index.js +8 -6
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.interaction.particles.attract.js +209 -30
- package/tsparticles.interaction.particles.attract.min.js +1 -1
- package/tsparticles.interaction.particles.attract.min.js.LICENSE.txt +1 -1
- package/types/index.d.ts +1 -1
- package/umd/Attractor.js +1 -3
- package/umd/index.js +43 -7
package/838.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 838.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_interaction_particles_attract=this.webpackChunk_tsparticles_interaction_particles_attract||[]).push([[838],{838(t,e,a){a.d(e,{Attractor:()=>c});var i=a(303);class c extends i.ParticlesInteractorBase{constructor(t){super(t)}clear(){}init(){}interact(t){const e=this.container;t.attractDistance??=(0,i.getRangeValue)(t.options.move.attract.distance)*e.retina.pixelRatio;const a=t.attractDistance,c=t.getPosition(),s=e.particles.quadTree.queryCircle(c,a);for(const e of s){if(t===e||!e.options.move.attract.enable||e.destroyed||e.spawning)continue;const a=e.getPosition(),{dx:s,dy:n}=(0,i.getDistances)(c,a),o=t.options.move.attract.rotate,r=s/(1e3*o.x),l=n/(1e3*o.y),p=e.size.value/t.size.value,u=1/p;t.velocity.x-=r*p,t.velocity.y-=l*p,e.velocity.x+=r*u,e.velocity.y+=l*u}}isEnabled(t){return t.options.move.attract.enable}reset(){}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Attract Particles Interaction v4.0.0-alpha.0 by Matteo Bruni */
|
package/browser/Attractor.js
CHANGED
|
@@ -10,9 +10,7 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
10
10
|
}
|
|
11
11
|
interact(p1) {
|
|
12
12
|
const container = this.container;
|
|
13
|
-
|
|
14
|
-
p1.attractDistance = getRangeValue(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
15
|
-
}
|
|
13
|
+
p1.attractDistance ??= getRangeValue(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
16
14
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);
|
|
17
15
|
for (const p2 of query) {
|
|
18
16
|
if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadParticlesAttractInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("particlesAttract", async (container) => {
|
|
5
|
+
const { Attractor } = await import("./Attractor.js");
|
|
6
|
+
return new Attractor(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/cjs/AttractParticle.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Attractor.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Attractor = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
1
|
+
import { ParticlesInteractorBase, getDistances, getRangeValue, } from "@tsparticles/engine";
|
|
5
2
|
const attractFactor = 1000, identity = 1;
|
|
6
|
-
class Attractor extends
|
|
3
|
+
export class Attractor extends ParticlesInteractorBase {
|
|
7
4
|
constructor(container) {
|
|
8
5
|
super(container);
|
|
9
6
|
}
|
|
@@ -13,15 +10,13 @@ class Attractor extends engine_1.ParticlesInteractorBase {
|
|
|
13
10
|
}
|
|
14
11
|
interact(p1) {
|
|
15
12
|
const container = this.container;
|
|
16
|
-
|
|
17
|
-
p1.attractDistance = (0, engine_1.getRangeValue)(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
18
|
-
}
|
|
13
|
+
p1.attractDistance ??= getRangeValue(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
19
14
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);
|
|
20
15
|
for (const p2 of query) {
|
|
21
16
|
if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {
|
|
22
17
|
continue;
|
|
23
18
|
}
|
|
24
|
-
const pos2 = p2.getPosition(), { dx, dy } =
|
|
19
|
+
const pos2 = p2.getPosition(), { dx, dy } = getDistances(pos1, pos2), rotate = p1.options.move.attract.rotate, ax = dx / (rotate.x * attractFactor), ay = dy / (rotate.y * attractFactor), p1Factor = p2.size.value / p1.size.value, p2Factor = identity / p1Factor;
|
|
25
20
|
p1.velocity.x -= ax * p1Factor;
|
|
26
21
|
p1.velocity.y -= ay * p1Factor;
|
|
27
22
|
p2.velocity.x += ax * p2Factor;
|
|
@@ -34,4 +29,3 @@ class Attractor extends engine_1.ParticlesInteractorBase {
|
|
|
34
29
|
reset() {
|
|
35
30
|
}
|
|
36
31
|
}
|
|
37
|
-
exports.Attractor = Attractor;
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, refresh);
|
|
1
|
+
export function loadParticlesAttractInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("particlesAttract", async (container) => {
|
|
5
|
+
const { Attractor } = await import("./Attractor.js");
|
|
6
|
+
return new Attractor(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
10
9
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_interaction_particles_attract"] = this["webpackChunk_tsparticles_interaction_particles_attract"] || []).push([["dist_browser_Attractor_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Attractor.js"
|
|
21
|
+
/*!***********************************!*\
|
|
22
|
+
!*** ./dist/browser/Attractor.js ***!
|
|
23
|
+
\***********************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
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\nconst attractFactor = 1000,\n identity = 1;\nclass Attractor extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ParticlesInteractorBase {\n constructor(container) {\n super(container);\n }\n clear() {}\n init() {}\n interact(p1) {\n const container = this.container;\n p1.attractDistance ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(p1.options.move.attract.distance) * container.retina.pixelRatio;\n const distance = p1.attractDistance,\n pos1 = p1.getPosition(),\n query = container.particles.quadTree.queryCircle(pos1, distance);\n for (const p2 of query) {\n if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {\n continue;\n }\n const pos2 = p2.getPosition(),\n {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(pos1, pos2),\n rotate = p1.options.move.attract.rotate,\n ax = dx / (rotate.x * attractFactor),\n ay = dy / (rotate.y * attractFactor),\n p1Factor = p2.size.value / p1.size.value,\n 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.move.attract.enable;\n }\n reset() {}\n}\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-attract/./dist/browser/Attractor.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ }
|
|
29
|
+
|
|
30
|
+
}]);
|
package/esm/Attractor.js
CHANGED
|
@@ -10,9 +10,7 @@ export class Attractor extends ParticlesInteractorBase {
|
|
|
10
10
|
}
|
|
11
11
|
interact(p1) {
|
|
12
12
|
const container = this.container;
|
|
13
|
-
|
|
14
|
-
p1.attractDistance = getRangeValue(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
15
|
-
}
|
|
13
|
+
p1.attractDistance ??= getRangeValue(p1.options.move.attract.distance) * container.retina.pixelRatio;
|
|
16
14
|
const distance = p1.attractDistance, pos1 = p1.getPosition(), query = container.particles.quadTree.queryCircle(pos1, distance);
|
|
17
15
|
for (const p2 of query) {
|
|
18
16
|
if (p1 === p2 || !p2.options.move.attract.enable || p2.destroyed || p2.spawning) {
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadParticlesAttractInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addInteractor("particlesAttract", async (container) => {
|
|
5
|
+
const { Attractor } = await import("./Attractor.js");
|
|
6
|
+
return new Attractor(container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-particles-attract",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles attract particles interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,9 +87,10 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "
|
|
90
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
"type": "module"
|
|
95
96
|
}
|