@tsparticles/updater-rotate 3.9.1 → 4.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/8.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 8.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_updater_rotate=this.webpackChunk_tsparticles_updater_rotate||[]).push([[8],{8(t,e,a){a.d(e,{RotateUpdater:()=>r});var o=a(303);class i{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){(0,o.isNull)(t)||(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,o.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,o.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class n extends o.ValueWithRandom{constructor(){super(),this.animation=new i,this.direction=o.RotateDirection.clockwise,this.path=!1,this.value=0}load(t){(0,o.isNull)(t)||(super.load(t),void 0!==t.direction&&(this.direction=t.direction),this.animation.load(t.animation),void 0!==t.path&&(this.path=t.path))}}const s=2*Math.PI;class r{constructor(t){this.container=t}init(t){const e=t.options.rotate;if(!e)return;t.rotate={enable:e.animation.enable,value:(0,o.degToRad)((0,o.getRangeValue)(e.value)),min:0,max:s},t.pathRotation=e.path;let a=e.direction;if(a===o.RotateDirection.random){a=Math.floor(2*(0,o.getRandom)())>0?o.RotateDirection.counterClockwise:o.RotateDirection.clockwise}switch(a){case o.RotateDirection.counterClockwise:case"counterClockwise":t.rotate.status=o.AnimationStatus.decreasing;break;case o.RotateDirection.clockwise:t.rotate.status=o.AnimationStatus.increasing}const i=e.animation;i.enable&&(t.rotate.decay=1-(0,o.getRangeValue)(i.decay),t.rotate.velocity=(0,o.getRangeValue)(i.speed)/360*this.container.retina.reduceFactor,i.sync||(t.rotate.velocity*=(0,o.getRandom)())),t.rotation=t.rotate.value}isEnabled(t){const e=t.options.rotate;return!!e&&(!t.destroyed&&!t.spawning&&(!!e.value||e.animation.enable||e.path))}loadOptions(t,...e){t.rotate??=new n;for(const a of e)t.rotate.load(a?.rotate)}update(t,e){this.isEnabled(t)&&(t.isRotating=!!t.rotate,t.rotate&&((0,o.updateAnimation)(t,t.rotate,!1,o.DestroyType.none,e),t.rotation=t.rotate.value))}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Rotate Updater v4.0.0-alpha.0 by Matteo Bruni */
@@ -50,9 +50,7 @@ export class RotateUpdater {
50
50
  return !particle.destroyed && !particle.spawning && (!!rotate.value || rotate.animation.enable || rotate.path);
51
51
  }
52
52
  loadOptions(options, ...sources) {
53
- if (!options.rotate) {
54
- options.rotate = new Rotate();
55
- }
53
+ options.rotate ??= new Rotate();
56
54
  for (const source of sources) {
57
55
  options.rotate.load(source?.rotate);
58
56
  }
package/browser/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { RotateUpdater } from "./RotateUpdater.js";
2
- export async function loadRotateUpdater(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addParticleUpdater("rotate", container => {
5
- return Promise.resolve(new RotateUpdater(container));
6
- }, refresh);
1
+ export function loadRotateUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("rotate", async (container) => {
5
+ const { RotateUpdater } = await import("./RotateUpdater.js");
6
+ return new RotateUpdater(container);
7
+ });
8
+ });
7
9
  }
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Rotate = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const RotateAnimation_js_1 = require("./RotateAnimation.js");
6
- class Rotate extends engine_1.ValueWithRandom {
1
+ import { RotateDirection, ValueWithRandom, isNull, } from "@tsparticles/engine";
2
+ import { RotateAnimation } from "./RotateAnimation.js";
3
+ export class Rotate extends ValueWithRandom {
7
4
  constructor() {
8
5
  super();
9
- this.animation = new RotateAnimation_js_1.RotateAnimation();
10
- this.direction = engine_1.RotateDirection.clockwise;
6
+ this.animation = new RotateAnimation();
7
+ this.direction = RotateDirection.clockwise;
11
8
  this.path = false;
12
9
  this.value = 0;
13
10
  }
14
11
  load(data) {
15
- if ((0, engine_1.isNull)(data)) {
12
+ if (isNull(data)) {
16
13
  return;
17
14
  }
18
15
  super.load(data);
@@ -25,4 +22,3 @@ class Rotate extends engine_1.ValueWithRandom {
25
22
  }
26
23
  }
27
24
  }
28
- exports.Rotate = Rotate;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RotateAnimation = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class RotateAnimation {
1
+ import { isNull, setRangeValue } from "@tsparticles/engine";
2
+ export class RotateAnimation {
6
3
  constructor() {
7
4
  this.enable = false;
8
5
  this.speed = 0;
@@ -10,21 +7,20 @@ class RotateAnimation {
10
7
  this.sync = false;
11
8
  }
12
9
  load(data) {
13
- if ((0, engine_1.isNull)(data)) {
10
+ if (isNull(data)) {
14
11
  return;
15
12
  }
16
13
  if (data.enable !== undefined) {
17
14
  this.enable = data.enable;
18
15
  }
19
16
  if (data.speed !== undefined) {
20
- this.speed = (0, engine_1.setRangeValue)(data.speed);
17
+ this.speed = setRangeValue(data.speed);
21
18
  }
22
19
  if (data.decay !== undefined) {
23
- this.decay = (0, engine_1.setRangeValue)(data.decay);
20
+ this.decay = setRangeValue(data.decay);
24
21
  }
25
22
  if (data.sync !== undefined) {
26
23
  this.sync = data.sync;
27
24
  }
28
25
  }
29
26
  }
30
- exports.RotateAnimation = RotateAnimation;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RotateUpdater = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const Rotate_js_1 = require("./Options/Classes/Rotate.js");
1
+ import { AnimationStatus, DestroyType, RotateDirection, degToRad, getRandom, getRangeValue, updateAnimation, } from "@tsparticles/engine";
2
+ import { Rotate } from "./Options/Classes/Rotate.js";
6
3
  const double = 2, doublePI = Math.PI * double, identity = 1, doublePIDeg = 360;
7
- class RotateUpdater {
4
+ export class RotateUpdater {
8
5
  constructor(container) {
9
6
  this.container = container;
10
7
  }
@@ -15,32 +12,32 @@ class RotateUpdater {
15
12
  }
16
13
  particle.rotate = {
17
14
  enable: rotateOptions.animation.enable,
18
- value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(rotateOptions.value)),
15
+ value: degToRad(getRangeValue(rotateOptions.value)),
19
16
  min: 0,
20
17
  max: doublePI,
21
18
  };
22
19
  particle.pathRotation = rotateOptions.path;
23
20
  let rotateDirection = rotateOptions.direction;
24
- if (rotateDirection === engine_1.RotateDirection.random) {
25
- const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
26
- rotateDirection = index > minIndex ? engine_1.RotateDirection.counterClockwise : engine_1.RotateDirection.clockwise;
21
+ if (rotateDirection === RotateDirection.random) {
22
+ const index = Math.floor(getRandom() * double), minIndex = 0;
23
+ rotateDirection = index > minIndex ? RotateDirection.counterClockwise : RotateDirection.clockwise;
27
24
  }
28
25
  switch (rotateDirection) {
29
- case engine_1.RotateDirection.counterClockwise:
26
+ case RotateDirection.counterClockwise:
30
27
  case "counterClockwise":
31
- particle.rotate.status = engine_1.AnimationStatus.decreasing;
28
+ particle.rotate.status = AnimationStatus.decreasing;
32
29
  break;
33
- case engine_1.RotateDirection.clockwise:
34
- particle.rotate.status = engine_1.AnimationStatus.increasing;
30
+ case RotateDirection.clockwise:
31
+ particle.rotate.status = AnimationStatus.increasing;
35
32
  break;
36
33
  }
37
34
  const rotateAnimation = rotateOptions.animation;
38
35
  if (rotateAnimation.enable) {
39
- particle.rotate.decay = identity - (0, engine_1.getRangeValue)(rotateAnimation.decay);
36
+ particle.rotate.decay = identity - getRangeValue(rotateAnimation.decay);
40
37
  particle.rotate.velocity =
41
- ((0, engine_1.getRangeValue)(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
38
+ (getRangeValue(rotateAnimation.speed) / doublePIDeg) * this.container.retina.reduceFactor;
42
39
  if (!rotateAnimation.sync) {
43
- particle.rotate.velocity *= (0, engine_1.getRandom)();
40
+ particle.rotate.velocity *= getRandom();
44
41
  }
45
42
  }
46
43
  particle.rotation = particle.rotate.value;
@@ -53,9 +50,7 @@ class RotateUpdater {
53
50
  return !particle.destroyed && !particle.spawning && (!!rotate.value || rotate.animation.enable || rotate.path);
54
51
  }
55
52
  loadOptions(options, ...sources) {
56
- if (!options.rotate) {
57
- options.rotate = new Rotate_js_1.Rotate();
58
- }
53
+ options.rotate ??= new Rotate();
59
54
  for (const source of sources) {
60
55
  options.rotate.load(source?.rotate);
61
56
  }
@@ -68,8 +63,7 @@ class RotateUpdater {
68
63
  if (!particle.rotate) {
69
64
  return;
70
65
  }
71
- (0, engine_1.updateAnimation)(particle, particle.rotate, false, engine_1.DestroyType.none, delta);
66
+ updateAnimation(particle, particle.rotate, false, DestroyType.none, delta);
72
67
  particle.rotation = particle.rotate.value;
73
68
  }
74
69
  }
75
- exports.RotateUpdater = RotateUpdater;
package/cjs/index.js CHANGED
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadRotateUpdater = loadRotateUpdater;
4
- const RotateUpdater_js_1 = require("./RotateUpdater.js");
5
- async function loadRotateUpdater(engine, refresh = true) {
6
- engine.checkVersion("3.9.1");
7
- await engine.addParticleUpdater("rotate", container => {
8
- return Promise.resolve(new RotateUpdater_js_1.RotateUpdater(container));
9
- }, refresh);
1
+ export function loadRotateUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("rotate", async (container) => {
5
+ const { RotateUpdater } = await import("./RotateUpdater.js");
6
+ return new RotateUpdater(container);
7
+ });
8
+ });
10
9
  }
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v4.0.0-alpha.0
8
+ */
9
+ "use strict";
10
+ /*
11
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
12
+ * This devtool is neither made for production nor for readable output files.
13
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
14
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
15
+ * or disable the default devtool with "devtool: false".
16
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
17
+ */
18
+ (this["webpackChunk_tsparticles_updater_rotate"] = this["webpackChunk_tsparticles_updater_rotate"] || []).push([["dist_browser_RotateUpdater_js"],{
19
+
20
+ /***/ "./dist/browser/Options/Classes/Rotate.js"
21
+ /*!************************************************!*\
22
+ !*** ./dist/browser/Options/Classes/Rotate.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 */ Rotate: () => (/* binding */ Rotate)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _RotateAnimation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./RotateAnimation.js */ \"./dist/browser/Options/Classes/RotateAnimation.js\");\n\n\nclass Rotate extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n constructor() {\n super();\n this.animation = new _RotateAnimation_js__WEBPACK_IMPORTED_MODULE_1__.RotateAnimation();\n this.direction = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise;\n this.path = false;\n this.value = 0;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n super.load(data);\n if (data.direction !== undefined) {\n this.direction = data.direction;\n }\n this.animation.load(data.animation);\n if (data.path !== undefined) {\n this.path = data.path;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-rotate/./dist/browser/Options/Classes/Rotate.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/Options/Classes/RotateAnimation.js"
31
+ /*!*********************************************************!*\
32
+ !*** ./dist/browser/Options/Classes/RotateAnimation.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 */ RotateAnimation: () => (/* binding */ RotateAnimation)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass RotateAnimation {\n constructor() {\n this.enable = false;\n this.speed = 0;\n this.decay = 0;\n this.sync = false;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.speed !== undefined) {\n this.speed = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.speed);\n }\n if (data.decay !== undefined) {\n this.decay = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.decay);\n }\n if (data.sync !== undefined) {\n this.sync = data.sync;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-rotate/./dist/browser/Options/Classes/RotateAnimation.js?\n}");
37
+
38
+ /***/ },
39
+
40
+ /***/ "./dist/browser/RotateUpdater.js"
41
+ /*!***************************************!*\
42
+ !*** ./dist/browser/RotateUpdater.js ***!
43
+ \***************************************/
44
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
45
+
46
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ RotateUpdater: () => (/* binding */ RotateUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Rotate_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Rotate.js */ \"./dist/browser/Options/Classes/Rotate.js\");\n\n\nconst double = 2,\n doublePI = Math.PI * double,\n identity = 1,\n doublePIDeg = 360;\nclass RotateUpdater {\n constructor(container) {\n this.container = container;\n }\n init(particle) {\n const rotateOptions = particle.options.rotate;\n if (!rotateOptions) {\n return;\n }\n particle.rotate = {\n enable: rotateOptions.animation.enable,\n value: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rotateOptions.value)),\n min: 0,\n max: doublePI\n };\n particle.pathRotation = rotateOptions.path;\n let rotateDirection = rotateOptions.direction;\n if (rotateDirection === _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.random) {\n const index = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * double),\n minIndex = 0;\n rotateDirection = index > minIndex ? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.counterClockwise : _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise;\n }\n switch (rotateDirection) {\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.counterClockwise:\n case \"counterClockwise\":\n particle.rotate.status = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimationStatus.decreasing;\n break;\n case _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.RotateDirection.clockwise:\n particle.rotate.status = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimationStatus.increasing;\n break;\n }\n const rotateAnimation = rotateOptions.animation;\n if (rotateAnimation.enable) {\n particle.rotate.decay = identity - (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rotateAnimation.decay);\n particle.rotate.velocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(rotateAnimation.speed) / doublePIDeg * this.container.retina.reduceFactor;\n if (!rotateAnimation.sync) {\n particle.rotate.velocity *= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n }\n particle.rotation = particle.rotate.value;\n }\n isEnabled(particle) {\n const rotate = particle.options.rotate;\n if (!rotate) {\n return false;\n }\n return !particle.destroyed && !particle.spawning && (!!rotate.value || rotate.animation.enable || rotate.path);\n }\n loadOptions(options, ...sources) {\n options.rotate ??= new _Options_Classes_Rotate_js__WEBPACK_IMPORTED_MODULE_1__.Rotate();\n for (const source of sources) {\n options.rotate.load(source?.rotate);\n }\n }\n update(particle, delta) {\n if (!this.isEnabled(particle)) {\n return;\n }\n particle.isRotating = !!particle.rotate;\n if (!particle.rotate) {\n return;\n }\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.updateAnimation)(particle, particle.rotate, false, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.DestroyType.none, delta);\n particle.rotation = particle.rotate.value;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-rotate/./dist/browser/RotateUpdater.js?\n}");
47
+
48
+ /***/ }
49
+
50
+ }]);
@@ -50,9 +50,7 @@ export class RotateUpdater {
50
50
  return !particle.destroyed && !particle.spawning && (!!rotate.value || rotate.animation.enable || rotate.path);
51
51
  }
52
52
  loadOptions(options, ...sources) {
53
- if (!options.rotate) {
54
- options.rotate = new Rotate();
55
- }
53
+ options.rotate ??= new Rotate();
56
54
  for (const source of sources) {
57
55
  options.rotate.load(source?.rotate);
58
56
  }
package/esm/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { RotateUpdater } from "./RotateUpdater.js";
2
- export async function loadRotateUpdater(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addParticleUpdater("rotate", container => {
5
- return Promise.resolve(new RotateUpdater(container));
6
- }, refresh);
1
+ export function loadRotateUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("rotate", async (container) => {
5
+ const { RotateUpdater } = await import("./RotateUpdater.js");
6
+ return new RotateUpdater(container);
7
+ });
8
+ });
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-rotate",
3
- "version": "3.9.1",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "tsParticles particles rotate updater",
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": "3.9.1"
90
+ "@tsparticles/engine": "4.0.0-alpha.0"
91
91
  },
92
92
  "publishConfig": {
93
93
  "access": "public"
94
- }
94
+ },
95
+ "type": "module"
95
96
  }