@tsparticles/updater-tilt 3.0.2 → 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/TiltUpdater.js +14 -11
- package/cjs/TiltUpdater.js +13 -10
- package/esm/TiltUpdater.js +14 -11
- package/package.json +2 -2
- package/report.html +2 -2
- package/tsparticles.updater.tilt.js +17 -43
- package/tsparticles.updater.tilt.min.js +1 -1
- package/tsparticles.updater.tilt.min.js.LICENSE.txt +1 -1
- package/types/Options/Classes/Tilt.d.ts +1 -2
- package/types/TiltUpdater.d.ts +2 -2
- package/types/Types.d.ts +2 -2
- package/umd/TiltUpdater.js +14 -11
- package/browser/Utils.js +0 -27
- package/cjs/Utils.js +0 -31
- package/esm/Utils.js +0 -27
- package/types/Utils.d.ts +0 -3
- package/umd/Utils.js +0 -41
package/browser/TiltUpdater.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getRandom, getRangeValue, } from "@tsparticles/engine";
|
|
1
|
+
import { degToRad, getRandom, getRangeValue, halfRandom, updateAnimation, } from "@tsparticles/engine";
|
|
2
2
|
import { Tilt } from "./Options/Classes/Tilt.js";
|
|
3
|
-
|
|
3
|
+
const identity = 1, double = 2, doublePI = Math.PI * double, maxAngle = 360;
|
|
4
4
|
export class TiltUpdater {
|
|
5
5
|
constructor(container) {
|
|
6
6
|
this.container = container;
|
|
@@ -19,14 +19,16 @@ export class TiltUpdater {
|
|
|
19
19
|
}
|
|
20
20
|
particle.tilt = {
|
|
21
21
|
enable: tiltOptions.enable,
|
|
22
|
-
value: (getRangeValue(tiltOptions.value)
|
|
23
|
-
sinDirection: getRandom() >=
|
|
24
|
-
cosDirection: getRandom() >=
|
|
22
|
+
value: degToRad(getRangeValue(tiltOptions.value)),
|
|
23
|
+
sinDirection: getRandom() >= halfRandom ? identity : -identity,
|
|
24
|
+
cosDirection: getRandom() >= halfRandom ? identity : -identity,
|
|
25
|
+
min: 0,
|
|
26
|
+
max: doublePI,
|
|
25
27
|
};
|
|
26
28
|
let tiltDirection = tiltOptions.direction;
|
|
27
29
|
if (tiltDirection === "random") {
|
|
28
|
-
const index = Math.floor(getRandom() *
|
|
29
|
-
tiltDirection = index >
|
|
30
|
+
const index = Math.floor(getRandom() * double), minIndex = 0;
|
|
31
|
+
tiltDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
30
32
|
}
|
|
31
33
|
switch (tiltDirection) {
|
|
32
34
|
case "counter-clockwise":
|
|
@@ -39,8 +41,9 @@ export class TiltUpdater {
|
|
|
39
41
|
}
|
|
40
42
|
const tiltAnimation = particle.options.tilt?.animation;
|
|
41
43
|
if (tiltAnimation?.enable) {
|
|
42
|
-
particle.tilt.decay =
|
|
43
|
-
particle.tilt.velocity =
|
|
44
|
+
particle.tilt.decay = identity - getRangeValue(tiltAnimation.decay);
|
|
45
|
+
particle.tilt.velocity =
|
|
46
|
+
(getRangeValue(tiltAnimation.speed) / maxAngle) * this.container.retina.reduceFactor;
|
|
44
47
|
if (!tiltAnimation.sync) {
|
|
45
48
|
particle.tilt.velocity *= getRandom();
|
|
46
49
|
}
|
|
@@ -59,9 +62,9 @@ export class TiltUpdater {
|
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
update(particle, delta) {
|
|
62
|
-
if (!this.isEnabled(particle)) {
|
|
65
|
+
if (!this.isEnabled(particle) || !particle.tilt) {
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
updateAnimation(particle, particle.tilt, false, "none", delta);
|
|
66
69
|
}
|
|
67
70
|
}
|
package/cjs/TiltUpdater.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TiltUpdater = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const Tilt_js_1 = require("./Options/Classes/Tilt.js");
|
|
6
|
-
const
|
|
6
|
+
const identity = 1, double = 2, doublePI = Math.PI * double, maxAngle = 360;
|
|
7
7
|
class TiltUpdater {
|
|
8
8
|
constructor(container) {
|
|
9
9
|
this.container = container;
|
|
@@ -22,14 +22,16 @@ class TiltUpdater {
|
|
|
22
22
|
}
|
|
23
23
|
particle.tilt = {
|
|
24
24
|
enable: tiltOptions.enable,
|
|
25
|
-
value: ((0, engine_1.getRangeValue)(tiltOptions.value)
|
|
26
|
-
sinDirection: (0, engine_1.getRandom)() >=
|
|
27
|
-
cosDirection: (0, engine_1.getRandom)() >=
|
|
25
|
+
value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(tiltOptions.value)),
|
|
26
|
+
sinDirection: (0, engine_1.getRandom)() >= engine_1.halfRandom ? identity : -identity,
|
|
27
|
+
cosDirection: (0, engine_1.getRandom)() >= engine_1.halfRandom ? identity : -identity,
|
|
28
|
+
min: 0,
|
|
29
|
+
max: doublePI,
|
|
28
30
|
};
|
|
29
31
|
let tiltDirection = tiltOptions.direction;
|
|
30
32
|
if (tiltDirection === "random") {
|
|
31
|
-
const index = Math.floor((0, engine_1.getRandom)() *
|
|
32
|
-
tiltDirection = index >
|
|
33
|
+
const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
|
|
34
|
+
tiltDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
33
35
|
}
|
|
34
36
|
switch (tiltDirection) {
|
|
35
37
|
case "counter-clockwise":
|
|
@@ -42,8 +44,9 @@ class TiltUpdater {
|
|
|
42
44
|
}
|
|
43
45
|
const tiltAnimation = particle.options.tilt?.animation;
|
|
44
46
|
if (tiltAnimation?.enable) {
|
|
45
|
-
particle.tilt.decay =
|
|
46
|
-
particle.tilt.velocity =
|
|
47
|
+
particle.tilt.decay = identity - (0, engine_1.getRangeValue)(tiltAnimation.decay);
|
|
48
|
+
particle.tilt.velocity =
|
|
49
|
+
((0, engine_1.getRangeValue)(tiltAnimation.speed) / maxAngle) * this.container.retina.reduceFactor;
|
|
47
50
|
if (!tiltAnimation.sync) {
|
|
48
51
|
particle.tilt.velocity *= (0, engine_1.getRandom)();
|
|
49
52
|
}
|
|
@@ -62,10 +65,10 @@ class TiltUpdater {
|
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
update(particle, delta) {
|
|
65
|
-
if (!this.isEnabled(particle)) {
|
|
68
|
+
if (!this.isEnabled(particle) || !particle.tilt) {
|
|
66
69
|
return;
|
|
67
70
|
}
|
|
68
|
-
(0,
|
|
71
|
+
(0, engine_1.updateAnimation)(particle, particle.tilt, false, "none", delta);
|
|
69
72
|
}
|
|
70
73
|
}
|
|
71
74
|
exports.TiltUpdater = TiltUpdater;
|
package/esm/TiltUpdater.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getRandom, getRangeValue, } from "@tsparticles/engine";
|
|
1
|
+
import { degToRad, getRandom, getRangeValue, halfRandom, updateAnimation, } from "@tsparticles/engine";
|
|
2
2
|
import { Tilt } from "./Options/Classes/Tilt.js";
|
|
3
|
-
|
|
3
|
+
const identity = 1, double = 2, doublePI = Math.PI * double, maxAngle = 360;
|
|
4
4
|
export class TiltUpdater {
|
|
5
5
|
constructor(container) {
|
|
6
6
|
this.container = container;
|
|
@@ -19,14 +19,16 @@ export class TiltUpdater {
|
|
|
19
19
|
}
|
|
20
20
|
particle.tilt = {
|
|
21
21
|
enable: tiltOptions.enable,
|
|
22
|
-
value: (getRangeValue(tiltOptions.value)
|
|
23
|
-
sinDirection: getRandom() >=
|
|
24
|
-
cosDirection: getRandom() >=
|
|
22
|
+
value: degToRad(getRangeValue(tiltOptions.value)),
|
|
23
|
+
sinDirection: getRandom() >= halfRandom ? identity : -identity,
|
|
24
|
+
cosDirection: getRandom() >= halfRandom ? identity : -identity,
|
|
25
|
+
min: 0,
|
|
26
|
+
max: doublePI,
|
|
25
27
|
};
|
|
26
28
|
let tiltDirection = tiltOptions.direction;
|
|
27
29
|
if (tiltDirection === "random") {
|
|
28
|
-
const index = Math.floor(getRandom() *
|
|
29
|
-
tiltDirection = index >
|
|
30
|
+
const index = Math.floor(getRandom() * double), minIndex = 0;
|
|
31
|
+
tiltDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
30
32
|
}
|
|
31
33
|
switch (tiltDirection) {
|
|
32
34
|
case "counter-clockwise":
|
|
@@ -39,8 +41,9 @@ export class TiltUpdater {
|
|
|
39
41
|
}
|
|
40
42
|
const tiltAnimation = particle.options.tilt?.animation;
|
|
41
43
|
if (tiltAnimation?.enable) {
|
|
42
|
-
particle.tilt.decay =
|
|
43
|
-
particle.tilt.velocity =
|
|
44
|
+
particle.tilt.decay = identity - getRangeValue(tiltAnimation.decay);
|
|
45
|
+
particle.tilt.velocity =
|
|
46
|
+
(getRangeValue(tiltAnimation.speed) / maxAngle) * this.container.retina.reduceFactor;
|
|
44
47
|
if (!tiltAnimation.sync) {
|
|
45
48
|
particle.tilt.velocity *= getRandom();
|
|
46
49
|
}
|
|
@@ -59,9 +62,9 @@ export class TiltUpdater {
|
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
update(particle, delta) {
|
|
62
|
-
if (!this.isEnabled(particle)) {
|
|
65
|
+
if (!this.isEnabled(particle) || !particle.tilt) {
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
|
-
|
|
68
|
+
updateAnimation(particle, particle.tilt, false, "none", delta);
|
|
66
69
|
}
|
|
67
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-tilt",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "tsParticles particles tilt 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-tilt [
|
|
6
|
+
<title>@tsparticles/updater-tilt [13 Jan 2024 at 23:09]</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.tilt.js","isAsset":true,"statSize":
|
|
34
|
+
window.chartData = [{"label":"tsparticles.updater.tilt.js","isAsset":true,"statSize":3787,"parsedSize":7790,"gzipSize":2274,"groups":[{"label":"dist/browser","path":"./dist/browser","statSize":3745,"groups":[{"id":516,"label":"index.js + 3 modules (concatenated)","path":"./dist/browser/index.js + 3 modules (concatenated)","statSize":3745,"parsedSize":7790,"gzipSize":2274,"concatenated":true,"groups":[{"label":"dist/browser","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser","statSize":3745,"groups":[{"id":null,"label":"index.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/index.js","statSize":206,"parsedSize":428,"gzipSize":125,"inaccurateSizes":true},{"id":null,"label":"TiltUpdater.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/TiltUpdater.js","statSize":2380,"parsedSize":4950,"gzipSize":1445,"inaccurateSizes":true},{"label":"Options/Classes","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/Options/Classes","statSize":1159,"groups":[{"id":null,"label":"Tilt.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/Options/Classes/Tilt.js","statSize":588,"parsedSize":1223,"gzipSize":357,"inaccurateSizes":true},{"id":null,"label":"TiltAnimation.js","path":"./dist/browser/index.js + 3 modules (concatenated)/dist/browser/Options/Classes/TiltAnimation.js","statSize":571,"parsedSize":1187,"gzipSize":346,"inaccurateSizes":true}],"parsedSize":2410,"gzipSize":703,"inaccurateSizes":true}],"parsedSize":7790,"gzipSize":2274,"inaccurateSizes":true}]}],"parsedSize":7790,"gzipSize":2274},{"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.tilt":true}}];
|
|
35
35
|
window.entrypoints = ["tsparticles.updater.tilt","tsparticles.updater.tilt.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')
|
|
@@ -148,42 +148,13 @@ class Tilt extends engine_root_window_.ValueWithRandom {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
;// CONCATENATED MODULE: ./dist/browser/Utils.js
|
|
152
|
-
function updateTilt(particle, delta) {
|
|
153
|
-
if (!particle.tilt || !particle.options.tilt) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const tilt = particle.options.tilt,
|
|
157
|
-
tiltAnimation = tilt.animation,
|
|
158
|
-
speed = (particle.tilt.velocity ?? 0) * delta.factor,
|
|
159
|
-
max = 2 * Math.PI,
|
|
160
|
-
decay = particle.tilt.decay ?? 1;
|
|
161
|
-
if (!tiltAnimation.enable) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
switch (particle.tilt.status) {
|
|
165
|
-
case "increasing":
|
|
166
|
-
particle.tilt.value += speed;
|
|
167
|
-
if (particle.tilt.value > max) {
|
|
168
|
-
particle.tilt.value -= max;
|
|
169
|
-
}
|
|
170
|
-
break;
|
|
171
|
-
case "decreasing":
|
|
172
|
-
default:
|
|
173
|
-
particle.tilt.value -= speed;
|
|
174
|
-
if (particle.tilt.value < 0) {
|
|
175
|
-
particle.tilt.value += max;
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
if (particle.tilt.velocity && decay !== 1) {
|
|
180
|
-
particle.tilt.velocity *= decay;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
151
|
;// CONCATENATED MODULE: ./dist/browser/TiltUpdater.js
|
|
184
152
|
|
|
185
153
|
|
|
186
|
-
|
|
154
|
+
const identity = 1,
|
|
155
|
+
TiltUpdater_double = 2,
|
|
156
|
+
doublePI = Math.PI * TiltUpdater_double,
|
|
157
|
+
maxAngle = 360;
|
|
187
158
|
class TiltUpdater {
|
|
188
159
|
constructor(container) {
|
|
189
160
|
this.container = container;
|
|
@@ -202,14 +173,17 @@ class TiltUpdater {
|
|
|
202
173
|
}
|
|
203
174
|
particle.tilt = {
|
|
204
175
|
enable: tiltOptions.enable,
|
|
205
|
-
value: (0,engine_root_window_.getRangeValue)(tiltOptions.value)
|
|
206
|
-
sinDirection: (0,engine_root_window_.getRandom)() >=
|
|
207
|
-
cosDirection: (0,engine_root_window_.getRandom)() >=
|
|
176
|
+
value: (0,engine_root_window_.degToRad)((0,engine_root_window_.getRangeValue)(tiltOptions.value)),
|
|
177
|
+
sinDirection: (0,engine_root_window_.getRandom)() >= engine_root_window_.halfRandom ? identity : -identity,
|
|
178
|
+
cosDirection: (0,engine_root_window_.getRandom)() >= engine_root_window_.halfRandom ? identity : -identity,
|
|
179
|
+
min: 0,
|
|
180
|
+
max: doublePI
|
|
208
181
|
};
|
|
209
182
|
let tiltDirection = tiltOptions.direction;
|
|
210
183
|
if (tiltDirection === "random") {
|
|
211
|
-
const index = Math.floor((0,engine_root_window_.getRandom)() *
|
|
212
|
-
|
|
184
|
+
const index = Math.floor((0,engine_root_window_.getRandom)() * TiltUpdater_double),
|
|
185
|
+
minIndex = 0;
|
|
186
|
+
tiltDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
213
187
|
}
|
|
214
188
|
switch (tiltDirection) {
|
|
215
189
|
case "counter-clockwise":
|
|
@@ -222,8 +196,8 @@ class TiltUpdater {
|
|
|
222
196
|
}
|
|
223
197
|
const tiltAnimation = particle.options.tilt?.animation;
|
|
224
198
|
if (tiltAnimation?.enable) {
|
|
225
|
-
particle.tilt.decay =
|
|
226
|
-
particle.tilt.velocity = (0,engine_root_window_.getRangeValue)(tiltAnimation.speed) /
|
|
199
|
+
particle.tilt.decay = identity - (0,engine_root_window_.getRangeValue)(tiltAnimation.decay);
|
|
200
|
+
particle.tilt.velocity = (0,engine_root_window_.getRangeValue)(tiltAnimation.speed) / maxAngle * this.container.retina.reduceFactor;
|
|
227
201
|
if (!tiltAnimation.sync) {
|
|
228
202
|
particle.tilt.velocity *= (0,engine_root_window_.getRandom)();
|
|
229
203
|
}
|
|
@@ -242,10 +216,10 @@ class TiltUpdater {
|
|
|
242
216
|
}
|
|
243
217
|
}
|
|
244
218
|
update(particle, delta) {
|
|
245
|
-
if (!this.isEnabled(particle)) {
|
|
219
|
+
if (!this.isEnabled(particle) || !particle.tilt) {
|
|
246
220
|
return;
|
|
247
221
|
}
|
|
248
|
-
|
|
222
|
+
(0,engine_root_window_.updateAnimation)(particle, particle.tilt, false, "none", delta);
|
|
249
223
|
}
|
|
250
224
|
}
|
|
251
225
|
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.updater.tilt.min.js.LICENSE.txt */
|
|
2
|
-
!function(t
|
|
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 i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},i={};function n(e){var o=i[e];if(void 0!==o)return o.exports;var a=i[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{n.r(o),n.d(o,{loadTiltUpdater:()=>r});var e=n(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 i extends e.ValueWithRandom{constructor(){super(),this.animation=new t,this.direction="clockwise",this.enable=!1,this.value=0}load(e){super.load(e),e&&(this.animation.load(e.animation),void 0!==e.direction&&(this.direction=e.direction),void 0!==e.enable&&(this.enable=e.enable))}}const a=2*Math.PI;class s{constructor(e){this.container=e}getTransformValues(e){const t=e.tilt?.enable&&e.tilt;return{b:t?Math.cos(t.value)*t.cosDirection:void 0,c:t?Math.sin(t.value)*t.sinDirection:void 0}}init(t){const i=t.options.tilt;if(!i)return;t.tilt={enable:i.enable,value:(0,e.degToRad)((0,e.getRangeValue)(i.value)),sinDirection:(0,e.getRandom)()>=e.halfRandom?1:-1,cosDirection:(0,e.getRandom)()>=e.halfRandom?1:-1,min:0,max:a};let n=i.direction;if("random"===n){n=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(n){case"counter-clockwise":case"counterClockwise":t.tilt.status="decreasing";break;case"clockwise":t.tilt.status="increasing"}const o=t.options.tilt?.animation;o?.enable&&(t.tilt.decay=1-(0,e.getRangeValue)(o.decay),t.tilt.velocity=(0,e.getRangeValue)(o.speed)/360*this.container.retina.reduceFactor,o.sync||(t.tilt.velocity*=(0,e.getRandom)()))}isEnabled(e){const t=e.options.tilt?.animation;return!e.destroyed&&!e.spawning&&!!t?.enable}loadOptions(e,...t){e.tilt||(e.tilt=new i);for(const i of t)e.tilt.load(i?.tilt)}update(t,i){this.isEnabled(t)&&t.tilt&&(0,e.updateAnimation)(t,t.tilt,!1,"none",i)}}async function r(e,t=!0){await e.addParticleUpdater("tilt",(e=>new s(e)),t)}})(),o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Tilt Updater v3.0
|
|
1
|
+
/*! tsParticles Tilt Updater v3.1.0 by Matteo Bruni */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type IOptionLoader, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
|
|
2
|
+
import { TiltDirection, type TiltDirectionAlt } from "../../TiltDirection.js";
|
|
2
3
|
import type { ITilt } from "../Interfaces/ITilt.js";
|
|
3
4
|
import { TiltAnimation } from "./TiltAnimation.js";
|
|
4
|
-
import { TiltDirection } from "../../TiltDirection.js";
|
|
5
|
-
import type { TiltDirectionAlt } from "../../TiltDirection.js";
|
|
6
5
|
export declare class Tilt extends ValueWithRandom implements ITilt, IOptionLoader<ITilt> {
|
|
7
6
|
animation: TiltAnimation;
|
|
8
7
|
direction: TiltDirection | keyof typeof TiltDirection | TiltDirectionAlt;
|
package/types/TiltUpdater.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Container, type IDelta, type IParticleTransformValues, type IParticleUpdater, type
|
|
1
|
+
import { type Container, type IDelta, type IParticleTransformValues, type IParticleUpdater, type RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { ITiltParticlesOptions, TiltParticle, TiltParticlesOptions } from "./Types.js";
|
|
3
3
|
export declare class TiltUpdater implements IParticleUpdater {
|
|
4
4
|
private readonly container;
|
|
@@ -7,5 +7,5 @@ export declare class TiltUpdater implements IParticleUpdater {
|
|
|
7
7
|
init(particle: TiltParticle): void;
|
|
8
8
|
isEnabled(particle: TiltParticle): boolean;
|
|
9
9
|
loadOptions(options: TiltParticlesOptions, ...sources: (RecursivePartial<ITiltParticlesOptions> | undefined)[]): void;
|
|
10
|
-
update(particle:
|
|
10
|
+
update(particle: TiltParticle, delta: IDelta): void;
|
|
11
11
|
}
|
package/types/Types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IParticleNumericValueAnimation, IParticlesOptions, Particle, ParticlesOptions } from "@tsparticles/engine";
|
|
2
2
|
import type { ITilt } from "./Options/Interfaces/ITilt.js";
|
|
3
3
|
import type { Tilt } from "./Options/Classes/Tilt.js";
|
|
4
|
-
export interface IParticleTiltValueAnimation extends
|
|
4
|
+
export interface IParticleTiltValueAnimation extends IParticleNumericValueAnimation {
|
|
5
5
|
cosDirection: number;
|
|
6
6
|
sinDirection: number;
|
|
7
7
|
}
|
package/umd/TiltUpdater.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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", "./Options/Classes/Tilt.js"
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Tilt.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports.TiltUpdater = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Tilt_js_1 = require("./Options/Classes/Tilt.js");
|
|
15
|
-
const
|
|
15
|
+
const identity = 1, double = 2, doublePI = Math.PI * double, maxAngle = 360;
|
|
16
16
|
class TiltUpdater {
|
|
17
17
|
constructor(container) {
|
|
18
18
|
this.container = container;
|
|
@@ -31,14 +31,16 @@
|
|
|
31
31
|
}
|
|
32
32
|
particle.tilt = {
|
|
33
33
|
enable: tiltOptions.enable,
|
|
34
|
-
value: ((0, engine_1.getRangeValue)(tiltOptions.value)
|
|
35
|
-
sinDirection: (0, engine_1.getRandom)() >=
|
|
36
|
-
cosDirection: (0, engine_1.getRandom)() >=
|
|
34
|
+
value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(tiltOptions.value)),
|
|
35
|
+
sinDirection: (0, engine_1.getRandom)() >= engine_1.halfRandom ? identity : -identity,
|
|
36
|
+
cosDirection: (0, engine_1.getRandom)() >= engine_1.halfRandom ? identity : -identity,
|
|
37
|
+
min: 0,
|
|
38
|
+
max: doublePI,
|
|
37
39
|
};
|
|
38
40
|
let tiltDirection = tiltOptions.direction;
|
|
39
41
|
if (tiltDirection === "random") {
|
|
40
|
-
const index = Math.floor((0, engine_1.getRandom)() *
|
|
41
|
-
tiltDirection = index >
|
|
42
|
+
const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
|
|
43
|
+
tiltDirection = index > minIndex ? "counter-clockwise" : "clockwise";
|
|
42
44
|
}
|
|
43
45
|
switch (tiltDirection) {
|
|
44
46
|
case "counter-clockwise":
|
|
@@ -51,8 +53,9 @@
|
|
|
51
53
|
}
|
|
52
54
|
const tiltAnimation = particle.options.tilt?.animation;
|
|
53
55
|
if (tiltAnimation?.enable) {
|
|
54
|
-
particle.tilt.decay =
|
|
55
|
-
particle.tilt.velocity =
|
|
56
|
+
particle.tilt.decay = identity - (0, engine_1.getRangeValue)(tiltAnimation.decay);
|
|
57
|
+
particle.tilt.velocity =
|
|
58
|
+
((0, engine_1.getRangeValue)(tiltAnimation.speed) / maxAngle) * this.container.retina.reduceFactor;
|
|
56
59
|
if (!tiltAnimation.sync) {
|
|
57
60
|
particle.tilt.velocity *= (0, engine_1.getRandom)();
|
|
58
61
|
}
|
|
@@ -71,10 +74,10 @@
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
update(particle, delta) {
|
|
74
|
-
if (!this.isEnabled(particle)) {
|
|
77
|
+
if (!this.isEnabled(particle) || !particle.tilt) {
|
|
75
78
|
return;
|
|
76
79
|
}
|
|
77
|
-
(0,
|
|
80
|
+
(0, engine_1.updateAnimation)(particle, particle.tilt, false, "none", delta);
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
83
|
exports.TiltUpdater = TiltUpdater;
|
package/browser/Utils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function updateTilt(particle, delta) {
|
|
2
|
-
if (!particle.tilt || !particle.options.tilt) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
const tilt = particle.options.tilt, tiltAnimation = tilt.animation, speed = (particle.tilt.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = particle.tilt.decay ?? 1;
|
|
6
|
-
if (!tiltAnimation.enable) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
switch (particle.tilt.status) {
|
|
10
|
-
case "increasing":
|
|
11
|
-
particle.tilt.value += speed;
|
|
12
|
-
if (particle.tilt.value > max) {
|
|
13
|
-
particle.tilt.value -= max;
|
|
14
|
-
}
|
|
15
|
-
break;
|
|
16
|
-
case "decreasing":
|
|
17
|
-
default:
|
|
18
|
-
particle.tilt.value -= speed;
|
|
19
|
-
if (particle.tilt.value < 0) {
|
|
20
|
-
particle.tilt.value += max;
|
|
21
|
-
}
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
if (particle.tilt.velocity && decay !== 1) {
|
|
25
|
-
particle.tilt.velocity *= decay;
|
|
26
|
-
}
|
|
27
|
-
}
|
package/cjs/Utils.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateTilt = void 0;
|
|
4
|
-
function updateTilt(particle, delta) {
|
|
5
|
-
if (!particle.tilt || !particle.options.tilt) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const tilt = particle.options.tilt, tiltAnimation = tilt.animation, speed = (particle.tilt.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = particle.tilt.decay ?? 1;
|
|
9
|
-
if (!tiltAnimation.enable) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
switch (particle.tilt.status) {
|
|
13
|
-
case "increasing":
|
|
14
|
-
particle.tilt.value += speed;
|
|
15
|
-
if (particle.tilt.value > max) {
|
|
16
|
-
particle.tilt.value -= max;
|
|
17
|
-
}
|
|
18
|
-
break;
|
|
19
|
-
case "decreasing":
|
|
20
|
-
default:
|
|
21
|
-
particle.tilt.value -= speed;
|
|
22
|
-
if (particle.tilt.value < 0) {
|
|
23
|
-
particle.tilt.value += max;
|
|
24
|
-
}
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
if (particle.tilt.velocity && decay !== 1) {
|
|
28
|
-
particle.tilt.velocity *= decay;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.updateTilt = updateTilt;
|
package/esm/Utils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function updateTilt(particle, delta) {
|
|
2
|
-
if (!particle.tilt || !particle.options.tilt) {
|
|
3
|
-
return;
|
|
4
|
-
}
|
|
5
|
-
const tilt = particle.options.tilt, tiltAnimation = tilt.animation, speed = (particle.tilt.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = particle.tilt.decay ?? 1;
|
|
6
|
-
if (!tiltAnimation.enable) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
switch (particle.tilt.status) {
|
|
10
|
-
case "increasing":
|
|
11
|
-
particle.tilt.value += speed;
|
|
12
|
-
if (particle.tilt.value > max) {
|
|
13
|
-
particle.tilt.value -= max;
|
|
14
|
-
}
|
|
15
|
-
break;
|
|
16
|
-
case "decreasing":
|
|
17
|
-
default:
|
|
18
|
-
particle.tilt.value -= speed;
|
|
19
|
-
if (particle.tilt.value < 0) {
|
|
20
|
-
particle.tilt.value += max;
|
|
21
|
-
}
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
if (particle.tilt.velocity && decay !== 1) {
|
|
25
|
-
particle.tilt.velocity *= decay;
|
|
26
|
-
}
|
|
27
|
-
}
|
package/types/Utils.d.ts
DELETED
package/umd/Utils.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
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
|
-
exports.updateTilt = void 0;
|
|
13
|
-
function updateTilt(particle, delta) {
|
|
14
|
-
if (!particle.tilt || !particle.options.tilt) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const tilt = particle.options.tilt, tiltAnimation = tilt.animation, speed = (particle.tilt.velocity ?? 0) * delta.factor, max = 2 * Math.PI, decay = particle.tilt.decay ?? 1;
|
|
18
|
-
if (!tiltAnimation.enable) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
switch (particle.tilt.status) {
|
|
22
|
-
case "increasing":
|
|
23
|
-
particle.tilt.value += speed;
|
|
24
|
-
if (particle.tilt.value > max) {
|
|
25
|
-
particle.tilt.value -= max;
|
|
26
|
-
}
|
|
27
|
-
break;
|
|
28
|
-
case "decreasing":
|
|
29
|
-
default:
|
|
30
|
-
particle.tilt.value -= speed;
|
|
31
|
-
if (particle.tilt.value < 0) {
|
|
32
|
-
particle.tilt.value += max;
|
|
33
|
-
}
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
if (particle.tilt.velocity && decay !== 1) {
|
|
37
|
-
particle.tilt.velocity *= decay;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.updateTilt = updateTilt;
|
|
41
|
-
});
|