@tsparticles/updater-destroy 4.0.0-beta.8 → 4.0.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.
Files changed (42) hide show
  1. package/browser/DestroyUpdater.js +44 -4
  2. package/browser/Enums/DestroyMode.js +1 -0
  3. package/browser/Options/Classes/Destroy.js +4 -0
  4. package/browser/Options/Classes/Explode.js +20 -0
  5. package/browser/Options/Interfaces/IExplode.js +1 -0
  6. package/browser/Utils.js +1 -1
  7. package/browser/browser.js +5 -0
  8. package/browser/index.js +4 -4
  9. package/browser/index.lazy.js +9 -0
  10. package/cjs/DestroyUpdater.js +44 -4
  11. package/cjs/Enums/DestroyMode.js +1 -0
  12. package/cjs/Options/Classes/Destroy.js +4 -0
  13. package/cjs/Options/Classes/Explode.js +20 -0
  14. package/cjs/Options/Interfaces/IExplode.js +1 -0
  15. package/cjs/Utils.js +1 -1
  16. package/cjs/browser.js +5 -0
  17. package/cjs/index.js +4 -4
  18. package/cjs/index.lazy.js +9 -0
  19. package/esm/DestroyUpdater.js +44 -4
  20. package/esm/Enums/DestroyMode.js +1 -0
  21. package/esm/Options/Classes/Destroy.js +4 -0
  22. package/esm/Options/Classes/Explode.js +20 -0
  23. package/esm/Options/Interfaces/IExplode.js +1 -0
  24. package/esm/Utils.js +1 -1
  25. package/esm/browser.js +5 -0
  26. package/esm/index.js +4 -4
  27. package/esm/index.lazy.js +9 -0
  28. package/package.json +9 -2
  29. package/report.html +4949 -94
  30. package/tsparticles.updater.destroy.js +371 -310
  31. package/tsparticles.updater.destroy.min.js +1 -2
  32. package/types/DestroyUpdater.d.ts +2 -2
  33. package/types/Enums/DestroyMode.d.ts +1 -0
  34. package/types/Options/Classes/Destroy.d.ts +2 -0
  35. package/types/Options/Classes/Explode.d.ts +8 -0
  36. package/types/Options/Interfaces/IDestroy.d.ts +2 -0
  37. package/types/Options/Interfaces/IExplode.d.ts +4 -0
  38. package/types/Types.d.ts +8 -0
  39. package/types/browser.d.ts +1 -0
  40. package/types/index.lazy.d.ts +2 -0
  41. package/960.min.js +0 -1
  42. package/dist_browser_DestroyUpdater_js.js +0 -100
@@ -2,6 +2,7 @@ import { getRangeValue, percentDenominator, } from "@tsparticles/engine";
2
2
  import { Destroy } from "./Options/Classes/Destroy.js";
3
3
  import { DestroyMode } from "./Enums/DestroyMode.js";
4
4
  import { split } from "./Utils.js";
5
+ const defaultDeltaFactor = 1, fpsFactor = 60, minExplodeSpeed = 0.01, maxExplodeProgress = 1;
5
6
  export class DestroyUpdater {
6
7
  _container;
7
8
  _pluginManager;
@@ -14,6 +15,7 @@ export class DestroyUpdater {
14
15
  if (!destroyOptions) {
15
16
  return;
16
17
  }
18
+ particle.exploding = undefined;
17
19
  particle.splitCount = 0;
18
20
  const destroyBoundsOptions = destroyOptions.bounds;
19
21
  particle.destroyBounds ??= {};
@@ -32,7 +34,8 @@ export class DestroyUpdater {
32
34
  }
33
35
  }
34
36
  isEnabled(particle) {
35
- return !particle.destroyed;
37
+ const destroyParticle = particle;
38
+ return !destroyParticle.destroyed || !!destroyParticle.exploding;
36
39
  }
37
40
  loadOptions(options, ...sources) {
38
41
  options.destroy ??= new Destroy();
@@ -45,11 +48,48 @@ export class DestroyUpdater {
45
48
  return;
46
49
  }
47
50
  const destroyOptions = particle.options.destroy;
48
- if (destroyOptions?.mode === DestroyMode.split) {
49
- split(this._pluginManager, this._container, particle);
51
+ switch (destroyOptions?.mode) {
52
+ case DestroyMode.split:
53
+ split(this._pluginManager, this._container, particle);
54
+ break;
55
+ case DestroyMode.explode: {
56
+ if (particle.exploding) {
57
+ particle.destroyed = false;
58
+ break;
59
+ }
60
+ const { explode } = destroyOptions, initialSize = particle.size.value, maxSize = initialSize * explode.maxSizeFactor, opacity = particle.getOpacity();
61
+ particle.exploding = {
62
+ initialFillOpacity: opacity.fillOpacity,
63
+ initialSize,
64
+ initialStrokeOpacity: opacity.strokeOpacity,
65
+ maxSize,
66
+ progress: 0,
67
+ speed: Math.max(explode.speed, minExplodeSpeed),
68
+ };
69
+ particle.fillOpacity = opacity.fillOpacity;
70
+ particle.strokeOpacity = opacity.strokeOpacity;
71
+ particle.destroyed = false;
72
+ break;
73
+ }
74
+ default:
75
+ break;
50
76
  }
51
77
  }
52
- update(particle) {
78
+ update(particle, delta) {
79
+ if (particle.exploding) {
80
+ const explosionState = particle.exploding, deltaFactor = delta.factor || defaultDeltaFactor;
81
+ explosionState.progress = Math.min(maxExplodeProgress, explosionState.progress + (explosionState.speed * deltaFactor) / fpsFactor);
82
+ const progress = explosionState.progress;
83
+ particle.size.value =
84
+ explosionState.initialSize + (explosionState.maxSize - explosionState.initialSize) * progress;
85
+ particle.fillOpacity = explosionState.initialFillOpacity * (maxExplodeProgress - progress);
86
+ particle.strokeOpacity = explosionState.initialStrokeOpacity * (maxExplodeProgress - progress);
87
+ if (progress >= maxExplodeProgress) {
88
+ particle.exploding = undefined;
89
+ particle.destroy(true);
90
+ }
91
+ return;
92
+ }
53
93
  if (particle.unbreakableUntil !== undefined && performance.now() >= particle.unbreakableUntil) {
54
94
  particle.unbreakable = false;
55
95
  particle.unbreakableUntil = undefined;
@@ -1,5 +1,6 @@
1
1
  export var DestroyMode;
2
2
  (function (DestroyMode) {
3
+ DestroyMode["explode"] = "explode";
3
4
  DestroyMode["none"] = "none";
4
5
  DestroyMode["split"] = "split";
5
6
  })(DestroyMode || (DestroyMode = {}));
@@ -1,13 +1,16 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  import { DestroyBounds } from "./DestroyBounds.js";
3
3
  import { DestroyMode } from "../../Enums/DestroyMode.js";
4
+ import { Explode } from "./Explode.js";
4
5
  import { Split } from "./Split.js";
5
6
  export class Destroy {
6
7
  bounds;
8
+ explode;
7
9
  mode;
8
10
  split;
9
11
  constructor() {
10
12
  this.bounds = new DestroyBounds();
13
+ this.explode = new Explode();
11
14
  this.mode = DestroyMode.none;
12
15
  this.split = new Split();
13
16
  }
@@ -21,6 +24,7 @@ export class Destroy {
21
24
  if (data.bounds) {
22
25
  this.bounds.load(data.bounds);
23
26
  }
27
+ this.explode.load(data.explode);
24
28
  this.split.load(data.split);
25
29
  }
26
30
  }
@@ -0,0 +1,20 @@
1
+ import { isNull } from "@tsparticles/engine";
2
+ export class Explode {
3
+ maxSizeFactor;
4
+ speed;
5
+ constructor() {
6
+ this.maxSizeFactor = 3;
7
+ this.speed = 2;
8
+ }
9
+ load(data) {
10
+ if (isNull(data)) {
11
+ return;
12
+ }
13
+ if (data.maxSizeFactor !== undefined) {
14
+ this.maxSizeFactor = data.maxSizeFactor;
15
+ }
16
+ if (data.speed !== undefined) {
17
+ this.speed = data.speed;
18
+ }
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ export {};
package/browser/Utils.js CHANGED
@@ -53,7 +53,7 @@ function addSplitParticle(pluginManager, container, parent, splitParticlesOption
53
53
  splitParticleOptions.size.value.max *= factor;
54
54
  }
55
55
  splitParticleOptions.load(splitParticlesOptions);
56
- const splitParticleFillOptions = itemFromSingleOrMultiple(splitParticleOptions.fill), splitParticleStrokeOptions = itemFromSingleOrMultiple(splitParticleOptions.stroke), fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
56
+ const splitParticlePaintOptions = itemFromSingleOrMultiple(splitParticleOptions.paint), splitParticleFillOptions = splitParticlePaintOptions?.fill, splitParticleStrokeOptions = splitParticlePaintOptions?.stroke, fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
57
57
  if (fillColor && splitParticleFillOptions) {
58
58
  splitParticleFillOptions.color = fillColor;
59
59
  }
@@ -0,0 +1,5 @@
1
+ import { loadDestroyUpdater } from "./index.js";
2
+ const globalObject = globalThis;
3
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
4
+ globalObject.loadDestroyUpdater = loadDestroyUpdater;
5
+ export * from "./index.js";
package/browser/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ import { DestroyUpdater } from "./DestroyUpdater.js";
1
2
  export async function loadDestroyUpdater(engine) {
2
- engine.checkVersion("4.0.0-beta.8");
3
+ engine.checkVersion("4.0.0");
3
4
  await engine.pluginManager.register(e => {
4
- e.pluginManager.addParticleUpdater("destroy", async (container) => {
5
- const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
- return new DestroyUpdater(e.pluginManager, container);
5
+ e.pluginManager.addParticleUpdater("destroy", container => {
6
+ return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
7
7
  });
8
8
  });
9
9
  }
@@ -0,0 +1,9 @@
1
+ export async function loadDestroyUpdater(engine) {
2
+ engine.checkVersion("4.0.0");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addParticleUpdater("destroy", async (container) => {
5
+ const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
+ return new DestroyUpdater(e.pluginManager, container);
7
+ });
8
+ });
9
+ }
@@ -2,6 +2,7 @@ import { getRangeValue, percentDenominator, } from "@tsparticles/engine";
2
2
  import { Destroy } from "./Options/Classes/Destroy.js";
3
3
  import { DestroyMode } from "./Enums/DestroyMode.js";
4
4
  import { split } from "./Utils.js";
5
+ const defaultDeltaFactor = 1, fpsFactor = 60, minExplodeSpeed = 0.01, maxExplodeProgress = 1;
5
6
  export class DestroyUpdater {
6
7
  _container;
7
8
  _pluginManager;
@@ -14,6 +15,7 @@ export class DestroyUpdater {
14
15
  if (!destroyOptions) {
15
16
  return;
16
17
  }
18
+ particle.exploding = undefined;
17
19
  particle.splitCount = 0;
18
20
  const destroyBoundsOptions = destroyOptions.bounds;
19
21
  particle.destroyBounds ??= {};
@@ -32,7 +34,8 @@ export class DestroyUpdater {
32
34
  }
33
35
  }
34
36
  isEnabled(particle) {
35
- return !particle.destroyed;
37
+ const destroyParticle = particle;
38
+ return !destroyParticle.destroyed || !!destroyParticle.exploding;
36
39
  }
37
40
  loadOptions(options, ...sources) {
38
41
  options.destroy ??= new Destroy();
@@ -45,11 +48,48 @@ export class DestroyUpdater {
45
48
  return;
46
49
  }
47
50
  const destroyOptions = particle.options.destroy;
48
- if (destroyOptions?.mode === DestroyMode.split) {
49
- split(this._pluginManager, this._container, particle);
51
+ switch (destroyOptions?.mode) {
52
+ case DestroyMode.split:
53
+ split(this._pluginManager, this._container, particle);
54
+ break;
55
+ case DestroyMode.explode: {
56
+ if (particle.exploding) {
57
+ particle.destroyed = false;
58
+ break;
59
+ }
60
+ const { explode } = destroyOptions, initialSize = particle.size.value, maxSize = initialSize * explode.maxSizeFactor, opacity = particle.getOpacity();
61
+ particle.exploding = {
62
+ initialFillOpacity: opacity.fillOpacity,
63
+ initialSize,
64
+ initialStrokeOpacity: opacity.strokeOpacity,
65
+ maxSize,
66
+ progress: 0,
67
+ speed: Math.max(explode.speed, minExplodeSpeed),
68
+ };
69
+ particle.fillOpacity = opacity.fillOpacity;
70
+ particle.strokeOpacity = opacity.strokeOpacity;
71
+ particle.destroyed = false;
72
+ break;
73
+ }
74
+ default:
75
+ break;
50
76
  }
51
77
  }
52
- update(particle) {
78
+ update(particle, delta) {
79
+ if (particle.exploding) {
80
+ const explosionState = particle.exploding, deltaFactor = delta.factor || defaultDeltaFactor;
81
+ explosionState.progress = Math.min(maxExplodeProgress, explosionState.progress + (explosionState.speed * deltaFactor) / fpsFactor);
82
+ const progress = explosionState.progress;
83
+ particle.size.value =
84
+ explosionState.initialSize + (explosionState.maxSize - explosionState.initialSize) * progress;
85
+ particle.fillOpacity = explosionState.initialFillOpacity * (maxExplodeProgress - progress);
86
+ particle.strokeOpacity = explosionState.initialStrokeOpacity * (maxExplodeProgress - progress);
87
+ if (progress >= maxExplodeProgress) {
88
+ particle.exploding = undefined;
89
+ particle.destroy(true);
90
+ }
91
+ return;
92
+ }
53
93
  if (particle.unbreakableUntil !== undefined && performance.now() >= particle.unbreakableUntil) {
54
94
  particle.unbreakable = false;
55
95
  particle.unbreakableUntil = undefined;
@@ -1,5 +1,6 @@
1
1
  export var DestroyMode;
2
2
  (function (DestroyMode) {
3
+ DestroyMode["explode"] = "explode";
3
4
  DestroyMode["none"] = "none";
4
5
  DestroyMode["split"] = "split";
5
6
  })(DestroyMode || (DestroyMode = {}));
@@ -1,13 +1,16 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  import { DestroyBounds } from "./DestroyBounds.js";
3
3
  import { DestroyMode } from "../../Enums/DestroyMode.js";
4
+ import { Explode } from "./Explode.js";
4
5
  import { Split } from "./Split.js";
5
6
  export class Destroy {
6
7
  bounds;
8
+ explode;
7
9
  mode;
8
10
  split;
9
11
  constructor() {
10
12
  this.bounds = new DestroyBounds();
13
+ this.explode = new Explode();
11
14
  this.mode = DestroyMode.none;
12
15
  this.split = new Split();
13
16
  }
@@ -21,6 +24,7 @@ export class Destroy {
21
24
  if (data.bounds) {
22
25
  this.bounds.load(data.bounds);
23
26
  }
27
+ this.explode.load(data.explode);
24
28
  this.split.load(data.split);
25
29
  }
26
30
  }
@@ -0,0 +1,20 @@
1
+ import { isNull } from "@tsparticles/engine";
2
+ export class Explode {
3
+ maxSizeFactor;
4
+ speed;
5
+ constructor() {
6
+ this.maxSizeFactor = 3;
7
+ this.speed = 2;
8
+ }
9
+ load(data) {
10
+ if (isNull(data)) {
11
+ return;
12
+ }
13
+ if (data.maxSizeFactor !== undefined) {
14
+ this.maxSizeFactor = data.maxSizeFactor;
15
+ }
16
+ if (data.speed !== undefined) {
17
+ this.speed = data.speed;
18
+ }
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ export {};
package/cjs/Utils.js CHANGED
@@ -53,7 +53,7 @@ function addSplitParticle(pluginManager, container, parent, splitParticlesOption
53
53
  splitParticleOptions.size.value.max *= factor;
54
54
  }
55
55
  splitParticleOptions.load(splitParticlesOptions);
56
- const splitParticleFillOptions = itemFromSingleOrMultiple(splitParticleOptions.fill), splitParticleStrokeOptions = itemFromSingleOrMultiple(splitParticleOptions.stroke), fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
56
+ const splitParticlePaintOptions = itemFromSingleOrMultiple(splitParticleOptions.paint), splitParticleFillOptions = splitParticlePaintOptions?.fill, splitParticleStrokeOptions = splitParticlePaintOptions?.stroke, fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
57
57
  if (fillColor && splitParticleFillOptions) {
58
58
  splitParticleFillOptions.color = fillColor;
59
59
  }
package/cjs/browser.js ADDED
@@ -0,0 +1,5 @@
1
+ import { loadDestroyUpdater } from "./index.js";
2
+ const globalObject = globalThis;
3
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
4
+ globalObject.loadDestroyUpdater = loadDestroyUpdater;
5
+ export * from "./index.js";
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ import { DestroyUpdater } from "./DestroyUpdater.js";
1
2
  export async function loadDestroyUpdater(engine) {
2
- engine.checkVersion("4.0.0-beta.8");
3
+ engine.checkVersion("4.0.0");
3
4
  await engine.pluginManager.register(e => {
4
- e.pluginManager.addParticleUpdater("destroy", async (container) => {
5
- const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
- return new DestroyUpdater(e.pluginManager, container);
5
+ e.pluginManager.addParticleUpdater("destroy", container => {
6
+ return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
7
7
  });
8
8
  });
9
9
  }
@@ -0,0 +1,9 @@
1
+ export async function loadDestroyUpdater(engine) {
2
+ engine.checkVersion("4.0.0");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addParticleUpdater("destroy", async (container) => {
5
+ const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
+ return new DestroyUpdater(e.pluginManager, container);
7
+ });
8
+ });
9
+ }
@@ -2,6 +2,7 @@ import { getRangeValue, percentDenominator, } from "@tsparticles/engine";
2
2
  import { Destroy } from "./Options/Classes/Destroy.js";
3
3
  import { DestroyMode } from "./Enums/DestroyMode.js";
4
4
  import { split } from "./Utils.js";
5
+ const defaultDeltaFactor = 1, fpsFactor = 60, minExplodeSpeed = 0.01, maxExplodeProgress = 1;
5
6
  export class DestroyUpdater {
6
7
  _container;
7
8
  _pluginManager;
@@ -14,6 +15,7 @@ export class DestroyUpdater {
14
15
  if (!destroyOptions) {
15
16
  return;
16
17
  }
18
+ particle.exploding = undefined;
17
19
  particle.splitCount = 0;
18
20
  const destroyBoundsOptions = destroyOptions.bounds;
19
21
  particle.destroyBounds ??= {};
@@ -32,7 +34,8 @@ export class DestroyUpdater {
32
34
  }
33
35
  }
34
36
  isEnabled(particle) {
35
- return !particle.destroyed;
37
+ const destroyParticle = particle;
38
+ return !destroyParticle.destroyed || !!destroyParticle.exploding;
36
39
  }
37
40
  loadOptions(options, ...sources) {
38
41
  options.destroy ??= new Destroy();
@@ -45,11 +48,48 @@ export class DestroyUpdater {
45
48
  return;
46
49
  }
47
50
  const destroyOptions = particle.options.destroy;
48
- if (destroyOptions?.mode === DestroyMode.split) {
49
- split(this._pluginManager, this._container, particle);
51
+ switch (destroyOptions?.mode) {
52
+ case DestroyMode.split:
53
+ split(this._pluginManager, this._container, particle);
54
+ break;
55
+ case DestroyMode.explode: {
56
+ if (particle.exploding) {
57
+ particle.destroyed = false;
58
+ break;
59
+ }
60
+ const { explode } = destroyOptions, initialSize = particle.size.value, maxSize = initialSize * explode.maxSizeFactor, opacity = particle.getOpacity();
61
+ particle.exploding = {
62
+ initialFillOpacity: opacity.fillOpacity,
63
+ initialSize,
64
+ initialStrokeOpacity: opacity.strokeOpacity,
65
+ maxSize,
66
+ progress: 0,
67
+ speed: Math.max(explode.speed, minExplodeSpeed),
68
+ };
69
+ particle.fillOpacity = opacity.fillOpacity;
70
+ particle.strokeOpacity = opacity.strokeOpacity;
71
+ particle.destroyed = false;
72
+ break;
73
+ }
74
+ default:
75
+ break;
50
76
  }
51
77
  }
52
- update(particle) {
78
+ update(particle, delta) {
79
+ if (particle.exploding) {
80
+ const explosionState = particle.exploding, deltaFactor = delta.factor || defaultDeltaFactor;
81
+ explosionState.progress = Math.min(maxExplodeProgress, explosionState.progress + (explosionState.speed * deltaFactor) / fpsFactor);
82
+ const progress = explosionState.progress;
83
+ particle.size.value =
84
+ explosionState.initialSize + (explosionState.maxSize - explosionState.initialSize) * progress;
85
+ particle.fillOpacity = explosionState.initialFillOpacity * (maxExplodeProgress - progress);
86
+ particle.strokeOpacity = explosionState.initialStrokeOpacity * (maxExplodeProgress - progress);
87
+ if (progress >= maxExplodeProgress) {
88
+ particle.exploding = undefined;
89
+ particle.destroy(true);
90
+ }
91
+ return;
92
+ }
53
93
  if (particle.unbreakableUntil !== undefined && performance.now() >= particle.unbreakableUntil) {
54
94
  particle.unbreakable = false;
55
95
  particle.unbreakableUntil = undefined;
@@ -1,5 +1,6 @@
1
1
  export var DestroyMode;
2
2
  (function (DestroyMode) {
3
+ DestroyMode["explode"] = "explode";
3
4
  DestroyMode["none"] = "none";
4
5
  DestroyMode["split"] = "split";
5
6
  })(DestroyMode || (DestroyMode = {}));
@@ -1,13 +1,16 @@
1
1
  import { isNull } from "@tsparticles/engine";
2
2
  import { DestroyBounds } from "./DestroyBounds.js";
3
3
  import { DestroyMode } from "../../Enums/DestroyMode.js";
4
+ import { Explode } from "./Explode.js";
4
5
  import { Split } from "./Split.js";
5
6
  export class Destroy {
6
7
  bounds;
8
+ explode;
7
9
  mode;
8
10
  split;
9
11
  constructor() {
10
12
  this.bounds = new DestroyBounds();
13
+ this.explode = new Explode();
11
14
  this.mode = DestroyMode.none;
12
15
  this.split = new Split();
13
16
  }
@@ -21,6 +24,7 @@ export class Destroy {
21
24
  if (data.bounds) {
22
25
  this.bounds.load(data.bounds);
23
26
  }
27
+ this.explode.load(data.explode);
24
28
  this.split.load(data.split);
25
29
  }
26
30
  }
@@ -0,0 +1,20 @@
1
+ import { isNull } from "@tsparticles/engine";
2
+ export class Explode {
3
+ maxSizeFactor;
4
+ speed;
5
+ constructor() {
6
+ this.maxSizeFactor = 3;
7
+ this.speed = 2;
8
+ }
9
+ load(data) {
10
+ if (isNull(data)) {
11
+ return;
12
+ }
13
+ if (data.maxSizeFactor !== undefined) {
14
+ this.maxSizeFactor = data.maxSizeFactor;
15
+ }
16
+ if (data.speed !== undefined) {
17
+ this.speed = data.speed;
18
+ }
19
+ }
20
+ }
@@ -0,0 +1 @@
1
+ export {};
package/esm/Utils.js CHANGED
@@ -53,7 +53,7 @@ function addSplitParticle(pluginManager, container, parent, splitParticlesOption
53
53
  splitParticleOptions.size.value.max *= factor;
54
54
  }
55
55
  splitParticleOptions.load(splitParticlesOptions);
56
- const splitParticleFillOptions = itemFromSingleOrMultiple(splitParticleOptions.fill), splitParticleStrokeOptions = itemFromSingleOrMultiple(splitParticleOptions.stroke), fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
56
+ const splitParticlePaintOptions = itemFromSingleOrMultiple(splitParticleOptions.paint), splitParticleFillOptions = splitParticlePaintOptions?.fill, splitParticleStrokeOptions = splitParticlePaintOptions?.stroke, fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
57
57
  if (fillColor && splitParticleFillOptions) {
58
58
  splitParticleFillOptions.color = fillColor;
59
59
  }
package/esm/browser.js ADDED
@@ -0,0 +1,5 @@
1
+ import { loadDestroyUpdater } from "./index.js";
2
+ const globalObject = globalThis;
3
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
4
+ globalObject.loadDestroyUpdater = loadDestroyUpdater;
5
+ export * from "./index.js";
package/esm/index.js CHANGED
@@ -1,9 +1,9 @@
1
+ import { DestroyUpdater } from "./DestroyUpdater.js";
1
2
  export async function loadDestroyUpdater(engine) {
2
- engine.checkVersion("4.0.0-beta.8");
3
+ engine.checkVersion("4.0.0");
3
4
  await engine.pluginManager.register(e => {
4
- e.pluginManager.addParticleUpdater("destroy", async (container) => {
5
- const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
- return new DestroyUpdater(e.pluginManager, container);
5
+ e.pluginManager.addParticleUpdater("destroy", container => {
6
+ return Promise.resolve(new DestroyUpdater(e.pluginManager, container));
7
7
  });
8
8
  });
9
9
  }
@@ -0,0 +1,9 @@
1
+ export async function loadDestroyUpdater(engine) {
2
+ engine.checkVersion("4.0.0");
3
+ await engine.pluginManager.register(e => {
4
+ e.pluginManager.addParticleUpdater("destroy", async (container) => {
5
+ const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
+ return new DestroyUpdater(e.pluginManager, container);
7
+ });
8
+ });
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/updater-destroy",
3
- "version": "4.0.0-beta.8",
3
+ "version": "4.0.0",
4
4
  "description": "tsParticles particles destroy updater",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -83,10 +83,17 @@
83
83
  "require": "./cjs/index.js",
84
84
  "default": "./esm/index.js"
85
85
  },
86
+ "./lazy": {
87
+ "types": "./types/index.lazy.d.ts",
88
+ "browser": "./browser/index.lazy.js",
89
+ "import": "./esm/index.lazy.js",
90
+ "require": "./cjs/index.lazy.js",
91
+ "default": "./esm/index.lazy.js"
92
+ },
86
93
  "./package.json": "./package.json"
87
94
  },
88
95
  "peerDependencies": {
89
- "@tsparticles/engine": "4.0.0-beta.8"
96
+ "@tsparticles/engine": "4.0.0"
90
97
  },
91
98
  "publishConfig": {
92
99
  "access": "public"