@tsparticles/updater-tilt 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/233.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 233.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_updater_tilt=this.webpackChunk_tsparticles_updater_tilt||[]).push([[233],{233(t,e,i){i.d(e,{TiltUpdater:()=>l});var n,a=i(303);!function(t){t.clockwise="clockwise",t.counterClockwise="counter-clockwise",t.random="random"}(n||(n={}));class s{constructor(){this.enable=!1,this.speed=0,this.decay=0,this.sync=!1}load(t){(0,a.isNull)(t)||(void 0!==t.enable&&(this.enable=t.enable),void 0!==t.speed&&(this.speed=(0,a.setRangeValue)(t.speed)),void 0!==t.decay&&(this.decay=(0,a.setRangeValue)(t.decay)),void 0!==t.sync&&(this.sync=t.sync))}}class o extends a.ValueWithRandom{constructor(){super(),this.animation=new s,this.direction=n.clockwise,this.enable=!1,this.value=0}load(t){super.load(t),(0,a.isNull)(t)||(this.animation.load(t.animation),void 0!==t.direction&&(this.direction=t.direction),void 0!==t.enable&&(this.enable=t.enable))}}const c=2*Math.PI;class l{constructor(t){this.container=t}getTransformValues(t){const e=t.tilt?.enable&&t.tilt;return{b:e?Math.cos(e.value)*e.cosDirection:void 0,c:e?Math.sin(e.value)*e.sinDirection:void 0}}init(t){const e=t.options.tilt;if(!e)return;t.tilt={enable:e.enable,value:(0,a.degToRad)((0,a.getRangeValue)(e.value)),sinDirection:(0,a.getRandom)()>=a.half?1:-1,cosDirection:(0,a.getRandom)()>=a.half?1:-1,min:0,max:c};let i=e.direction;if(i===n.random){i=Math.floor(2*(0,a.getRandom)())>0?n.counterClockwise:n.clockwise}switch(i){case n.counterClockwise:case"counterClockwise":t.tilt.status=a.AnimationStatus.decreasing;break;case n.clockwise:t.tilt.status=a.AnimationStatus.increasing}const s=t.options.tilt?.animation;s?.enable&&(t.tilt.decay=1-(0,a.getRangeValue)(s.decay),t.tilt.velocity=(0,a.getRangeValue)(s.speed)/360*this.container.retina.reduceFactor,s.sync||(t.tilt.velocity*=(0,a.getRandom)()))}isEnabled(t){const e=t.options.tilt?.animation;return!t.destroyed&&!t.spawning&&!!e?.enable}loadOptions(t,...e){t.tilt??=new o;for(const i of e)t.tilt.load(i?.tilt)}update(t,e){this.isEnabled(t)&&t.tilt&&(0,a.updateAnimation)(t,t.tilt,!1,a.DestroyType.none,e)}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Tilt Updater v4.0.0-alpha.0 by Matteo Bruni */
@@ -55,18 +55,15 @@ export class TiltUpdater {
55
55
  return !particle.destroyed && !particle.spawning && !!tiltAnimation?.enable;
56
56
  }
57
57
  loadOptions(options, ...sources) {
58
- if (!options.tilt) {
59
- options.tilt = new Tilt();
60
- }
58
+ options.tilt ??= new Tilt();
61
59
  for (const source of sources) {
62
60
  options.tilt.load(source?.tilt);
63
61
  }
64
62
  }
65
- async update(particle, delta) {
63
+ update(particle, delta) {
66
64
  if (!this.isEnabled(particle) || !particle.tilt) {
67
65
  return;
68
66
  }
69
67
  updateAnimation(particle, particle.tilt, false, DestroyType.none, delta);
70
- await Promise.resolve();
71
68
  }
72
69
  }
package/browser/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { TiltUpdater } from "./TiltUpdater.js";
2
- export async function loadTiltUpdater(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addParticleUpdater("tilt", container => {
5
- return Promise.resolve(new TiltUpdater(container));
6
- }, refresh);
1
+ export function loadTiltUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("tilt", async (container) => {
5
+ const { TiltUpdater } = await import("./TiltUpdater.js");
6
+ return new TiltUpdater(container);
7
+ });
8
+ });
7
9
  }
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Tilt = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const TiltDirection_js_1 = require("../../TiltDirection.js");
6
- const TiltAnimation_js_1 = require("./TiltAnimation.js");
7
- class Tilt extends engine_1.ValueWithRandom {
1
+ import { ValueWithRandom, isNull } from "@tsparticles/engine";
2
+ import { TiltDirection } from "../../TiltDirection.js";
3
+ import { TiltAnimation } from "./TiltAnimation.js";
4
+ export class Tilt extends ValueWithRandom {
8
5
  constructor() {
9
6
  super();
10
- this.animation = new TiltAnimation_js_1.TiltAnimation();
11
- this.direction = TiltDirection_js_1.TiltDirection.clockwise;
7
+ this.animation = new TiltAnimation();
8
+ this.direction = TiltDirection.clockwise;
12
9
  this.enable = false;
13
10
  this.value = 0;
14
11
  }
15
12
  load(data) {
16
13
  super.load(data);
17
- if ((0, engine_1.isNull)(data)) {
14
+ if (isNull(data)) {
18
15
  return;
19
16
  }
20
17
  this.animation.load(data.animation);
@@ -26,4 +23,3 @@ class Tilt extends engine_1.ValueWithRandom {
26
23
  }
27
24
  }
28
25
  }
29
- exports.Tilt = Tilt;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TiltAnimation = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class TiltAnimation {
1
+ import { isNull, setRangeValue } from "@tsparticles/engine";
2
+ export class TiltAnimation {
6
3
  constructor() {
7
4
  this.enable = false;
8
5
  this.speed = 0;
@@ -10,21 +7,20 @@ class TiltAnimation {
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.TiltAnimation = TiltAnimation;
@@ -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,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TiltDirection = void 0;
4
- var TiltDirection;
1
+ export var TiltDirection;
5
2
  (function (TiltDirection) {
6
3
  TiltDirection["clockwise"] = "clockwise";
7
4
  TiltDirection["counterClockwise"] = "counter-clockwise";
8
5
  TiltDirection["random"] = "random";
9
- })(TiltDirection || (exports.TiltDirection = TiltDirection = {}));
6
+ })(TiltDirection || (TiltDirection = {}));
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TiltUpdater = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const Tilt_js_1 = require("./Options/Classes/Tilt.js");
6
- const TiltDirection_js_1 = require("./TiltDirection.js");
1
+ import { AnimationStatus, DestroyType, degToRad, getRandom, getRangeValue, half, updateAnimation, } from "@tsparticles/engine";
2
+ import { Tilt } from "./Options/Classes/Tilt.js";
3
+ import { TiltDirection } from "./TiltDirection.js";
7
4
  const identity = 1, double = 2, doublePI = Math.PI * double, maxAngle = 360;
8
- class TiltUpdater {
5
+ export class TiltUpdater {
9
6
  constructor(container) {
10
7
  this.container = container;
11
8
  }
@@ -23,33 +20,33 @@ class TiltUpdater {
23
20
  }
24
21
  particle.tilt = {
25
22
  enable: tiltOptions.enable,
26
- value: (0, engine_1.degToRad)((0, engine_1.getRangeValue)(tiltOptions.value)),
27
- sinDirection: (0, engine_1.getRandom)() >= engine_1.half ? identity : -identity,
28
- cosDirection: (0, engine_1.getRandom)() >= engine_1.half ? identity : -identity,
23
+ value: degToRad(getRangeValue(tiltOptions.value)),
24
+ sinDirection: getRandom() >= half ? identity : -identity,
25
+ cosDirection: getRandom() >= half ? identity : -identity,
29
26
  min: 0,
30
27
  max: doublePI,
31
28
  };
32
29
  let tiltDirection = tiltOptions.direction;
33
- if (tiltDirection === TiltDirection_js_1.TiltDirection.random) {
34
- const index = Math.floor((0, engine_1.getRandom)() * double), minIndex = 0;
35
- tiltDirection = index > minIndex ? TiltDirection_js_1.TiltDirection.counterClockwise : TiltDirection_js_1.TiltDirection.clockwise;
30
+ if (tiltDirection === TiltDirection.random) {
31
+ const index = Math.floor(getRandom() * double), minIndex = 0;
32
+ tiltDirection = index > minIndex ? TiltDirection.counterClockwise : TiltDirection.clockwise;
36
33
  }
37
34
  switch (tiltDirection) {
38
- case TiltDirection_js_1.TiltDirection.counterClockwise:
35
+ case TiltDirection.counterClockwise:
39
36
  case "counterClockwise":
40
- particle.tilt.status = engine_1.AnimationStatus.decreasing;
37
+ particle.tilt.status = AnimationStatus.decreasing;
41
38
  break;
42
- case TiltDirection_js_1.TiltDirection.clockwise:
43
- particle.tilt.status = engine_1.AnimationStatus.increasing;
39
+ case TiltDirection.clockwise:
40
+ particle.tilt.status = AnimationStatus.increasing;
44
41
  break;
45
42
  }
46
43
  const tiltAnimation = particle.options.tilt?.animation;
47
44
  if (tiltAnimation?.enable) {
48
- particle.tilt.decay = identity - (0, engine_1.getRangeValue)(tiltAnimation.decay);
45
+ particle.tilt.decay = identity - getRangeValue(tiltAnimation.decay);
49
46
  particle.tilt.velocity =
50
- ((0, engine_1.getRangeValue)(tiltAnimation.speed) / maxAngle) * this.container.retina.reduceFactor;
47
+ (getRangeValue(tiltAnimation.speed) / maxAngle) * this.container.retina.reduceFactor;
51
48
  if (!tiltAnimation.sync) {
52
- particle.tilt.velocity *= (0, engine_1.getRandom)();
49
+ particle.tilt.velocity *= getRandom();
53
50
  }
54
51
  }
55
52
  }
@@ -58,19 +55,15 @@ class TiltUpdater {
58
55
  return !particle.destroyed && !particle.spawning && !!tiltAnimation?.enable;
59
56
  }
60
57
  loadOptions(options, ...sources) {
61
- if (!options.tilt) {
62
- options.tilt = new Tilt_js_1.Tilt();
63
- }
58
+ options.tilt ??= new Tilt();
64
59
  for (const source of sources) {
65
60
  options.tilt.load(source?.tilt);
66
61
  }
67
62
  }
68
- async update(particle, delta) {
63
+ update(particle, delta) {
69
64
  if (!this.isEnabled(particle) || !particle.tilt) {
70
65
  return;
71
66
  }
72
- (0, engine_1.updateAnimation)(particle, particle.tilt, false, engine_1.DestroyType.none, delta);
73
- await Promise.resolve();
67
+ updateAnimation(particle, particle.tilt, false, DestroyType.none, delta);
74
68
  }
75
69
  }
76
- exports.TiltUpdater = TiltUpdater;
package/cjs/Types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/index.js CHANGED
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadTiltUpdater = loadTiltUpdater;
4
- const TiltUpdater_js_1 = require("./TiltUpdater.js");
5
- async function loadTiltUpdater(engine, refresh = true) {
6
- engine.checkVersion("3.9.1");
7
- await engine.addParticleUpdater("tilt", container => {
8
- return Promise.resolve(new TiltUpdater_js_1.TiltUpdater(container));
9
- }, refresh);
1
+ export function loadTiltUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("tilt", async (container) => {
5
+ const { TiltUpdater } = await import("./TiltUpdater.js");
6
+ return new TiltUpdater(container);
7
+ });
8
+ });
10
9
  }
@@ -0,0 +1,60 @@
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_tilt"] = this["webpackChunk_tsparticles_updater_tilt"] || []).push([["dist_browser_TiltUpdater_js"],{
19
+
20
+ /***/ "./dist/browser/Options/Classes/Tilt.js"
21
+ /*!**********************************************!*\
22
+ !*** ./dist/browser/Options/Classes/Tilt.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 */ Tilt: () => (/* binding */ Tilt)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _TiltDirection_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../TiltDirection.js */ \"./dist/browser/TiltDirection.js\");\n/* harmony import */ var _TiltAnimation_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TiltAnimation.js */ \"./dist/browser/Options/Classes/TiltAnimation.js\");\n\n\n\nclass Tilt extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n constructor() {\n super();\n this.animation = new _TiltAnimation_js__WEBPACK_IMPORTED_MODULE_2__.TiltAnimation();\n this.direction = _TiltDirection_js__WEBPACK_IMPORTED_MODULE_1__.TiltDirection.clockwise;\n this.enable = false;\n this.value = 0;\n }\n load(data) {\n super.load(data);\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n this.animation.load(data.animation);\n if (data.direction !== undefined) {\n this.direction = data.direction;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-tilt/./dist/browser/Options/Classes/Tilt.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/Options/Classes/TiltAnimation.js"
31
+ /*!*******************************************************!*\
32
+ !*** ./dist/browser/Options/Classes/TiltAnimation.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 */ TiltAnimation: () => (/* binding */ TiltAnimation)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass TiltAnimation {\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-tilt/./dist/browser/Options/Classes/TiltAnimation.js?\n}");
37
+
38
+ /***/ },
39
+
40
+ /***/ "./dist/browser/TiltDirection.js"
41
+ /*!***************************************!*\
42
+ !*** ./dist/browser/TiltDirection.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 */ TiltDirection: () => (/* binding */ TiltDirection)\n/* harmony export */ });\nvar TiltDirection;\n(function (TiltDirection) {\n TiltDirection[\"clockwise\"] = \"clockwise\";\n TiltDirection[\"counterClockwise\"] = \"counter-clockwise\";\n TiltDirection[\"random\"] = \"random\";\n})(TiltDirection || (TiltDirection = {}));\n\n//# sourceURL=webpack://@tsparticles/updater-tilt/./dist/browser/TiltDirection.js?\n}");
47
+
48
+ /***/ },
49
+
50
+ /***/ "./dist/browser/TiltUpdater.js"
51
+ /*!*************************************!*\
52
+ !*** ./dist/browser/TiltUpdater.js ***!
53
+ \*************************************/
54
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
55
+
56
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ TiltUpdater: () => (/* binding */ TiltUpdater)\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_Tilt_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Tilt.js */ \"./dist/browser/Options/Classes/Tilt.js\");\n/* harmony import */ var _TiltDirection_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./TiltDirection.js */ \"./dist/browser/TiltDirection.js\");\n\n\n\nconst identity = 1,\n double = 2,\n doublePI = Math.PI * double,\n maxAngle = 360;\nclass TiltUpdater {\n constructor(container) {\n this.container = container;\n }\n getTransformValues(particle) {\n const tilt = particle.tilt?.enable && particle.tilt;\n return {\n b: tilt ? Math.cos(tilt.value) * tilt.cosDirection : undefined,\n c: tilt ? Math.sin(tilt.value) * tilt.sinDirection : undefined\n };\n }\n init(particle) {\n const tiltOptions = particle.options.tilt;\n if (!tiltOptions) {\n return;\n }\n particle.tilt = {\n enable: tiltOptions.enable,\n value: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(tiltOptions.value)),\n sinDirection: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() >= _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half ? identity : -identity,\n cosDirection: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() >= _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half ? identity : -identity,\n min: 0,\n max: doublePI\n };\n let tiltDirection = tiltOptions.direction;\n if (tiltDirection === _TiltDirection_js__WEBPACK_IMPORTED_MODULE_2__.TiltDirection.random) {\n const index = Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * double),\n minIndex = 0;\n tiltDirection = index > minIndex ? _TiltDirection_js__WEBPACK_IMPORTED_MODULE_2__.TiltDirection.counterClockwise : _TiltDirection_js__WEBPACK_IMPORTED_MODULE_2__.TiltDirection.clockwise;\n }\n switch (tiltDirection) {\n case _TiltDirection_js__WEBPACK_IMPORTED_MODULE_2__.TiltDirection.counterClockwise:\n case \"counterClockwise\":\n particle.tilt.status = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimationStatus.decreasing;\n break;\n case _TiltDirection_js__WEBPACK_IMPORTED_MODULE_2__.TiltDirection.clockwise:\n particle.tilt.status = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimationStatus.increasing;\n break;\n }\n const tiltAnimation = particle.options.tilt?.animation;\n if (tiltAnimation?.enable) {\n particle.tilt.decay = identity - (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(tiltAnimation.decay);\n particle.tilt.velocity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(tiltAnimation.speed) / maxAngle * this.container.retina.reduceFactor;\n if (!tiltAnimation.sync) {\n particle.tilt.velocity *= (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)();\n }\n }\n }\n isEnabled(particle) {\n const tiltAnimation = particle.options.tilt?.animation;\n return !particle.destroyed && !particle.spawning && !!tiltAnimation?.enable;\n }\n loadOptions(options, ...sources) {\n options.tilt ??= new _Options_Classes_Tilt_js__WEBPACK_IMPORTED_MODULE_1__.Tilt();\n for (const source of sources) {\n options.tilt.load(source?.tilt);\n }\n }\n update(particle, delta) {\n if (!this.isEnabled(particle) || !particle.tilt) {\n return;\n }\n (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.updateAnimation)(particle, particle.tilt, false, _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.DestroyType.none, delta);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-tilt/./dist/browser/TiltUpdater.js?\n}");
57
+
58
+ /***/ }
59
+
60
+ }]);
@@ -55,18 +55,15 @@ export class TiltUpdater {
55
55
  return !particle.destroyed && !particle.spawning && !!tiltAnimation?.enable;
56
56
  }
57
57
  loadOptions(options, ...sources) {
58
- if (!options.tilt) {
59
- options.tilt = new Tilt();
60
- }
58
+ options.tilt ??= new Tilt();
61
59
  for (const source of sources) {
62
60
  options.tilt.load(source?.tilt);
63
61
  }
64
62
  }
65
- async update(particle, delta) {
63
+ update(particle, delta) {
66
64
  if (!this.isEnabled(particle) || !particle.tilt) {
67
65
  return;
68
66
  }
69
67
  updateAnimation(particle, particle.tilt, false, DestroyType.none, delta);
70
- await Promise.resolve();
71
68
  }
72
69
  }
package/esm/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { TiltUpdater } from "./TiltUpdater.js";
2
- export async function loadTiltUpdater(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addParticleUpdater("tilt", container => {
5
- return Promise.resolve(new TiltUpdater(container));
6
- }, refresh);
1
+ export function loadTiltUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("tilt", async (container) => {
5
+ const { TiltUpdater } = await import("./TiltUpdater.js");
6
+ return new TiltUpdater(container);
7
+ });
8
+ });
7
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-tilt",
3
- "version": "3.9.1",
3
+ "version": "4.0.0-alpha.0",
4
4
  "description": "tsParticles particles tilt 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
  }