@tsparticles/move-base 3.9.1 → 4.0.0-alpha.1
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/593.min.js +2 -0
- package/593.min.js.LICENSE.txt +1 -0
- package/browser/index.js +8 -6
- package/cjs/BaseMover.js +11 -15
- package/cjs/IParticleGravity.js +1 -2
- package/cjs/IParticleSpin.js +1 -2
- package/cjs/Types.js +1 -2
- package/cjs/Utils.js +16 -24
- package/cjs/index.js +8 -9
- package/dist_browser_BaseMover_js.js +40 -0
- package/esm/index.js +8 -6
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.move.base.js +209 -40
- package/tsparticles.move.base.min.js +1 -1
- package/tsparticles.move.base.min.js.LICENSE.txt +1 -1
- package/types/index.d.ts +1 -1
- package/umd/index.js +43 -7
package/593.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 593.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_move_base=this.webpackChunk_tsparticles_move_base||[]).push([[593],{593(e,i,t){t.d(i,{BaseMover:()=>s});var n=t(303);const a=2*Math.PI;function o(e,i,t,a,o,s,c){!function(e,i){const t=e.options,a=t.move.path;if(!a.enable)return;if(e.lastPathTime<=e.pathDelay)return void(e.lastPathTime+=i.value);const o=e.pathGenerator?.generate(e,i);o&&e.velocity.addTo(o);a.clamp&&(e.velocity.x=(0,n.clamp)(e.velocity.x,-1,1),e.velocity.y=(0,n.clamp)(e.velocity.y,-1,1));e.lastPathTime-=e.pathDelay}(e,c);const r=e.gravity,l=r?.enable&&r.inverse?-1:1;o&&t&&(e.velocity.x+=o*c.factor/(60*t)),r?.enable&&t&&(e.velocity.y+=l*(r.acceleration*c.factor)/(60*t));const p=e.moveDecay;e.velocity.multTo(p);const y=e.velocity.mult(t);r?.enable&&a>0&&(!r.inverse&&y.y>=0&&y.y>=a||r.inverse&&y.y<=0&&y.y<=-a)&&(y.y=l*a,t&&(e.velocity.y=y.y/t));const v=e.options.zIndex,d=(1-e.zIndexFactor)**v.velocityRate;y.multTo(d),y.multTo(s);const{position:u}=e;u.addTo(y),i.vibrate&&(u.x+=Math.sin(u.x*Math.cos(u.y))*s,u.y+=Math.cos(u.y*Math.sin(u.x))*s)}class s{init(e){const i=e.options.move.gravity;e.gravity={enable:i.enable,acceleration:(0,n.getRangeValue)(i.acceleration),inverse:i.inverse},function(e){const i=e.container,t=e.options.move.spin;if(!t.enable)return;const o=t.position??{x:50,y:50},s={x:.01*o.x*i.canvas.size.width,y:.01*o.y*i.canvas.size.height},c=e.getPosition(),r=(0,n.getDistance)(c,s),l=(0,n.getRangeValue)(t.acceleration);e.retina.spinAcceleration=l*i.retina.pixelRatio,e.spin={center:s,direction:e.velocity.x>=0?n.RotateDirection.clockwise:n.RotateDirection.counterClockwise,angle:(0,n.getRandom)()*a,radius:r,acceleration:e.retina.spinAcceleration}}(e)}isEnabled(e){return!e.destroyed&&e.options.move.enable}move(e,i){const t=e.options,a=t.move;if(!a.enable)return;const s=e.container,c=s.retina.pixelRatio;e.retina.moveSpeed??=(0,n.getRangeValue)(a.speed)*c,e.retina.moveDrift??=(0,n.getRangeValue)(e.options.move.drift)*c;const r=function(e){return e.slow.inRange?e.slow.factor:1}(e),l=s.retina.reduceFactor,p=e.retina.moveSpeed,y=e.retina.moveDrift,v=(0,n.getRangeMax)(t.size.value)*c,d=p*(a.size?e.getRadius()/v:1)*r*(i.factor||1)/2,u=e.retina.maxSpeed??s.retina.maxSpeed;a.spin.enable?function(e,i,t){const a=e.container;if(!e.spin)return;const o=e.spin.direction===n.RotateDirection.clockwise,s={x:o?Math.cos:Math.sin,y:o?Math.sin:Math.cos};e.position.x=e.spin.center.x+e.spin.radius*s.x(e.spin.angle)*t,e.position.y=e.spin.center.y+e.spin.radius*s.y(e.spin.angle)*t,e.spin.radius+=e.spin.acceleration*t;const c=Math.max(a.canvas.size.width,a.canvas.size.height),r=.5*c;e.spin.radius>r?(e.spin.radius=r,e.spin.acceleration*=-1):e.spin.radius<0&&(e.spin.radius=0,e.spin.acceleration*=-1),e.spin.angle+=.01*i*(1-e.spin.radius/c)}(e,d,l):o(e,a,d,u,y,l,i),function(e){const i=e.initialPosition,{dx:t,dy:a}=(0,n.getDistances)(i,e.position),o=Math.abs(t),s=Math.abs(a),{maxDistance:c}=e.retina,r=c.horizontal,l=c.vertical;if(!r&&!l)return;if((r&&o>=r||l&&s>=l)&&!e.misplaced)e.misplaced=!!r&&o>r||!!l&&s>l,r&&(e.velocity.x=.5*e.velocity.y-e.velocity.x),l&&(e.velocity.y=.5*e.velocity.x-e.velocity.y);else if((!r||o<r)&&(!l||s<l)&&e.misplaced)e.misplaced=!1;else if(e.misplaced){const t=e.position,a=e.velocity;r&&(t.x<i.x&&a.x<0||t.x>i.x&&a.x>0)&&(a.x*=-(0,n.getRandom)()),l&&(t.y<i.y&&a.y<0||t.y>i.y&&a.y>0)&&(a.y*=-(0,n.getRandom)())}}(e)}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Base Move v4.0.0-alpha.1 by Matteo Bruni */
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadBaseMover(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addMover("base", async () => {
|
|
5
|
+
const { BaseMover } = await import("./BaseMover.js");
|
|
6
|
+
return new BaseMover();
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/cjs/BaseMover.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BaseMover = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const Utils_js_1 = require("./Utils.js");
|
|
1
|
+
import { getRangeMax, getRangeValue } from "@tsparticles/engine";
|
|
2
|
+
import { applyDistance, getProximitySpeedFactor, initSpin, move, spin } from "./Utils.js";
|
|
6
3
|
const diffFactor = 2, defaultSizeFactor = 1, defaultDeltaFactor = 1;
|
|
7
|
-
class BaseMover {
|
|
4
|
+
export class BaseMover {
|
|
8
5
|
init(particle) {
|
|
9
6
|
const options = particle.options, gravityOptions = options.move.gravity;
|
|
10
7
|
particle.gravity = {
|
|
11
8
|
enable: gravityOptions.enable,
|
|
12
|
-
acceleration:
|
|
9
|
+
acceleration: getRangeValue(gravityOptions.acceleration),
|
|
13
10
|
inverse: gravityOptions.inverse,
|
|
14
11
|
};
|
|
15
|
-
|
|
12
|
+
initSpin(particle);
|
|
16
13
|
}
|
|
17
14
|
isEnabled(particle) {
|
|
18
15
|
return !particle.destroyed && particle.options.move.enable;
|
|
@@ -23,16 +20,15 @@ class BaseMover {
|
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
22
|
const container = particle.container, pxRatio = container.retina.pixelRatio;
|
|
26
|
-
particle.retina.moveSpeed ??=
|
|
27
|
-
particle.retina.moveDrift ??=
|
|
28
|
-
const slowFactor =
|
|
23
|
+
particle.retina.moveSpeed ??= getRangeValue(moveOptions.speed) * pxRatio;
|
|
24
|
+
particle.retina.moveDrift ??= getRangeValue(particle.options.move.drift) * pxRatio;
|
|
25
|
+
const slowFactor = getProximitySpeedFactor(particle), reduceFactor = container.retina.reduceFactor, baseSpeed = particle.retina.moveSpeed, moveDrift = particle.retina.moveDrift, maxSize = getRangeMax(particleOptions.size.value) * pxRatio, sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor, deltaFactor = delta.factor || defaultDeltaFactor, moveSpeed = (baseSpeed * sizeFactor * slowFactor * deltaFactor) / diffFactor, maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;
|
|
29
26
|
if (moveOptions.spin.enable) {
|
|
30
|
-
|
|
27
|
+
spin(particle, moveSpeed, reduceFactor);
|
|
31
28
|
}
|
|
32
29
|
else {
|
|
33
|
-
|
|
30
|
+
move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
applyDistance(particle);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
exports.BaseMover = BaseMover;
|
package/cjs/IParticleGravity.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/IParticleSpin.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Utils.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyDistance = applyDistance;
|
|
4
|
-
exports.move = move;
|
|
5
|
-
exports.spin = spin;
|
|
6
|
-
exports.applyPath = applyPath;
|
|
7
|
-
exports.getProximitySpeedFactor = getProximitySpeedFactor;
|
|
8
|
-
exports.initSpin = initSpin;
|
|
9
|
-
const engine_1 = require("@tsparticles/engine");
|
|
1
|
+
import { RotateDirection, clamp, getDistance, getDistances, getRandom, getRangeValue, } from "@tsparticles/engine";
|
|
10
2
|
const half = 0.5, double = 2, minVelocity = 0, identity = 1, moveSpeedFactor = 60, minSpinRadius = 0, spinFactor = 0.01, doublePI = Math.PI * double;
|
|
11
|
-
function applyDistance(particle) {
|
|
12
|
-
const initialPosition = particle.initialPosition, { dx, dy } =
|
|
3
|
+
export function applyDistance(particle) {
|
|
4
|
+
const initialPosition = particle.initialPosition, { dx, dy } = getDistances(initialPosition, particle.position), dxFixed = Math.abs(dx), dyFixed = Math.abs(dy), { maxDistance } = particle.retina, hDistance = maxDistance.horizontal, vDistance = maxDistance.vertical;
|
|
13
5
|
if (!hDistance && !vDistance) {
|
|
14
6
|
return;
|
|
15
7
|
}
|
|
@@ -30,15 +22,15 @@ function applyDistance(particle) {
|
|
|
30
22
|
const pos = particle.position, vel = particle.velocity;
|
|
31
23
|
if (hDistance &&
|
|
32
24
|
((pos.x < initialPosition.x && vel.x < minVelocity) || (pos.x > initialPosition.x && vel.x > minVelocity))) {
|
|
33
|
-
vel.x *= -
|
|
25
|
+
vel.x *= -getRandom();
|
|
34
26
|
}
|
|
35
27
|
if (vDistance &&
|
|
36
28
|
((pos.y < initialPosition.y && vel.y < minVelocity) || (pos.y > initialPosition.y && vel.y > minVelocity))) {
|
|
37
|
-
vel.y *= -
|
|
29
|
+
vel.y *= -getRandom();
|
|
38
30
|
}
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
|
-
function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
|
|
33
|
+
export function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {
|
|
42
34
|
applyPath(particle, delta);
|
|
43
35
|
const gravityOptions = particle.gravity, gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;
|
|
44
36
|
if (moveDrift && moveSpeed) {
|
|
@@ -70,12 +62,12 @@ function move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFacto
|
|
|
70
62
|
position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;
|
|
71
63
|
}
|
|
72
64
|
}
|
|
73
|
-
function spin(particle, moveSpeed, reduceFactor) {
|
|
65
|
+
export function spin(particle, moveSpeed, reduceFactor) {
|
|
74
66
|
const container = particle.container;
|
|
75
67
|
if (!particle.spin) {
|
|
76
68
|
return;
|
|
77
69
|
}
|
|
78
|
-
const spinClockwise = particle.spin.direction ===
|
|
70
|
+
const spinClockwise = particle.spin.direction === RotateDirection.clockwise, updateFunc = {
|
|
79
71
|
x: spinClockwise ? Math.cos : Math.sin,
|
|
80
72
|
y: spinClockwise ? Math.sin : Math.cos,
|
|
81
73
|
};
|
|
@@ -95,7 +87,7 @@ function spin(particle, moveSpeed, reduceFactor) {
|
|
|
95
87
|
}
|
|
96
88
|
particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);
|
|
97
89
|
}
|
|
98
|
-
function applyPath(particle, delta) {
|
|
90
|
+
export function applyPath(particle, delta) {
|
|
99
91
|
const particlesOptions = particle.options, pathOptions = particlesOptions.move.path, pathEnabled = pathOptions.enable;
|
|
100
92
|
if (!pathEnabled) {
|
|
101
93
|
return;
|
|
@@ -109,15 +101,15 @@ function applyPath(particle, delta) {
|
|
|
109
101
|
particle.velocity.addTo(path);
|
|
110
102
|
}
|
|
111
103
|
if (pathOptions.clamp) {
|
|
112
|
-
particle.velocity.x =
|
|
113
|
-
particle.velocity.y =
|
|
104
|
+
particle.velocity.x = clamp(particle.velocity.x, -identity, identity);
|
|
105
|
+
particle.velocity.y = clamp(particle.velocity.y, -identity, identity);
|
|
114
106
|
}
|
|
115
107
|
particle.lastPathTime -= particle.pathDelay;
|
|
116
108
|
}
|
|
117
|
-
function getProximitySpeedFactor(particle) {
|
|
109
|
+
export function getProximitySpeedFactor(particle) {
|
|
118
110
|
return particle.slow.inRange ? particle.slow.factor : identity;
|
|
119
111
|
}
|
|
120
|
-
function initSpin(particle) {
|
|
112
|
+
export function initSpin(particle) {
|
|
121
113
|
const container = particle.container, options = particle.options, spinOptions = options.move.spin;
|
|
122
114
|
if (!spinOptions.enable) {
|
|
123
115
|
return;
|
|
@@ -125,12 +117,12 @@ function initSpin(particle) {
|
|
|
125
117
|
const spinPos = spinOptions.position ?? { x: 50, y: 50 }, spinFactor = 0.01, spinCenter = {
|
|
126
118
|
x: spinPos.x * spinFactor * container.canvas.size.width,
|
|
127
119
|
y: spinPos.y * spinFactor * container.canvas.size.height,
|
|
128
|
-
}, pos = particle.getPosition(), distance =
|
|
120
|
+
}, pos = particle.getPosition(), distance = getDistance(pos, spinCenter), spinAcceleration = getRangeValue(spinOptions.acceleration);
|
|
129
121
|
particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;
|
|
130
122
|
particle.spin = {
|
|
131
123
|
center: spinCenter,
|
|
132
|
-
direction: particle.velocity.x >= minVelocity ?
|
|
133
|
-
angle:
|
|
124
|
+
direction: particle.velocity.x >= minVelocity ? RotateDirection.clockwise : RotateDirection.counterClockwise,
|
|
125
|
+
angle: getRandom() * doublePI,
|
|
134
126
|
radius: distance,
|
|
135
127
|
acceleration: particle.retina.spinAcceleration,
|
|
136
128
|
};
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, refresh);
|
|
1
|
+
export function loadBaseMover(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addMover("base", async () => {
|
|
5
|
+
const { BaseMover } = await import("./BaseMover.js");
|
|
6
|
+
return new BaseMover();
|
|
7
|
+
});
|
|
8
|
+
});
|
|
10
9
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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.1
|
|
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_move_base"] = this["webpackChunk_tsparticles_move_base"] || []).push([["dist_browser_BaseMover_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/BaseMover.js"
|
|
21
|
+
/*!***********************************!*\
|
|
22
|
+
!*** ./dist/browser/BaseMover.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 */ BaseMover: () => (/* binding */ BaseMover)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\nconst diffFactor = 2,\n defaultSizeFactor = 1,\n defaultDeltaFactor = 1;\nclass BaseMover {\n init(particle) {\n const options = particle.options,\n gravityOptions = options.move.gravity;\n particle.gravity = {\n enable: gravityOptions.enable,\n acceleration: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(gravityOptions.acceleration),\n inverse: gravityOptions.inverse\n };\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.initSpin)(particle);\n }\n isEnabled(particle) {\n return !particle.destroyed && particle.options.move.enable;\n }\n move(particle, delta) {\n const particleOptions = particle.options,\n moveOptions = particleOptions.move;\n if (!moveOptions.enable) {\n return;\n }\n const container = particle.container,\n pxRatio = container.retina.pixelRatio;\n particle.retina.moveSpeed ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(moveOptions.speed) * pxRatio;\n particle.retina.moveDrift ??= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(particle.options.move.drift) * pxRatio;\n const slowFactor = (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.getProximitySpeedFactor)(particle),\n reduceFactor = container.retina.reduceFactor,\n baseSpeed = particle.retina.moveSpeed,\n moveDrift = particle.retina.moveDrift,\n maxSize = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeMax)(particleOptions.size.value) * pxRatio,\n sizeFactor = moveOptions.size ? particle.getRadius() / maxSize : defaultSizeFactor,\n deltaFactor = delta.factor || defaultDeltaFactor,\n moveSpeed = baseSpeed * sizeFactor * slowFactor * deltaFactor / diffFactor,\n maxSpeed = particle.retina.maxSpeed ?? container.retina.maxSpeed;\n if (moveOptions.spin.enable) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.spin)(particle, moveSpeed, reduceFactor);\n } else {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.move)(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta);\n }\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_1__.applyDistance)(particle);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/move-base/./dist/browser/BaseMover.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Utils.js"
|
|
31
|
+
/*!*******************************!*\
|
|
32
|
+
!*** ./dist/browser/Utils.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 */ applyDistance: () => (/* binding */ applyDistance),\n/* harmony export */ applyPath: () => (/* binding */ applyPath),\n/* harmony export */ getProximitySpeedFactor: () => (/* binding */ getProximitySpeedFactor),\n/* harmony export */ initSpin: () => (/* binding */ initSpin),\n/* harmony export */ move: () => (/* binding */ move),\n/* harmony export */ spin: () => (/* binding */ spin)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst half = 0.5,\n double = 2,\n minVelocity = 0,\n identity = 1,\n moveSpeedFactor = 60,\n minSpinRadius = 0,\n spinFactor = 0.01,\n doublePI = Math.PI * double;\nfunction applyDistance(particle) {\n const initialPosition = particle.initialPosition,\n {\n dx,\n dy\n } = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistances)(initialPosition, particle.position),\n dxFixed = Math.abs(dx),\n dyFixed = Math.abs(dy),\n {\n maxDistance\n } = particle.retina,\n hDistance = maxDistance.horizontal,\n vDistance = maxDistance.vertical;\n if (!hDistance && !vDistance) {\n return;\n }\n const hasHDistance = (hDistance && dxFixed >= hDistance) ?? false,\n hasVDistance = (vDistance && dyFixed >= vDistance) ?? false;\n if ((hasHDistance || hasVDistance) && !particle.misplaced) {\n particle.misplaced = !!hDistance && dxFixed > hDistance || !!vDistance && dyFixed > vDistance;\n if (hDistance) {\n particle.velocity.x = particle.velocity.y * half - particle.velocity.x;\n }\n if (vDistance) {\n particle.velocity.y = particle.velocity.x * half - particle.velocity.y;\n }\n } else if ((!hDistance || dxFixed < hDistance) && (!vDistance || dyFixed < vDistance) && particle.misplaced) {\n particle.misplaced = false;\n } else if (particle.misplaced) {\n const pos = particle.position,\n vel = particle.velocity;\n if (hDistance && (pos.x < initialPosition.x && vel.x < minVelocity || pos.x > initialPosition.x && vel.x > minVelocity)) {\n vel.x *= -(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n if (vDistance && (pos.y < initialPosition.y && vel.y < minVelocity || pos.y > initialPosition.y && vel.y > minVelocity)) {\n vel.y *= -(0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n }\n}\nfunction move(particle, moveOptions, moveSpeed, maxSpeed, moveDrift, reduceFactor, delta) {\n applyPath(particle, delta);\n const gravityOptions = particle.gravity,\n gravityFactor = gravityOptions?.enable && gravityOptions.inverse ? -identity : identity;\n if (moveDrift && moveSpeed) {\n particle.velocity.x += moveDrift * delta.factor / (moveSpeedFactor * moveSpeed);\n }\n if (gravityOptions?.enable && moveSpeed) {\n particle.velocity.y += gravityFactor * (gravityOptions.acceleration * delta.factor) / (moveSpeedFactor * moveSpeed);\n }\n const decay = particle.moveDecay;\n particle.velocity.multTo(decay);\n const velocity = particle.velocity.mult(moveSpeed);\n if (gravityOptions?.enable && maxSpeed > minVelocity && (!gravityOptions.inverse && velocity.y >= minVelocity && velocity.y >= maxSpeed || gravityOptions.inverse && velocity.y <= minVelocity && velocity.y <= -maxSpeed)) {\n velocity.y = gravityFactor * maxSpeed;\n if (moveSpeed) {\n particle.velocity.y = velocity.y / moveSpeed;\n }\n }\n const zIndexOptions = particle.options.zIndex,\n zVelocityFactor = (identity - particle.zIndexFactor) ** zIndexOptions.velocityRate;\n velocity.multTo(zVelocityFactor);\n velocity.multTo(reduceFactor);\n const {\n position\n } = particle;\n position.addTo(velocity);\n if (moveOptions.vibrate) {\n position.x += Math.sin(position.x * Math.cos(position.y)) * reduceFactor;\n position.y += Math.cos(position.y * Math.sin(position.x)) * reduceFactor;\n }\n}\nfunction spin(particle, moveSpeed, reduceFactor) {\n const container = particle.container;\n if (!particle.spin) {\n return;\n }\n const spinClockwise = particle.spin.direction === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise,\n updateFunc = {\n x: spinClockwise ? Math.cos : Math.sin,\n y: spinClockwise ? Math.sin : Math.cos\n };\n particle.position.x = particle.spin.center.x + particle.spin.radius * updateFunc.x(particle.spin.angle) * reduceFactor;\n particle.position.y = particle.spin.center.y + particle.spin.radius * updateFunc.y(particle.spin.angle) * reduceFactor;\n particle.spin.radius += particle.spin.acceleration * reduceFactor;\n const maxCanvasSize = Math.max(container.canvas.size.width, container.canvas.size.height),\n halfMaxSize = maxCanvasSize * half;\n if (particle.spin.radius > halfMaxSize) {\n particle.spin.radius = halfMaxSize;\n particle.spin.acceleration *= -identity;\n } else if (particle.spin.radius < minSpinRadius) {\n particle.spin.radius = minSpinRadius;\n particle.spin.acceleration *= -identity;\n }\n particle.spin.angle += moveSpeed * spinFactor * (identity - particle.spin.radius / maxCanvasSize);\n}\nfunction applyPath(particle, delta) {\n const particlesOptions = particle.options,\n pathOptions = particlesOptions.move.path,\n pathEnabled = pathOptions.enable;\n if (!pathEnabled) {\n return;\n }\n if (particle.lastPathTime <= particle.pathDelay) {\n particle.lastPathTime += delta.value;\n return;\n }\n const path = particle.pathGenerator?.generate(particle, delta);\n if (path) {\n particle.velocity.addTo(path);\n }\n if (pathOptions.clamp) {\n particle.velocity.x = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(particle.velocity.x, -identity, identity);\n particle.velocity.y = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.clamp)(particle.velocity.y, -identity, identity);\n }\n particle.lastPathTime -= particle.pathDelay;\n}\nfunction getProximitySpeedFactor(particle) {\n return particle.slow.inRange ? particle.slow.factor : identity;\n}\nfunction initSpin(particle) {\n const container = particle.container,\n options = particle.options,\n spinOptions = options.move.spin;\n if (!spinOptions.enable) {\n return;\n }\n const spinPos = spinOptions.position ?? {\n x: 50,\n y: 50\n },\n spinFactor = 0.01,\n spinCenter = {\n x: spinPos.x * spinFactor * container.canvas.size.width,\n y: spinPos.y * spinFactor * container.canvas.size.height\n },\n pos = particle.getPosition(),\n distance = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(pos, spinCenter),\n spinAcceleration = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(spinOptions.acceleration);\n particle.retina.spinAcceleration = spinAcceleration * container.retina.pixelRatio;\n particle.spin = {\n center: spinCenter,\n direction: particle.velocity.x >= minVelocity ? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise : _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.counterClockwise,\n angle: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * doublePI,\n radius: distance,\n acceleration: particle.retina.spinAcceleration\n };\n}\n\n//# sourceURL=webpack://@tsparticles/move-base/./dist/browser/Utils.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ }
|
|
39
|
+
|
|
40
|
+
}]);
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadBaseMover(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.1");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addMover("base", async () => {
|
|
5
|
+
const { BaseMover } = await import("./BaseMover.js");
|
|
6
|
+
return new BaseMover();
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/move-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "tsParticles Base movement",
|
|
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.1"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|
|
94
|
-
}
|
|
94
|
+
},
|
|
95
|
+
"type": "module"
|
|
95
96
|
}
|