@tsparticles/updater-rotate 3.0.0-beta.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/LICENSE +21 -0
- package/README.md +74 -0
- package/browser/Options/Classes/Rotate.js +24 -0
- package/browser/Options/Classes/RotateAnimation.js +26 -0
- package/browser/Options/Interfaces/IRotate.js +1 -0
- package/browser/Options/Interfaces/IRotateAnimation.js +1 -0
- package/browser/RotateUpdater.js +92 -0
- package/browser/index.js +4 -0
- package/cjs/Options/Classes/Rotate.js +28 -0
- package/cjs/Options/Classes/RotateAnimation.js +30 -0
- package/cjs/Options/Interfaces/IRotate.js +2 -0
- package/cjs/Options/Interfaces/IRotateAnimation.js +2 -0
- package/cjs/RotateUpdater.js +96 -0
- package/cjs/index.js +8 -0
- package/esm/Options/Classes/Rotate.js +24 -0
- package/esm/Options/Classes/RotateAnimation.js +26 -0
- package/esm/Options/Interfaces/IRotate.js +1 -0
- package/esm/Options/Interfaces/IRotateAnimation.js +1 -0
- package/esm/RotateUpdater.js +92 -0
- package/esm/index.js +4 -0
- package/package.json +83 -0
- package/report.html +39 -0
- package/tsparticles.updater.rotate.js +257 -0
- package/tsparticles.updater.rotate.min.js +2 -0
- package/tsparticles.updater.rotate.min.js.LICENSE.txt +1 -0
- package/types/Options/Classes/Rotate.d.ts +10 -0
- package/types/Options/Classes/RotateAnimation.d.ts +10 -0
- package/types/Options/Interfaces/IRotate.d.ts +7 -0
- package/types/Options/Interfaces/IRotateAnimation.d.ts +7 -0
- package/types/RotateUpdater.d.ts +22 -0
- package/types/index.d.ts +2 -0
- package/umd/Options/Classes/Rotate.js +38 -0
- package/umd/Options/Classes/RotateAnimation.js +40 -0
- package/umd/Options/Interfaces/IRotate.js +12 -0
- package/umd/Options/Interfaces/IRotateAnimation.js +12 -0
- package/umd/RotateUpdater.js +106 -0
- package/umd/index.js +18 -0
|
@@ -0,0 +1,257 @@
|
|
|
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
|
+
* v3.0.0-beta.0
|
|
8
|
+
*/
|
|
9
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
|
+
if(typeof exports === 'object' && typeof module === 'object')
|
|
11
|
+
module.exports = factory(require("@tsparticles/engine"));
|
|
12
|
+
else if(typeof define === 'function' && define.amd)
|
|
13
|
+
define(["@tsparticles/engine"], factory);
|
|
14
|
+
else {
|
|
15
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
|
+
}
|
|
18
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__533__) => {
|
|
19
|
+
return /******/ (() => { // webpackBootstrap
|
|
20
|
+
/******/ "use strict";
|
|
21
|
+
/******/ var __webpack_modules__ = ({
|
|
22
|
+
|
|
23
|
+
/***/ 533:
|
|
24
|
+
/***/ ((module) => {
|
|
25
|
+
|
|
26
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
27
|
+
|
|
28
|
+
/***/ })
|
|
29
|
+
|
|
30
|
+
/******/ });
|
|
31
|
+
/************************************************************************/
|
|
32
|
+
/******/ // The module cache
|
|
33
|
+
/******/ var __webpack_module_cache__ = {};
|
|
34
|
+
/******/
|
|
35
|
+
/******/ // The require function
|
|
36
|
+
/******/ function __webpack_require__(moduleId) {
|
|
37
|
+
/******/ // Check if module is in cache
|
|
38
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
39
|
+
/******/ if (cachedModule !== undefined) {
|
|
40
|
+
/******/ return cachedModule.exports;
|
|
41
|
+
/******/ }
|
|
42
|
+
/******/ // Create a new module (and put it into the cache)
|
|
43
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
44
|
+
/******/ // no module.id needed
|
|
45
|
+
/******/ // no module.loaded needed
|
|
46
|
+
/******/ exports: {}
|
|
47
|
+
/******/ };
|
|
48
|
+
/******/
|
|
49
|
+
/******/ // Execute the module function
|
|
50
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
51
|
+
/******/
|
|
52
|
+
/******/ // Return the exports of the module
|
|
53
|
+
/******/ return module.exports;
|
|
54
|
+
/******/ }
|
|
55
|
+
/******/
|
|
56
|
+
/************************************************************************/
|
|
57
|
+
/******/ /* webpack/runtime/define property getters */
|
|
58
|
+
/******/ (() => {
|
|
59
|
+
/******/ // define getter functions for harmony exports
|
|
60
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
61
|
+
/******/ for(var key in definition) {
|
|
62
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
63
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
64
|
+
/******/ }
|
|
65
|
+
/******/ }
|
|
66
|
+
/******/ };
|
|
67
|
+
/******/ })();
|
|
68
|
+
/******/
|
|
69
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
|
+
/******/ (() => {
|
|
71
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
|
+
/******/ })();
|
|
73
|
+
/******/
|
|
74
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
75
|
+
/******/ (() => {
|
|
76
|
+
/******/ // define __esModule on exports
|
|
77
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
78
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
/******/ }
|
|
81
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
/******/ };
|
|
83
|
+
/******/ })();
|
|
84
|
+
/******/
|
|
85
|
+
/************************************************************************/
|
|
86
|
+
var __webpack_exports__ = {};
|
|
87
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
88
|
+
(() => {
|
|
89
|
+
// ESM COMPAT FLAG
|
|
90
|
+
__webpack_require__.r(__webpack_exports__);
|
|
91
|
+
|
|
92
|
+
// EXPORTS
|
|
93
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
+
loadRotateUpdater: () => (/* binding */ loadRotateUpdater)
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
|
+
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/RotateAnimation.js
|
|
100
|
+
|
|
101
|
+
class RotateAnimation {
|
|
102
|
+
constructor() {
|
|
103
|
+
this.enable = false;
|
|
104
|
+
this.speed = 0;
|
|
105
|
+
this.decay = 0;
|
|
106
|
+
this.sync = false;
|
|
107
|
+
}
|
|
108
|
+
load(data) {
|
|
109
|
+
if (!data) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (data.enable !== undefined) {
|
|
113
|
+
this.enable = data.enable;
|
|
114
|
+
}
|
|
115
|
+
if (data.speed !== undefined) {
|
|
116
|
+
this.speed = (0,engine_root_window_.setRangeValue)(data.speed);
|
|
117
|
+
}
|
|
118
|
+
if (data.decay !== undefined) {
|
|
119
|
+
this.decay = (0,engine_root_window_.setRangeValue)(data.decay);
|
|
120
|
+
}
|
|
121
|
+
if (data.sync !== undefined) {
|
|
122
|
+
this.sync = data.sync;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Rotate.js
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
class Rotate extends engine_root_window_.ValueWithRandom {
|
|
130
|
+
constructor() {
|
|
131
|
+
super();
|
|
132
|
+
this.animation = new RotateAnimation();
|
|
133
|
+
this.direction = "clockwise";
|
|
134
|
+
this.path = false;
|
|
135
|
+
this.value = 0;
|
|
136
|
+
}
|
|
137
|
+
load(data) {
|
|
138
|
+
if (!data) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
super.load(data);
|
|
142
|
+
if (data.direction !== undefined) {
|
|
143
|
+
this.direction = data.direction;
|
|
144
|
+
}
|
|
145
|
+
this.animation.load(data.animation);
|
|
146
|
+
if (data.path !== undefined) {
|
|
147
|
+
this.path = data.path;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
;// CONCATENATED MODULE: ./dist/browser/RotateUpdater.js
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
function updateRotate(particle, delta) {
|
|
155
|
+
const rotate = particle.rotate,
|
|
156
|
+
rotateOptions = particle.options.rotate;
|
|
157
|
+
if (!rotate || !rotateOptions) {
|
|
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
|
+
}
|
|
186
|
+
class RotateUpdater {
|
|
187
|
+
constructor(container) {
|
|
188
|
+
this.container = container;
|
|
189
|
+
}
|
|
190
|
+
init(particle) {
|
|
191
|
+
const rotateOptions = particle.options.rotate;
|
|
192
|
+
if (!rotateOptions) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
particle.rotate = {
|
|
196
|
+
enable: rotateOptions.animation.enable,
|
|
197
|
+
value: (0,engine_root_window_.getRangeValue)(rotateOptions.value) * Math.PI / 180
|
|
198
|
+
};
|
|
199
|
+
particle.pathRotation = rotateOptions.path;
|
|
200
|
+
let rotateDirection = rotateOptions.direction;
|
|
201
|
+
if (rotateDirection === "random") {
|
|
202
|
+
const index = Math.floor((0,engine_root_window_.getRandom)() * 2);
|
|
203
|
+
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
|
|
204
|
+
}
|
|
205
|
+
switch (rotateDirection) {
|
|
206
|
+
case "counter-clockwise":
|
|
207
|
+
case "counterClockwise":
|
|
208
|
+
particle.rotate.status = "decreasing";
|
|
209
|
+
break;
|
|
210
|
+
case "clockwise":
|
|
211
|
+
particle.rotate.status = "increasing";
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
const rotateAnimation = rotateOptions.animation;
|
|
215
|
+
if (rotateAnimation.enable) {
|
|
216
|
+
particle.rotate.decay = 1 - (0,engine_root_window_.getRangeValue)(rotateAnimation.decay);
|
|
217
|
+
particle.rotate.velocity = (0,engine_root_window_.getRangeValue)(rotateAnimation.speed) / 360 * this.container.retina.reduceFactor;
|
|
218
|
+
if (!rotateAnimation.sync) {
|
|
219
|
+
particle.rotate.velocity *= (0,engine_root_window_.getRandom)();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
particle.rotation = particle.rotate.value;
|
|
223
|
+
}
|
|
224
|
+
isEnabled(particle) {
|
|
225
|
+
const rotate = particle.options.rotate;
|
|
226
|
+
if (!rotate) {
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
return !particle.destroyed && !particle.spawning && rotate.animation.enable && !rotate.path;
|
|
230
|
+
}
|
|
231
|
+
loadOptions(options, ...sources) {
|
|
232
|
+
if (!options.rotate) {
|
|
233
|
+
options.rotate = new Rotate();
|
|
234
|
+
}
|
|
235
|
+
for (const source of sources) {
|
|
236
|
+
options.rotate.load(source?.rotate);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
update(particle, delta) {
|
|
240
|
+
if (!this.isEnabled(particle)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
updateRotate(particle, delta);
|
|
244
|
+
particle.rotation = particle.rotate?.value ?? 0;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
248
|
+
|
|
249
|
+
async function loadRotateUpdater(engine, refresh = true) {
|
|
250
|
+
await engine.addParticleUpdater("rotate", container => new RotateUpdater(container), refresh);
|
|
251
|
+
}
|
|
252
|
+
})();
|
|
253
|
+
|
|
254
|
+
/******/ return __webpack_exports__;
|
|
255
|
+
/******/ })()
|
|
256
|
+
;
|
|
257
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
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 a="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in a)("object"==typeof exports?exports:e)[o]=a[o]}}(this,(e=>(()=>{"use strict";var t={533:t=>{t.exports=e}},a={};function o(e){var n=a[e];if(void 0!==n)return n.exports;var i=a[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var a in t)o.o(t,a)&&!o.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{o.r(n),o.d(n,{loadRotateUpdater:()=>r});var e=o(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 a 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))}}class i{constructor(e){this.container=e}init(t){const a=t.options.rotate;if(!a)return;t.rotate={enable:a.animation.enable,value:(0,e.getRangeValue)(a.value)*Math.PI/180},t.pathRotation=a.path;let o=a.direction;if("random"===o){o=Math.floor(2*(0,e.getRandom)())>0?"counter-clockwise":"clockwise"}switch(o){case"counter-clockwise":case"counterClockwise":t.rotate.status="decreasing";break;case"clockwise":t.rotate.status="increasing"}const n=a.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 a);for(const a of t)e.rotate.load(a?.rotate)}update(e,t){this.isEnabled(e)&&(!function(e,t){const a=e.rotate,o=e.options.rotate;if(!a||!o)return;const n=o.animation,i=(a.velocity??0)*t.factor,r=2*Math.PI,s=a.decay??1;n.enable&&("increasing"===a.status?(a.value+=i,a.value>r&&(a.value-=r)):(a.value-=i,a.value<0&&(a.value+=r)),a.velocity&&1!==s&&(a.velocity*=s))}(e,t),e.rotation=e.rotate?.value??0)}}async function r(e,t=!0){await e.addParticleUpdater("rotate",(e=>new i(e)),t)}})(),n})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Rotate Updater v3.0.0-beta.0 by Matteo Bruni */
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IOptionLoader, type RecursivePartial, RotateDirection, type RotateDirectionAlt, ValueWithRandom } from "@tsparticles/engine";
|
|
2
|
+
import type { IRotate } from "../Interfaces/IRotate";
|
|
3
|
+
import { RotateAnimation } from "./RotateAnimation";
|
|
4
|
+
export declare class Rotate extends ValueWithRandom implements IRotate, IOptionLoader<IRotate> {
|
|
5
|
+
animation: RotateAnimation;
|
|
6
|
+
direction: RotateDirection | keyof typeof RotateDirection | RotateDirectionAlt;
|
|
7
|
+
path: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
load(data?: RecursivePartial<IRotate>): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type IOptionLoader, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IRotateAnimation } from "../Interfaces/IRotateAnimation";
|
|
3
|
+
export declare class RotateAnimation implements IRotateAnimation, IOptionLoader<IRotateAnimation> {
|
|
4
|
+
decay: RangeValue;
|
|
5
|
+
enable: boolean;
|
|
6
|
+
speed: RangeValue;
|
|
7
|
+
sync: boolean;
|
|
8
|
+
constructor();
|
|
9
|
+
load(data?: RecursivePartial<IRotateAnimation>): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IValueWithRandom, RotateDirection, RotateDirectionAlt } from "@tsparticles/engine";
|
|
2
|
+
import type { IRotateAnimation } from "./IRotateAnimation";
|
|
3
|
+
export interface IRotate extends IValueWithRandom {
|
|
4
|
+
animation: IRotateAnimation;
|
|
5
|
+
direction: RotateDirection | keyof typeof RotateDirection | RotateDirectionAlt;
|
|
6
|
+
path: boolean;
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Container, type IDelta, type IParticleUpdater, type IParticleValueAnimation, type IParticlesOptions, type Particle, type ParticlesOptions, type RecursivePartial } from "@tsparticles/engine";
|
|
2
|
+
import type { IRotate } from "./Options/Interfaces/IRotate";
|
|
3
|
+
import { Rotate } from "./Options/Classes/Rotate";
|
|
4
|
+
type RotateParticle = Particle & {
|
|
5
|
+
options: RotateParticlesOptions;
|
|
6
|
+
rotate?: IParticleValueAnimation<number>;
|
|
7
|
+
};
|
|
8
|
+
type IRotateParticlesOptions = IParticlesOptions & {
|
|
9
|
+
rotate?: IRotate;
|
|
10
|
+
};
|
|
11
|
+
type RotateParticlesOptions = ParticlesOptions & {
|
|
12
|
+
rotate?: Rotate;
|
|
13
|
+
};
|
|
14
|
+
export declare class RotateUpdater implements IParticleUpdater {
|
|
15
|
+
private readonly container;
|
|
16
|
+
constructor(container: Container);
|
|
17
|
+
init(particle: RotateParticle): void;
|
|
18
|
+
isEnabled(particle: RotateParticle): boolean;
|
|
19
|
+
loadOptions(options: RotateParticlesOptions, ...sources: (RecursivePartial<IRotateParticlesOptions> | undefined)[]): void;
|
|
20
|
+
update(particle: RotateParticle, delta: IDelta): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./RotateAnimation"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Rotate = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const RotateAnimation_1 = require("./RotateAnimation");
|
|
15
|
+
class Rotate extends engine_1.ValueWithRandom {
|
|
16
|
+
constructor() {
|
|
17
|
+
super();
|
|
18
|
+
this.animation = new RotateAnimation_1.RotateAnimation();
|
|
19
|
+
this.direction = "clockwise";
|
|
20
|
+
this.path = false;
|
|
21
|
+
this.value = 0;
|
|
22
|
+
}
|
|
23
|
+
load(data) {
|
|
24
|
+
if (!data) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
super.load(data);
|
|
28
|
+
if (data.direction !== undefined) {
|
|
29
|
+
this.direction = data.direction;
|
|
30
|
+
}
|
|
31
|
+
this.animation.load(data.animation);
|
|
32
|
+
if (data.path !== undefined) {
|
|
33
|
+
this.path = data.path;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.Rotate = Rotate;
|
|
38
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RotateAnimation = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class RotateAnimation {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.enable = false;
|
|
17
|
+
this.speed = 0;
|
|
18
|
+
this.decay = 0;
|
|
19
|
+
this.sync = false;
|
|
20
|
+
}
|
|
21
|
+
load(data) {
|
|
22
|
+
if (!data) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (data.enable !== undefined) {
|
|
26
|
+
this.enable = data.enable;
|
|
27
|
+
}
|
|
28
|
+
if (data.speed !== undefined) {
|
|
29
|
+
this.speed = (0, engine_1.setRangeValue)(data.speed);
|
|
30
|
+
}
|
|
31
|
+
if (data.decay !== undefined) {
|
|
32
|
+
this.decay = (0, engine_1.setRangeValue)(data.decay);
|
|
33
|
+
}
|
|
34
|
+
if (data.sync !== undefined) {
|
|
35
|
+
this.sync = data.sync;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.RotateAnimation = RotateAnimation;
|
|
40
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Rotate"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RotateUpdater = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const Rotate_1 = require("./Options/Classes/Rotate");
|
|
15
|
+
function updateRotate(particle, delta) {
|
|
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
|
+
}
|
|
43
|
+
class RotateUpdater {
|
|
44
|
+
constructor(container) {
|
|
45
|
+
this.container = container;
|
|
46
|
+
}
|
|
47
|
+
init(particle) {
|
|
48
|
+
const rotateOptions = particle.options.rotate;
|
|
49
|
+
if (!rotateOptions) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
particle.rotate = {
|
|
53
|
+
enable: rotateOptions.animation.enable,
|
|
54
|
+
value: ((0, engine_1.getRangeValue)(rotateOptions.value) * Math.PI) / 180,
|
|
55
|
+
};
|
|
56
|
+
particle.pathRotation = rotateOptions.path;
|
|
57
|
+
let rotateDirection = rotateOptions.direction;
|
|
58
|
+
if (rotateDirection === "random") {
|
|
59
|
+
const index = Math.floor((0, engine_1.getRandom)() * 2);
|
|
60
|
+
rotateDirection = index > 0 ? "counter-clockwise" : "clockwise";
|
|
61
|
+
}
|
|
62
|
+
switch (rotateDirection) {
|
|
63
|
+
case "counter-clockwise":
|
|
64
|
+
case "counterClockwise":
|
|
65
|
+
particle.rotate.status = "decreasing";
|
|
66
|
+
break;
|
|
67
|
+
case "clockwise":
|
|
68
|
+
particle.rotate.status = "increasing";
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
const rotateAnimation = rotateOptions.animation;
|
|
72
|
+
if (rotateAnimation.enable) {
|
|
73
|
+
particle.rotate.decay = 1 - (0, engine_1.getRangeValue)(rotateAnimation.decay);
|
|
74
|
+
particle.rotate.velocity =
|
|
75
|
+
((0, engine_1.getRangeValue)(rotateAnimation.speed) / 360) * this.container.retina.reduceFactor;
|
|
76
|
+
if (!rotateAnimation.sync) {
|
|
77
|
+
particle.rotate.velocity *= (0, engine_1.getRandom)();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
particle.rotation = particle.rotate.value;
|
|
81
|
+
}
|
|
82
|
+
isEnabled(particle) {
|
|
83
|
+
const rotate = particle.options.rotate;
|
|
84
|
+
if (!rotate) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return !particle.destroyed && !particle.spawning && rotate.animation.enable && !rotate.path;
|
|
88
|
+
}
|
|
89
|
+
loadOptions(options, ...sources) {
|
|
90
|
+
if (!options.rotate) {
|
|
91
|
+
options.rotate = new Rotate_1.Rotate();
|
|
92
|
+
}
|
|
93
|
+
for (const source of sources) {
|
|
94
|
+
options.rotate.load(source?.rotate);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
update(particle, delta) {
|
|
98
|
+
if (!this.isEnabled(particle)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
updateRotate(particle, delta);
|
|
102
|
+
particle.rotation = particle.rotate?.value ?? 0;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.RotateUpdater = RotateUpdater;
|
|
106
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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", "./RotateUpdater"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.loadRotateUpdater = void 0;
|
|
13
|
+
const RotateUpdater_1 = require("./RotateUpdater");
|
|
14
|
+
async function loadRotateUpdater(engine, refresh = true) {
|
|
15
|
+
await engine.addParticleUpdater("rotate", (container) => new RotateUpdater_1.RotateUpdater(container), refresh);
|
|
16
|
+
}
|
|
17
|
+
exports.loadRotateUpdater = loadRotateUpdater;
|
|
18
|
+
});
|