@tsparticles/updater-rotate 3.0.3 → 3.1.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/browser/RotateUpdater.js +14 -36
- package/cjs/RotateUpdater.js +13 -35
- package/esm/RotateUpdater.js +14 -36
- package/package.json +2 -2
- package/report.html +2 -2
- package/tsparticles.updater.rotate.js +18 -40
- package/tsparticles.updater.rotate.min.js +1 -1
- package/tsparticles.updater.rotate.min.js.LICENSE.txt +1 -1
- package/types/RotateUpdater.d.ts +2 -2
- package/umd/RotateUpdater.js +13 -35
package/browser/RotateUpdater.js
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import { getRandom, getRangeValue, } from "@tsparticles/engine";
|
|
1
|
+
import { degToRad, getRandom, getRangeValue, updateAnimation, } from "@tsparticles/engine";
|
|
2
2
|
import { Rotate } from "./Options/Classes/Rotate.js";
|
|
3
|
-
|
|
4
|
-
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
|
|
5
|
-
if (!rotate || !rotateOptions) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
|
|
9
|
-
if (!rotateAnimation.enable) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
switch (rotate.status) {
|
|
13
|
-
case "increasing":
|
|
14
|
-
rotate.value += speed;
|
|
15
|
-
if (rotate.value > max) {
|
|
16
|
-
rotate.value -= max;
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
case "decreasing":
|
|
20
|
-
default:
|
|
21
|
-
rotate.value -= speed;
|
|
22
|
-
if (rotate.value < 0) {
|
|
23
|
-
rotate.value += max;
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
if (rotate.velocity && decay !== 1) {
|
|
28
|
-
rotate.velocity *= decay;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
3
|
+
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
|
|
31
4
|
export class RotateUpdater {
|
|
32
5
|
constructor(container) {
|
|
33
6
|
this.container = container;
|
|
@@ -39,13 +12,15 @@ export class RotateUpdater {
|
|
|
39
12
|
}
|
|
40
13
|
particle.rotate = {
|
|
41
14
|
enable: rotateOptions.animation.enable,
|
|
42
|
-
value: (getRangeValue(rotateOptions.value)
|
|
15
|
+
value: degToRad(getRangeValue(rotateOptions.value)),
|
|
16
|
+
min: 0,
|
|
17
|
+
max: doublePI,
|
|
43
18
|
};
|
|
44
19
|
particle.pathRotation = rotateOptions.path;
|
|
45
20
|
let rotateDirection = rotateOptions.direction;
|
|
46
21
|
if (rotateDirection === "random") {
|
|
47
|
-
const index = Math.floor(getRandom() *
|
|
48
|
-
rotateDirection = index >
|
|
22
|
+
const index = Math.floor(getRandom() * double), minIndex = 0;
|
|
23
|
+
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
49
24
|
}
|
|
50
25
|
switch (rotateDirection) {
|
|
51
26
|
case "counter-clockwise":
|
|
@@ -58,9 +33,9 @@ export class RotateUpdater {
|
|
|
58
33
|
}
|
|
59
34
|
const rotateAnimation = rotateOptions.animation;
|
|
60
35
|
if (rotateAnimation.enable) {
|
|
61
|
-
particle.rotate.decay =
|
|
36
|
+
particle.rotate.decay = identity - getRangeValue(rotateAnimation.decay);
|
|
62
37
|
particle.rotate.velocity =
|
|
63
|
-
(getRangeValue(rotateAnimation.speed) /
|
|
38
|
+
(getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
|
|
64
39
|
if (!rotateAnimation.sync) {
|
|
65
40
|
particle.rotate.velocity *= getRandom();
|
|
66
41
|
}
|
|
@@ -86,7 +61,10 @@ export class RotateUpdater {
|
|
|
86
61
|
if (!this.isEnabled(particle)) {
|
|
87
62
|
return;
|
|
88
63
|
}
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
if (!particle.rotate) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
updateAnimation(particle, particle.rotate, false, "none", delta);
|
|
68
|
+
particle.rotation = particle.rotate.value;
|
|
91
69
|
}
|
|
92
70
|
}
|
package/cjs/RotateUpdater.js
CHANGED
|
@@ -3,34 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RotateUpdater = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const Rotate_js_1 = require("./Options/Classes/Rotate.js");
|
|
6
|
-
|
|
7
|
-
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
|
|
8
|
-
if (!rotate || !rotateOptions) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
|
|
12
|
-
if (!rotateAnimation.enable) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
switch (rotate.status) {
|
|
16
|
-
case "increasing":
|
|
17
|
-
rotate.value += speed;
|
|
18
|
-
if (rotate.value > max) {
|
|
19
|
-
rotate.value -= max;
|
|
20
|
-
}
|
|
21
|
-
break;
|
|
22
|
-
case "decreasing":
|
|
23
|
-
default:
|
|
24
|
-
rotate.value -= speed;
|
|
25
|
-
if (rotate.value < 0) {
|
|
26
|
-
rotate.value += max;
|
|
27
|
-
}
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
if (rotate.velocity && decay !== 1) {
|
|
31
|
-
rotate.velocity *= decay;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
6
|
+
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
|
|
34
7
|
class RotateUpdater {
|
|
35
8
|
constructor(container) {
|
|
36
9
|
this.container = container;
|
|
@@ -42,13 +15,15 @@ class RotateUpdater {
|
|
|
42
15
|
}
|
|
43
16
|
particle.rotate = {
|
|
44
17
|
enable: rotateOptions.animation.enable,
|
|
45
|
-
value: ((0, engine_1.getRangeValue)(rotateOptions.value)
|
|
18
|
+
value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(rotateOptions.value)),
|
|
19
|
+
min: 0,
|
|
20
|
+
max: doublePI,
|
|
46
21
|
};
|
|
47
22
|
particle.pathRotation = rotateOptions.path;
|
|
48
23
|
let rotateDirection = rotateOptions.direction;
|
|
49
24
|
if (rotateDirection === "random") {
|
|
50
|
-
const index = Math.floor((0, engine_1.getRandom)() *
|
|
51
|
-
rotateDirection = index >
|
|
25
|
+
const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
|
|
26
|
+
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
52
27
|
}
|
|
53
28
|
switch (rotateDirection) {
|
|
54
29
|
case "counter-clockwise":
|
|
@@ -61,9 +36,9 @@ class RotateUpdater {
|
|
|
61
36
|
}
|
|
62
37
|
const rotateAnimation = rotateOptions.animation;
|
|
63
38
|
if (rotateAnimation.enable) {
|
|
64
|
-
particle.rotate.decay =
|
|
39
|
+
particle.rotate.decay = identity - (0, engine_1.getRangeValue)(rotateAnimation.decay);
|
|
65
40
|
particle.rotate.velocity =
|
|
66
|
-
((0, engine_1.getRangeValue)(rotateAnimation.speed) /
|
|
41
|
+
((0, engine_1.getRangeValue)(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
|
|
67
42
|
if (!rotateAnimation.sync) {
|
|
68
43
|
particle.rotate.velocity *= (0, engine_1.getRandom)();
|
|
69
44
|
}
|
|
@@ -89,8 +64,11 @@ class RotateUpdater {
|
|
|
89
64
|
if (!this.isEnabled(particle)) {
|
|
90
65
|
return;
|
|
91
66
|
}
|
|
92
|
-
|
|
93
|
-
|
|
67
|
+
if (!particle.rotate) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
(0, engine_1.updateAnimation)(particle, particle.rotate, false, "none", delta);
|
|
71
|
+
particle.rotation = particle.rotate.value;
|
|
94
72
|
}
|
|
95
73
|
}
|
|
96
74
|
exports.RotateUpdater = RotateUpdater;
|
package/esm/RotateUpdater.js
CHANGED
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import { getRandom, getRangeValue, } from "@tsparticles/engine";
|
|
1
|
+
import { degToRad, getRandom, getRangeValue, updateAnimation, } from "@tsparticles/engine";
|
|
2
2
|
import { Rotate } from "./Options/Classes/Rotate.js";
|
|
3
|
-
|
|
4
|
-
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
|
|
5
|
-
if (!rotate || !rotateOptions) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
|
|
9
|
-
if (!rotateAnimation.enable) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
switch (rotate.status) {
|
|
13
|
-
case "increasing":
|
|
14
|
-
rotate.value += speed;
|
|
15
|
-
if (rotate.value > max) {
|
|
16
|
-
rotate.value -= max;
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
case "decreasing":
|
|
20
|
-
default:
|
|
21
|
-
rotate.value -= speed;
|
|
22
|
-
if (rotate.value < 0) {
|
|
23
|
-
rotate.value += max;
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
if (rotate.velocity && decay !== 1) {
|
|
28
|
-
rotate.velocity *= decay;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
3
|
+
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
|
|
31
4
|
export class RotateUpdater {
|
|
32
5
|
constructor(container) {
|
|
33
6
|
this.container = container;
|
|
@@ -39,13 +12,15 @@ export class RotateUpdater {
|
|
|
39
12
|
}
|
|
40
13
|
particle.rotate = {
|
|
41
14
|
enable: rotateOptions.animation.enable,
|
|
42
|
-
value: (getRangeValue(rotateOptions.value)
|
|
15
|
+
value: degToRad(getRangeValue(rotateOptions.value)),
|
|
16
|
+
min: 0,
|
|
17
|
+
max: doublePI,
|
|
43
18
|
};
|
|
44
19
|
particle.pathRotation = rotateOptions.path;
|
|
45
20
|
let rotateDirection = rotateOptions.direction;
|
|
46
21
|
if (rotateDirection === "random") {
|
|
47
|
-
const index = Math.floor(getRandom() *
|
|
48
|
-
rotateDirection = index >
|
|
22
|
+
const index = Math.floor(getRandom() * double), minIndex = 0;
|
|
23
|
+
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
49
24
|
}
|
|
50
25
|
switch (rotateDirection) {
|
|
51
26
|
case "counter-clockwise":
|
|
@@ -58,9 +33,9 @@ export class RotateUpdater {
|
|
|
58
33
|
}
|
|
59
34
|
const rotateAnimation = rotateOptions.animation;
|
|
60
35
|
if (rotateAnimation.enable) {
|
|
61
|
-
particle.rotate.decay =
|
|
36
|
+
particle.rotate.decay = identity - getRangeValue(rotateAnimation.decay);
|
|
62
37
|
particle.rotate.velocity =
|
|
63
|
-
(getRangeValue(rotateAnimation.speed) /
|
|
38
|
+
(getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
|
|
64
39
|
if (!rotateAnimation.sync) {
|
|
65
40
|
particle.rotate.velocity *= getRandom();
|
|
66
41
|
}
|
|
@@ -86,7 +61,10 @@ export class RotateUpdater {
|
|
|
86
61
|
if (!this.isEnabled(particle)) {
|
|
87
62
|
return;
|
|
88
63
|
}
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
if (!particle.rotate) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
updateAnimation(particle, particle.rotate, false, "none", delta);
|
|
68
|
+
particle.rotation = particle.rotate.value;
|
|
91
69
|
}
|
|
92
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-rotate",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "tsParticles particles rotate updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "^3.0
|
|
90
|
+
"@tsparticles/engine": "^3.1.0"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"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/updater-rotate [
|
|
6
|
+
<title>@tsparticles/updater-rotate [13 Jan 2024 at 23: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>
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
<body>
|
|
32
32
|
<div id="app"></div>
|
|
33
33
|
<script>
|
|
34
|
-
window.chartData = [{"label":"tsparticles.updater.rotate.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"tsparticles.updater.rotate.js","isAsset":true,"statSize":3677,"parsedSize":7608,"gzipSize":2207,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":3635,"groups":[{"id":184,"label":"index.js + 3 modules (concatenated)","path":"./dist/browser/index.js + 3 modules (concatenated)","statSize":3635,"parsedSize":7608,"gzipSize":2207,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser","statSize":3635,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/index.js","statSize":216,"parsedSize":452,"gzipSize":131,"inaccurateSizes":true},{"id":null,"label":"RotateUpdater.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/RotateUpdater.js","statSize":2258,"parsedSize":4725,"gzipSize":1370,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/Options/Classes","statSize":1161,"groups":[{"id":null,"label":"Rotate.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/Options/Classes/Rotate.js","statSize":588,"parsedSize":1230,"gzipSize":357,"inaccurateSizes":true},{"id":null,"label":"RotateAnimation.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/Options/Classes/RotateAnimation.js","statSize":573,"parsedSize":1199,"gzipSize":347,"inaccurateSizes":true}],"parsedSize":2429,"gzipSize":704,"inaccurateSizes":true}],"parsedSize":7608,"gzipSize":2207,"inaccurateSizes":true}]}],"parsedSize":7608,"gzipSize":2207},{"label":"engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles","statSize":42,"groups":[{"id":533,"label":"engine\",\"root\":\"window\"}","path":"./engine\",\"commonjs2\":\"@tsparticles/engine\",\"amd\":\"@tsparticles/engine\",\"root\":\"window\"}","statSize":42}],"parsedSize":0,"gzipSize":0}],"isInitialByEntrypoint":{"tsparticles.updater.rotate":true}}];
|
|
35
35
|
window.entrypoints = ["tsparticles.updater.rotate","tsparticles.updater.rotate.min"];
|
|
36
36
|
window.defaultSizes = "parsed";
|
|
37
37
|
</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
|
-
* v3.0
|
|
7
|
+
* v3.1.0
|
|
8
8
|
*/
|
|
9
9
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
10
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -151,38 +151,10 @@ class Rotate extends engine_root_window_.ValueWithRandom {
|
|
|
151
151
|
;// CONCATENATED MODULE: ./dist/browser/RotateUpdater.js
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const rotateAnimation = rotateOptions.animation,
|
|
161
|
-
speed = (rotate.velocity ?? 0) * delta.factor,
|
|
162
|
-
max = 2 * Math.PI,
|
|
163
|
-
decay = rotate.decay ?? 1;
|
|
164
|
-
if (!rotateAnimation.enable) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
switch (rotate.status) {
|
|
168
|
-
case "increasing":
|
|
169
|
-
rotate.value += speed;
|
|
170
|
-
if (rotate.value > max) {
|
|
171
|
-
rotate.value -= max;
|
|
172
|
-
}
|
|
173
|
-
break;
|
|
174
|
-
case "decreasing":
|
|
175
|
-
default:
|
|
176
|
-
rotate.value -= speed;
|
|
177
|
-
if (rotate.value < 0) {
|
|
178
|
-
rotate.value += max;
|
|
179
|
-
}
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
if (rotate.velocity && decay !== 1) {
|
|
183
|
-
rotate.velocity *= decay;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
154
|
+
const RotateUpdater_double = 2,
|
|
155
|
+
doublePI = Math.PI * RotateUpdater_double,
|
|
156
|
+
identity = 1,
|
|
157
|
+
doublePIDeg = 360;
|
|
186
158
|
class RotateUpdater {
|
|
187
159
|
constructor(container) {
|
|
188
160
|
this.container = container;
|
|
@@ -194,13 +166,16 @@ class RotateUpdater {
|
|
|
194
166
|
}
|
|
195
167
|
particle.rotate = {
|
|
196
168
|
enable: rotateOptions.animation.enable,
|
|
197
|
-
value: (0,engine_root_window_.getRangeValue)(rotateOptions.value)
|
|
169
|
+
value: (0,engine_root_window_.degToRad)((0,engine_root_window_.getRangeValue)(rotateOptions.value)),
|
|
170
|
+
min: 0,
|
|
171
|
+
max: doublePI
|
|
198
172
|
};
|
|
199
173
|
particle.pathRotation = rotateOptions.path;
|
|
200
174
|
let rotateDirection = rotateOptions.direction;
|
|
201
175
|
if (rotateDirection === "random") {
|
|
202
|
-
const index = Math.floor((0,engine_root_window_.getRandom)() *
|
|
203
|
-
|
|
176
|
+
const index = Math.floor((0,engine_root_window_.getRandom)() * RotateUpdater_double),
|
|
177
|
+
minIndex = 0;
|
|
178
|
+
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
204
179
|
}
|
|
205
180
|
switch (rotateDirection) {
|
|
206
181
|
case "counter-clockwise":
|
|
@@ -213,8 +188,8 @@ class RotateUpdater {
|
|
|
213
188
|
}
|
|
214
189
|
const rotateAnimation = rotateOptions.animation;
|
|
215
190
|
if (rotateAnimation.enable) {
|
|
216
|
-
particle.rotate.decay =
|
|
217
|
-
particle.rotate.velocity = (0,engine_root_window_.getRangeValue)(rotateAnimation.speed) /
|
|
191
|
+
particle.rotate.decay = identity - (0,engine_root_window_.getRangeValue)(rotateAnimation.decay);
|
|
192
|
+
particle.rotate.velocity = (0,engine_root_window_.getRangeValue)(rotateAnimation.speed) / doublePIDeg * this.container.retina.reduceFactor;
|
|
218
193
|
if (!rotateAnimation.sync) {
|
|
219
194
|
particle.rotate.velocity *= (0,engine_root_window_.getRandom)();
|
|
220
195
|
}
|
|
@@ -240,8 +215,11 @@ class RotateUpdater {
|
|
|
240
215
|
if (!this.isEnabled(particle)) {
|
|
241
216
|
return;
|
|
242
217
|
}
|
|
243
|
-
|
|
244
|
-
|
|
218
|
+
if (!particle.rotate) {
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
(0,engine_root_window_.updateAnimation)(particle, particle.rotate, false, "none", delta);
|
|
222
|
+
particle.rotation = particle.rotate.value;
|
|
245
223
|
}
|
|
246
224
|
}
|
|
247
225
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.rotate.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var a in o)("object"==typeof exports?exports:e)[a]=o[a]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},o={};function a(e){var n=o[e];if(void 0!==n)return n.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,a),i.exports}a.d=(e,t)=>{for(var o in t)a.o(t,o)&&!a.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{a.r(n),a.d(n,{loadRotateUpdater:()=>s});var e=a(533);class t{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){t&&(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,e.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,e.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class o extends e.ValueWithRandom{constructor(){super(),this.animation=new t,this.direction="clockwise",this.path=!1,this.value=0}load(e){e&&(super.load(e),void 0!==e.direction&&(this.direction=e.direction),this.animation.load(e.animation),void 0!==e.path&&(this.path=e.path))}}const i=2*Math.PI;class r{constructor(e){this.container=e}init(t){const o=t.options.rotate;if(!o)return;t.rotate={enable:o.animation.enable,value:(0,e.degToRad)((0,e.getRangeValue)(o.value)),min:0,max:i},t.pathRotation=o.path;let a=o.direction;if("random"===a){a=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(a){case"counter-clockwise":case"counterClockwise":t.rotate.status="decreasing";break;case"clockwise":t.rotate.status="increasing"}const n=o.animation;n.enable&&(t.rotate.decay=1-(0,e.getRangeValue)(n.decay),t.rotate.velocity=(0,e.getRangeValue)(n.speed)/360*this.container.retina.reduceFactor,n.sync||(t.rotate.velocity*=(0,e.getRandom)())),t.rotation=t.rotate.value}isEnabled(e){const t=e.options.rotate;return!!t&&(!e.destroyed&&!e.spawning&&t.animation.enable&&!t.path)}loadOptions(e,...t){e.rotate||(e.rotate=new o);for(const o of t)e.rotate.load(o?.rotate)}update(t,o){this.isEnabled(t)&&t.rotate&&((0,e.updateAnimation)(t,t.rotate,!1,"none",o),t.rotation=t.rotate.value)}}async function s(e,t=!0){await e.addParticleUpdater("rotate",(e=>new r(e)),t)}})(),n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Rotate Updater v3.0
|
|
1
|
+
/*! tsParticles Rotate Updater v3.1.0 by Matteo Bruni */
|
package/types/RotateUpdater.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type Container, type IDelta, type
|
|
1
|
+
import { type Container, type IDelta, type IParticleNumericValueAnimation, type IParticleUpdater, type IParticlesOptions, type Particle, type ParticlesOptions, type RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { IRotate } from "./Options/Interfaces/IRotate.js";
|
|
3
3
|
import { Rotate } from "./Options/Classes/Rotate.js";
|
|
4
4
|
type RotateParticle = Particle & {
|
|
5
5
|
options: RotateParticlesOptions;
|
|
6
|
-
rotate?:
|
|
6
|
+
rotate?: IParticleNumericValueAnimation;
|
|
7
7
|
};
|
|
8
8
|
type IRotateParticlesOptions = IParticlesOptions & {
|
|
9
9
|
rotate?: IRotate;
|
package/umd/RotateUpdater.js
CHANGED
|
@@ -12,34 +12,7 @@
|
|
|
12
12
|
exports.RotateUpdater = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Rotate_js_1 = require("./Options/Classes/Rotate.js");
|
|
15
|
-
|
|
16
|
-
const rotate = particle.rotate, rotateOptions = particle.options.rotate;
|
|
17
|
-
if (!rotate || !rotateOptions) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const rotateAnimation = rotateOptions.animation, speed = (rotate.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = rotate.decay ?? 1;
|
|
21
|
-
if (!rotateAnimation.enable) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
switch (rotate.status) {
|
|
25
|
-
case "increasing":
|
|
26
|
-
rotate.value += speed;
|
|
27
|
-
if (rotate.value > max) {
|
|
28
|
-
rotate.value -= max;
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
case "decreasing":
|
|
32
|
-
default:
|
|
33
|
-
rotate.value -= speed;
|
|
34
|
-
if (rotate.value < 0) {
|
|
35
|
-
rotate.value += max;
|
|
36
|
-
}
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
if (rotate.velocity && decay !== 1) {
|
|
40
|
-
rotate.velocity *= decay;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
15
|
+
const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
|
|
43
16
|
class RotateUpdater {
|
|
44
17
|
constructor(container) {
|
|
45
18
|
this.container = container;
|
|
@@ -51,13 +24,15 @@
|
|
|
51
24
|
}
|
|
52
25
|
particle.rotate = {
|
|
53
26
|
enable: rotateOptions.animation.enable,
|
|
54
|
-
value: ((0, engine_1.getRangeValue)(rotateOptions.value)
|
|
27
|
+
value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(rotateOptions.value)),
|
|
28
|
+
min: 0,
|
|
29
|
+
max: doublePI,
|
|
55
30
|
};
|
|
56
31
|
particle.pathRotation = rotateOptions.path;
|
|
57
32
|
let rotateDirection = rotateOptions.direction;
|
|
58
33
|
if (rotateDirection === "random") {
|
|
59
|
-
const index = Math.floor((0, engine_1.getRandom)() *
|
|
60
|
-
rotateDirection = index >
|
|
34
|
+
const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
|
|
35
|
+
rotateDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
61
36
|
}
|
|
62
37
|
switch (rotateDirection) {
|
|
63
38
|
case "counter-clockwise":
|
|
@@ -70,9 +45,9 @@
|
|
|
70
45
|
}
|
|
71
46
|
const rotateAnimation = rotateOptions.animation;
|
|
72
47
|
if (rotateAnimation.enable) {
|
|
73
|
-
particle.rotate.decay =
|
|
48
|
+
particle.rotate.decay = identity - (0, engine_1.getRangeValue)(rotateAnimation.decay);
|
|
74
49
|
particle.rotate.velocity =
|
|
75
|
-
((0, engine_1.getRangeValue)(rotateAnimation.speed) /
|
|
50
|
+
((0, engine_1.getRangeValue)(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
|
|
76
51
|
if (!rotateAnimation.sync) {
|
|
77
52
|
particle.rotate.velocity *= (0, engine_1.getRandom)();
|
|
78
53
|
}
|
|
@@ -98,8 +73,11 @@
|
|
|
98
73
|
if (!this.isEnabled(particle)) {
|
|
99
74
|
return;
|
|
100
75
|
}
|
|
101
|
-
|
|
102
|
-
|
|
76
|
+
if (!particle.rotate) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
(0, engine_1.updateAnimation)(particle, particle.rotate, false, "none", delta);
|
|
80
|
+
particle.rotation = particle.rotate.value;
|
|
103
81
|
}
|
|
104
82
|
}
|
|
105
83
|
exports.RotateUpdater = RotateUpdater;
|