@tsparticles/updater-orbit 3.0.0-alpha.0 → 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.
@@ -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.0-alpha.0
7
+ * v3.0.0-beta.0
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ __webpack_require__.r(__webpack_exports__);
91
91
 
92
92
  // EXPORTS
93
93
  __webpack_require__.d(__webpack_exports__, {
94
- "loadOrbitUpdater": () => (/* binding */ loadOrbitUpdater)
94
+ loadOrbitUpdater: () => (/* binding */ loadOrbitUpdater)
95
95
  });
96
96
 
97
97
  // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
@@ -146,8 +146,7 @@ class Orbit {
146
146
  }
147
147
  }
148
148
  }
149
- ;// CONCATENATED MODULE: ./dist/browser/OrbitUpdater.js
150
-
149
+ ;// CONCATENATED MODULE: ./dist/browser/Utils.js
151
150
 
152
151
  function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
153
152
  if (width <= 0) {
@@ -163,19 +162,23 @@ function drawEllipse(context, particle, fillColorValue, radius, opacity, width,
163
162
  context.ellipse(pos.x, pos.y, radius / 2, radius * 2, rotationRadian, start, end);
164
163
  context.stroke();
165
164
  }
165
+ ;// CONCATENATED MODULE: ./dist/browser/OrbitUpdater.js
166
+
167
+
168
+
166
169
  class OrbitUpdater {
167
170
  constructor(container) {
168
171
  this.container = container;
169
172
  }
170
173
  afterDraw(particle) {
171
174
  const orbitOptions = particle.options.orbit;
172
- if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
175
+ if (orbitOptions?.enable) {
173
176
  this.drawOrbit(particle, "front");
174
177
  }
175
178
  }
176
179
  beforeDraw(particle) {
177
180
  const orbitOptions = particle.options.orbit;
178
- if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
181
+ if (orbitOptions?.enable) {
179
182
  this.drawOrbit(particle, "back");
180
183
  }
181
184
  }
@@ -196,15 +199,14 @@ class OrbitUpdater {
196
199
  end = 2 * Math.PI;
197
200
  }
198
201
  container.canvas.draw(ctx => {
199
- var _a, _b, _c, _d, _e, _f;
200
- drawEllipse(ctx, particle, (_a = particle.orbitColor) !== null && _a !== void 0 ? _a : particle.getFillColor(), (_c = (_b = particle.retina.orbitRadius) !== null && _b !== void 0 ? _b : container.retina.orbitRadius) !== null && _c !== void 0 ? _c : particle.getRadius(), (_d = particle.orbitOpacity) !== null && _d !== void 0 ? _d : 1, (_e = particle.orbitWidth) !== null && _e !== void 0 ? _e : 1, ((_f = particle.orbitRotation) !== null && _f !== void 0 ? _f : 0) * container.retina.pixelRatio, start, end);
202
+ drawEllipse(ctx, particle, particle.orbitColor ?? particle.getFillColor(), particle.retina.orbitRadius ?? container.retina.orbitRadius ?? particle.getRadius(), particle.orbitOpacity ?? 1, particle.orbitWidth ?? 1, (particle.orbitRotation ?? 0) * container.retina.pixelRatio, start, end);
201
203
  });
202
204
  }
203
205
  init(particle) {
204
206
  const container = this.container,
205
207
  particlesOptions = particle.options,
206
208
  orbitOptions = particlesOptions.orbit;
207
- if (!(orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable)) {
209
+ if (!orbitOptions?.enable) {
208
210
  return;
209
211
  }
210
212
  particle.orbitRotation = (0,engine_root_window_.getRangeValue)(orbitOptions.rotation.value);
@@ -216,33 +218,31 @@ class OrbitUpdater {
216
218
  particle.orbitOpacity = (0,engine_root_window_.getRangeValue)(orbitOptions.opacity);
217
219
  }
218
220
  isEnabled(particle) {
219
- var _a;
220
- const orbitAnimations = (_a = particle.options.orbit) === null || _a === void 0 ? void 0 : _a.animation;
221
- return !particle.destroyed && !particle.spawning && !!(orbitAnimations === null || orbitAnimations === void 0 ? void 0 : orbitAnimations.enable);
221
+ const orbitAnimations = particle.options.orbit?.animation;
222
+ return !particle.destroyed && !particle.spawning && !!orbitAnimations?.enable;
222
223
  }
223
224
  loadOptions(options, ...sources) {
224
225
  if (!options.orbit) {
225
226
  options.orbit = new Orbit();
226
227
  }
227
228
  for (const source of sources) {
228
- options.orbit.load(source === null || source === void 0 ? void 0 : source.orbit);
229
+ options.orbit.load(source?.orbit);
229
230
  }
230
231
  }
231
232
  update(particle, delta) {
232
- var _a;
233
233
  if (!this.isEnabled(particle)) {
234
234
  return;
235
235
  }
236
236
  if (particle.orbitRotation === undefined) {
237
237
  particle.orbitRotation = 0;
238
238
  }
239
- particle.orbitRotation += ((_a = particle.orbitAnimationSpeed) !== null && _a !== void 0 ? _a : 0 / (Math.PI * 2)) * delta.factor;
239
+ particle.orbitRotation += (particle.orbitAnimationSpeed ?? 0 / (Math.PI * 2)) * delta.factor;
240
240
  }
241
241
  }
242
242
  ;// CONCATENATED MODULE: ./dist/browser/index.js
243
243
 
244
- function loadOrbitUpdater(engine) {
245
- engine.addParticleUpdater("orbit", container => new OrbitUpdater(container));
244
+ async function loadOrbitUpdater(engine, refresh = true) {
245
+ await engine.addParticleUpdater("orbit", container => new OrbitUpdater(container), refresh);
246
246
  }
247
247
  })();
248
248
 
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see tsparticles.updater.orbit.min.js.LICENSE.txt */
2
- !function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var i="object"==typeof exports?o(require("@tsparticles/engine")):o(t.window);for(var e in i)("object"==typeof exports?exports:t)[e]=i[e]}}(this,(t=>(()=>{"use strict";var o={533:o=>{o.exports=t}},i={};function e(t){var a=i[t];if(void 0!==a)return a.exports;var r=i[t]={exports:{}};return o[t](r,r.exports,e),r.exports}e.d=(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},e.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return(()=>{e.r(a),e.d(a,{loadOrbitUpdater:()=>n});var t=e(533);class o extends t.ValueWithRandom{constructor(){super(),this.value=45,this.random.enable=!1,this.random.minimumValue=0}load(t){void 0!==t&&super.load(t)}}class i{constructor(){this.animation=new t.AnimationOptions,this.enable=!1,this.opacity=1,this.rotation=new o,this.width=1}load(o){o&&(this.animation.load(o.animation),this.rotation.load(o.rotation),void 0!==o.enable&&(this.enable=o.enable),void 0!==o.opacity&&(this.opacity=(0,t.setRangeValue)(o.opacity)),void 0!==o.width&&(this.width=(0,t.setRangeValue)(o.width)),void 0!==o.radius&&(this.radius=(0,t.setRangeValue)(o.radius)),void 0!==o.color&&(this.color=t.OptionsColor.create(this.color,o.color)))}}class r{constructor(t){this.container=t}afterDraw(t){const o=t.options.orbit;(null==o?void 0:o.enable)&&this.drawOrbit(t,"front")}beforeDraw(t){const o=t.options.orbit;(null==o?void 0:o.enable)&&this.drawOrbit(t,"back")}drawOrbit(o,i){const e=this.container;let a,r;switch(i){case"back":a=Math.PI/2,r=3*Math.PI/2;break;case"front":a=3*Math.PI/2,r=Math.PI/2;break;default:a=0,r=2*Math.PI}e.canvas.draw((i=>{var n,l,s,d,u,b;!function(o,i,e,a,r,n,l,s,d){if(n<=0)return;const u=i.getPosition();e&&(o.strokeStyle=(0,t.getStyleFromHsl)(e,r)),o.lineWidth=n;const b=l*Math.PI/180;o.beginPath(),o.ellipse(u.x,u.y,a/2,2*a,b,s,d),o.stroke()}(i,o,null!==(n=o.orbitColor)&&void 0!==n?n:o.getFillColor(),null!==(s=null!==(l=o.retina.orbitRadius)&&void 0!==l?l:e.retina.orbitRadius)&&void 0!==s?s:o.getRadius(),null!==(d=o.orbitOpacity)&&void 0!==d?d:1,null!==(u=o.orbitWidth)&&void 0!==u?u:1,(null!==(b=o.orbitRotation)&&void 0!==b?b:0)*e.retina.pixelRatio,a,r)}))}init(o){const i=this.container,e=o.options.orbit;(null==e?void 0:e.enable)&&(o.orbitRotation=(0,t.getRangeValue)(e.rotation.value),o.orbitColor=(0,t.rangeColorToHsl)(e.color),o.retina.orbitRadius=void 0!==e.radius?(0,t.getRangeValue)(e.radius)*i.retina.pixelRatio:void 0,i.retina.orbitRadius=o.retina.orbitRadius,o.orbitAnimationSpeed=e.animation.enable?(0,t.getRangeValue)(e.animation.speed):0,o.orbitWidth=(0,t.getRangeValue)(e.width),o.orbitOpacity=(0,t.getRangeValue)(e.opacity))}isEnabled(t){var o;const i=null===(o=t.options.orbit)||void 0===o?void 0:o.animation;return!t.destroyed&&!t.spawning&&!!(null==i?void 0:i.enable)}loadOptions(t,...o){t.orbit||(t.orbit=new i);for(const i of o)t.orbit.load(null==i?void 0:i.orbit)}update(t,o){var i;this.isEnabled(t)&&(void 0===t.orbitRotation&&(t.orbitRotation=0),t.orbitRotation+=(null!==(i=t.orbitAnimationSpeed)&&void 0!==i?i:0/(2*Math.PI))*o.factor)}}function n(t){t.addParticleUpdater("orbit",(t=>new r(t)))}})(),a})()));
2
+ !function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],o);else{var i="object"==typeof exports?o(require("@tsparticles/engine")):o(t.window);for(var e in i)("object"==typeof exports?exports:t)[e]=i[e]}}(this,(t=>(()=>{"use strict";var o={533:o=>{o.exports=t}},i={};function e(t){var a=i[t];if(void 0!==a)return a.exports;var r=i[t]={exports:{}};return o[t](r,r.exports,e),r.exports}e.d=(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},e.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),e.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};return(()=>{e.r(a),e.d(a,{loadOrbitUpdater:()=>n});var t=e(533);class o extends t.ValueWithRandom{constructor(){super(),this.value=45,this.random.enable=!1,this.random.minimumValue=0}load(t){void 0!==t&&super.load(t)}}class i{constructor(){this.animation=new t.AnimationOptions,this.enable=!1,this.opacity=1,this.rotation=new o,this.width=1}load(o){o&&(this.animation.load(o.animation),this.rotation.load(o.rotation),void 0!==o.enable&&(this.enable=o.enable),void 0!==o.opacity&&(this.opacity=(0,t.setRangeValue)(o.opacity)),void 0!==o.width&&(this.width=(0,t.setRangeValue)(o.width)),void 0!==o.radius&&(this.radius=(0,t.setRangeValue)(o.radius)),void 0!==o.color&&(this.color=t.OptionsColor.create(this.color,o.color)))}}class r{constructor(t){this.container=t}afterDraw(t){const o=t.options.orbit;o?.enable&&this.drawOrbit(t,"front")}beforeDraw(t){const o=t.options.orbit;o?.enable&&this.drawOrbit(t,"back")}drawOrbit(o,i){const e=this.container;let a,r;switch(i){case"back":a=Math.PI/2,r=3*Math.PI/2;break;case"front":a=3*Math.PI/2,r=Math.PI/2;break;default:a=0,r=2*Math.PI}e.canvas.draw((i=>{!function(o,i,e,a,r,n,s,l,d){if(n<=0)return;const b=i.getPosition();e&&(o.strokeStyle=(0,t.getStyleFromHsl)(e,r)),o.lineWidth=n;const c=s*Math.PI/180;o.beginPath(),o.ellipse(b.x,b.y,a/2,2*a,c,l,d),o.stroke()}(i,o,o.orbitColor??o.getFillColor(),o.retina.orbitRadius??e.retina.orbitRadius??o.getRadius(),o.orbitOpacity??1,o.orbitWidth??1,(o.orbitRotation??0)*e.retina.pixelRatio,a,r)}))}init(o){const i=this.container,e=o.options.orbit;e?.enable&&(o.orbitRotation=(0,t.getRangeValue)(e.rotation.value),o.orbitColor=(0,t.rangeColorToHsl)(e.color),o.retina.orbitRadius=void 0!==e.radius?(0,t.getRangeValue)(e.radius)*i.retina.pixelRatio:void 0,i.retina.orbitRadius=o.retina.orbitRadius,o.orbitAnimationSpeed=e.animation.enable?(0,t.getRangeValue)(e.animation.speed):0,o.orbitWidth=(0,t.getRangeValue)(e.width),o.orbitOpacity=(0,t.getRangeValue)(e.opacity))}isEnabled(t){const o=t.options.orbit?.animation;return!t.destroyed&&!t.spawning&&!!o?.enable}loadOptions(t,...o){t.orbit||(t.orbit=new i);for(const i of o)t.orbit.load(i?.orbit)}update(t,o){this.isEnabled(t)&&(void 0===t.orbitRotation&&(t.orbitRotation=0),t.orbitRotation+=(t.orbitAnimationSpeed??0/(2*Math.PI))*o.factor)}}async function n(t,o=!0){await t.addParticleUpdater("orbit",(t=>new r(t)),o)}})(),a})()));
@@ -1,8 +1 @@
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-alpha.0
8
- */
1
+ /*! tsParticles Orbit Updater v3.0.0-beta.0 by Matteo Bruni */
@@ -0,0 +1,4 @@
1
+ export declare const enum OrbitType {
2
+ front = "front",
3
+ back = "back"
4
+ }
@@ -1,5 +1,4 @@
1
- import { AnimationOptions, OptionsColor } from "@tsparticles/engine";
2
- import type { IAnimatable, IOptionLoader, RangeValue, RecursivePartial } from "@tsparticles/engine";
1
+ import { AnimationOptions, type IAnimatable, type IOptionLoader, OptionsColor, type RangeValue, type RecursivePartial } from "@tsparticles/engine";
3
2
  import type { IOrbit } from "../Interfaces/IOrbit";
4
3
  import { OrbitRotation } from "./OrbitRotation";
5
4
  export declare class Orbit implements IOrbit, IOptionLoader<IOrbit>, IAnimatable<AnimationOptions> {
@@ -1,5 +1,4 @@
1
- import type { IValueWithRandom, RecursivePartial } from "@tsparticles/engine";
2
- import { ValueWithRandom } from "@tsparticles/engine";
1
+ import { type IValueWithRandom, type RecursivePartial, ValueWithRandom } from "@tsparticles/engine";
3
2
  export declare class OrbitRotation extends ValueWithRandom {
4
3
  constructor();
5
4
  load(data?: RecursivePartial<IValueWithRandom>): void;
@@ -1,33 +1,6 @@
1
- import type { Container, IDelta, IHsl, IParticleRetinaProps, IParticleUpdater, IParticlesOptions, Particle, ParticlesOptions, RecursivePartial, Retina } from "@tsparticles/engine";
2
- import type { IOrbit } from "./Options/Interfaces/IOrbit";
3
- import { Orbit } from "./Options/Classes/Orbit";
4
- export declare const enum OrbitType {
5
- front = "front",
6
- back = "back"
7
- }
8
- type IOrbitParticlesOptions = IParticlesOptions & {
9
- orbit?: IOrbit;
10
- };
11
- type OrbitParticlesOptions = ParticlesOptions & {
12
- orbit?: Orbit;
13
- };
14
- type OrbitRetina = Retina & {
15
- orbitRadius?: number;
16
- };
17
- type OrbitContainer = Container & {
18
- retina: OrbitRetina;
19
- };
20
- type OrbitParticle = Particle & {
21
- options: OrbitParticlesOptions;
22
- orbitAnimationSpeed?: number;
23
- orbitColor?: IHsl;
24
- orbitOpacity?: number;
25
- orbitRotation?: number;
26
- orbitWidth?: number;
27
- retina: IParticleRetinaProps & {
28
- orbitRadius?: number;
29
- };
30
- };
1
+ import { type IDelta, type IParticleUpdater, type RecursivePartial } from "@tsparticles/engine";
2
+ import type { IOrbitParticlesOptions, OrbitContainer, OrbitParticle, OrbitParticlesOptions } from "./Types";
3
+ import { OrbitType } from "./Enums";
31
4
  export declare class OrbitUpdater implements IParticleUpdater {
32
5
  private readonly container;
33
6
  constructor(container: OrbitContainer);
@@ -39,4 +12,3 @@ export declare class OrbitUpdater implements IParticleUpdater {
39
12
  loadOptions(options: OrbitParticlesOptions, ...sources: (RecursivePartial<IOrbitParticlesOptions> | undefined)[]): void;
40
13
  update(particle: OrbitParticle, delta: IDelta): void;
41
14
  }
42
- export {};
@@ -0,0 +1,26 @@
1
+ import type { Container, IHsl, IParticleRetinaProps, IParticlesOptions, Particle, ParticlesOptions, Retina } from "@tsparticles/engine";
2
+ import type { IOrbit } from "./Options/Interfaces/IOrbit";
3
+ import type { Orbit } from "./Options/Classes/Orbit";
4
+ export type IOrbitParticlesOptions = IParticlesOptions & {
5
+ orbit?: IOrbit;
6
+ };
7
+ export type OrbitParticlesOptions = ParticlesOptions & {
8
+ orbit?: Orbit;
9
+ };
10
+ export type OrbitRetina = Retina & {
11
+ orbitRadius?: number;
12
+ };
13
+ export type OrbitContainer = Container & {
14
+ retina: OrbitRetina;
15
+ };
16
+ export type OrbitParticle = Particle & {
17
+ options: OrbitParticlesOptions;
18
+ orbitAnimationSpeed?: number;
19
+ orbitColor?: IHsl;
20
+ orbitOpacity?: number;
21
+ orbitRotation?: number;
22
+ orbitWidth?: number;
23
+ retina: IParticleRetinaProps & {
24
+ orbitRadius?: number;
25
+ };
26
+ };
@@ -0,0 +1,2 @@
1
+ import { type IHsl, type Particle } from "@tsparticles/engine";
2
+ export declare function drawEllipse(context: CanvasRenderingContext2D, particle: Particle, fillColorValue: IHsl | undefined, radius: number, opacity: number, width: number, rotation: number, start: number, end: number): void;
package/types/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import type { Engine } from "@tsparticles/engine";
2
- export declare function loadOrbitUpdater(engine: Engine): void;
2
+ export declare function loadOrbitUpdater(engine: Engine, refresh?: boolean): Promise<void>;
package/umd/Enums.js ADDED
@@ -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
+ });
@@ -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/Orbit"], factory);
7
+ define(["require", "exports", "@tsparticles/engine", "./Options/Classes/Orbit", "./Utils"], factory);
8
8
  }
9
9
  })(function (require, exports) {
10
10
  "use strict";
@@ -12,33 +12,20 @@
12
12
  exports.OrbitUpdater = void 0;
13
13
  const engine_1 = require("@tsparticles/engine");
14
14
  const Orbit_1 = require("./Options/Classes/Orbit");
15
- function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
16
- if (width <= 0) {
17
- return;
18
- }
19
- const pos = particle.getPosition();
20
- if (fillColorValue) {
21
- context.strokeStyle = (0, engine_1.getStyleFromHsl)(fillColorValue, opacity);
22
- }
23
- context.lineWidth = width;
24
- const rotationRadian = (rotation * Math.PI) / 180;
25
- context.beginPath();
26
- context.ellipse(pos.x, pos.y, radius / 2, radius * 2, rotationRadian, start, end);
27
- context.stroke();
28
- }
15
+ const Utils_1 = require("./Utils");
29
16
  class OrbitUpdater {
30
17
  constructor(container) {
31
18
  this.container = container;
32
19
  }
33
20
  afterDraw(particle) {
34
21
  const orbitOptions = particle.options.orbit;
35
- if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
22
+ if (orbitOptions?.enable) {
36
23
  this.drawOrbit(particle, "front");
37
24
  }
38
25
  }
39
26
  beforeDraw(particle) {
40
27
  const orbitOptions = particle.options.orbit;
41
- if (orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable) {
28
+ if (orbitOptions?.enable) {
42
29
  this.drawOrbit(particle, "back");
43
30
  }
44
31
  }
@@ -59,13 +46,12 @@
59
46
  end = 2 * Math.PI;
60
47
  }
61
48
  container.canvas.draw((ctx) => {
62
- var _a, _b, _c, _d, _e, _f;
63
- drawEllipse(ctx, particle, (_a = particle.orbitColor) !== null && _a !== void 0 ? _a : particle.getFillColor(), (_c = (_b = particle.retina.orbitRadius) !== null && _b !== void 0 ? _b : container.retina.orbitRadius) !== null && _c !== void 0 ? _c : particle.getRadius(), (_d = particle.orbitOpacity) !== null && _d !== void 0 ? _d : 1, (_e = particle.orbitWidth) !== null && _e !== void 0 ? _e : 1, ((_f = particle.orbitRotation) !== null && _f !== void 0 ? _f : 0) * container.retina.pixelRatio, start, end);
49
+ (0, Utils_1.drawEllipse)(ctx, particle, particle.orbitColor ?? particle.getFillColor(), particle.retina.orbitRadius ?? container.retina.orbitRadius ?? particle.getRadius(), particle.orbitOpacity ?? 1, particle.orbitWidth ?? 1, (particle.orbitRotation ?? 0) * container.retina.pixelRatio, start, end);
64
50
  });
65
51
  }
66
52
  init(particle) {
67
53
  const container = this.container, particlesOptions = particle.options, orbitOptions = particlesOptions.orbit;
68
- if (!(orbitOptions === null || orbitOptions === void 0 ? void 0 : orbitOptions.enable)) {
54
+ if (!orbitOptions?.enable) {
69
55
  return;
70
56
  }
71
57
  particle.orbitRotation = (0, engine_1.getRangeValue)(orbitOptions.rotation.value);
@@ -80,27 +66,25 @@
80
66
  particle.orbitOpacity = (0, engine_1.getRangeValue)(orbitOptions.opacity);
81
67
  }
82
68
  isEnabled(particle) {
83
- var _a;
84
- const orbitAnimations = (_a = particle.options.orbit) === null || _a === void 0 ? void 0 : _a.animation;
85
- return !particle.destroyed && !particle.spawning && !!(orbitAnimations === null || orbitAnimations === void 0 ? void 0 : orbitAnimations.enable);
69
+ const orbitAnimations = particle.options.orbit?.animation;
70
+ return !particle.destroyed && !particle.spawning && !!orbitAnimations?.enable;
86
71
  }
87
72
  loadOptions(options, ...sources) {
88
73
  if (!options.orbit) {
89
74
  options.orbit = new Orbit_1.Orbit();
90
75
  }
91
76
  for (const source of sources) {
92
- options.orbit.load(source === null || source === void 0 ? void 0 : source.orbit);
77
+ options.orbit.load(source?.orbit);
93
78
  }
94
79
  }
95
80
  update(particle, delta) {
96
- var _a;
97
81
  if (!this.isEnabled(particle)) {
98
82
  return;
99
83
  }
100
84
  if (particle.orbitRotation === undefined) {
101
85
  particle.orbitRotation = 0;
102
86
  }
103
- particle.orbitRotation += ((_a = particle.orbitAnimationSpeed) !== null && _a !== void 0 ? _a : 0 / (Math.PI * 2)) * delta.factor;
87
+ particle.orbitRotation += (particle.orbitAnimationSpeed ?? 0 / (Math.PI * 2)) * delta.factor;
104
88
  }
105
89
  }
106
90
  exports.OrbitUpdater = OrbitUpdater;
package/umd/Types.js ADDED
@@ -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
+ });
package/umd/Utils.js ADDED
@@ -0,0 +1,29 @@
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.drawEllipse = void 0;
13
+ const engine_1 = require("@tsparticles/engine");
14
+ function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
15
+ if (width <= 0) {
16
+ return;
17
+ }
18
+ const pos = particle.getPosition();
19
+ if (fillColorValue) {
20
+ context.strokeStyle = (0, engine_1.getStyleFromHsl)(fillColorValue, opacity);
21
+ }
22
+ context.lineWidth = width;
23
+ const rotationRadian = (rotation * Math.PI) / 180;
24
+ context.beginPath();
25
+ context.ellipse(pos.x, pos.y, radius / 2, radius * 2, rotationRadian, start, end);
26
+ context.stroke();
27
+ }
28
+ exports.drawEllipse = drawEllipse;
29
+ });
package/umd/index.js CHANGED
@@ -11,8 +11,8 @@
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.loadOrbitUpdater = void 0;
13
13
  const OrbitUpdater_1 = require("./OrbitUpdater");
14
- function loadOrbitUpdater(engine) {
15
- engine.addParticleUpdater("orbit", (container) => new OrbitUpdater_1.OrbitUpdater(container));
14
+ async function loadOrbitUpdater(engine, refresh = true) {
15
+ await engine.addParticleUpdater("orbit", (container) => new OrbitUpdater_1.OrbitUpdater(container), refresh);
16
16
  }
17
17
  exports.loadOrbitUpdater = loadOrbitUpdater;
18
18
  });