@tsparticles/updater-destroy 3.9.1 → 4.0.0-alpha.1

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/541.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 541.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_updater_destroy=this.webpackChunk_tsparticles_updater_destroy||[]).push([[541],{541(t,e,o){o.d(e,{DestroyUpdater:()=>d});var s,i=o(303);class l{load(t){(0,i.isNull)(t)||(void 0!==t.bottom&&(this.bottom=(0,i.setRangeValue)(t.bottom)),void 0!==t.left&&(this.left=(0,i.setRangeValue)(t.left)),void 0!==t.right&&(this.right=(0,i.setRangeValue)(t.right)),void 0!==t.top&&(this.top=(0,i.setRangeValue)(t.top)))}}!function(t){t.none="none",t.split="split"}(s||(s={}));class n extends i.ValueWithRandom{constructor(){super(),this.value=3}}class r extends i.ValueWithRandom{constructor(){super(),this.value={min:4,max:9}}}class a{constructor(){this.count=1,this.factor=new n,this.rate=new r,this.sizeOffset=!0}load(t){(0,i.isNull)(t)||(void 0!==t.color&&(this.color=i.OptionsColor.create(this.color,t.color)),void 0!==t.count&&(this.count=t.count),this.factor.load(t.factor),this.rate.load(t.rate),this.particles=(0,i.executeOnSingleOrMultiple)(t.particles,(t=>(0,i.deepExtend)({},t))),void 0!==t.sizeOffset&&(this.sizeOffset=t.sizeOffset),t.colorOffset&&(this.colorOffset=this.colorOffset??{},void 0!==t.colorOffset.h&&(this.colorOffset.h=t.colorOffset.h),void 0!==t.colorOffset.s&&(this.colorOffset.s=t.colorOffset.s),void 0!==t.colorOffset.l&&(this.colorOffset.l=t.colorOffset.l)))}}class c{constructor(){this.bounds=new l,this.mode=s.none,this.split=new a}load(t){(0,i.isNull)(t)||(t.mode&&(this.mode=t.mode),t.bounds&&this.bounds.load(t.bounds),this.split.load(t.split))}}function u(t,e,o,s){const l=o.options.destroy;if(!l)return;const n=l.split,r=(0,i.loadParticlesOptions)(t,e,o.options),a=(0,i.getRangeValue)(n.factor.value),c=o.getFillColor();n.color?r.color.load(n.color):n.colorOffset&&c?r.color.load({value:{hsl:{h:c.h+(0,i.getRangeValue)(n.colorOffset.h??0),s:c.s+(0,i.getRangeValue)(n.colorOffset.s??0),l:c.l+(0,i.getRangeValue)(n.colorOffset.l??0)}}}):r.color.load({value:{hsl:o.getFillColor()}}),r.move.load({center:{x:o.position.x,y:o.position.y,mode:i.PixelMode.precise}}),(0,i.isNumber)(r.size.value)?r.size.value/=a:(r.size.value.min/=a,r.size.value.max/=a),r.load(s);const u=n.sizeOffset?(0,i.setRangeValue)(-o.size.value,o.size.value):0,d={x:o.position.x+(0,i.randomInRangeValue)(u),y:o.position.y+(0,i.randomInRangeValue)(u)};return e.particles.addParticle(d,r,o.group,(t=>!(t.size.value<.5)&&(t.velocity.length=(0,i.randomInRangeValue)((0,i.setRangeValue)(o.velocity.length,t.velocity.length)),t.splitCount=(o.splitCount??0)+1,t.unbreakable=!0,setTimeout((()=>{t.unbreakable=!1}),500),!0)))}class d{constructor(t,e){this.container=e,this.engine=t}init(t){const e=this.container,o=t.options.destroy;if(!o)return;t.splitCount=0;const s=o.bounds;t.destroyBounds??={};const{bottom:l,left:n,right:r,top:a}=s,{destroyBounds:c}=t,u=e.canvas.size;l&&(c.bottom=(0,i.getRangeValue)(l)*u.height/i.percentDenominator),n&&(c.left=(0,i.getRangeValue)(n)*u.width/i.percentDenominator),r&&(c.right=(0,i.getRangeValue)(r)*u.width/i.percentDenominator),a&&(c.top=(0,i.getRangeValue)(a)*u.height/i.percentDenominator)}isEnabled(t){return!t.destroyed}loadOptions(t,...e){t.destroy??=new c;for(const o of e)t.destroy.load(o?.destroy)}particleDestroyed(t,e){if(e)return;const o=t.options.destroy;o?.mode===s.split&&function(t,e,o){const s=o.options.destroy;if(!s)return;const l=s.split;if(l.count>=0&&(void 0===o.splitCount||o.splitCount++>l.count))return;const n=(0,i.getRangeValue)(l.rate.value),r=(0,i.itemFromSingleOrMultiple)(l.particles);for(let s=0;s<n;s++)u(t,e,o,r)}(this.engine,this.container,t)}update(t){if(!this.isEnabled(t))return;const e=t.getPosition(),o=t.destroyBounds;o&&(void 0!==o.bottom&&e.y>=o.bottom||void 0!==o.left&&e.x<=o.left||void 0!==o.right&&e.x>=o.right||void 0!==o.top&&e.y<=o.top)&&t.destroy()}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Destroy Updater v4.0.0-alpha.1 by Matteo Bruni */
@@ -14,9 +14,7 @@ export class DestroyUpdater {
14
14
  }
15
15
  particle.splitCount = 0;
16
16
  const destroyBoundsOptions = destroyOptions.bounds;
17
- if (!particle.destroyBounds) {
18
- particle.destroyBounds = {};
19
- }
17
+ particle.destroyBounds ??= {};
20
18
  const { bottom, left, right, top } = destroyBoundsOptions, { destroyBounds } = particle, canvasSize = container.canvas.size;
21
19
  if (bottom) {
22
20
  destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / percentDenominator;
@@ -35,9 +33,7 @@ export class DestroyUpdater {
35
33
  return !particle.destroyed;
36
34
  }
37
35
  loadOptions(options, ...sources) {
38
- if (!options.destroy) {
39
- options.destroy = new Destroy();
40
- }
36
+ options.destroy ??= new Destroy();
41
37
  for (const source of sources) {
42
38
  options.destroy.load(source?.destroy);
43
39
  }
@@ -47,7 +43,7 @@ export class DestroyUpdater {
47
43
  return;
48
44
  }
49
45
  const destroyOptions = particle.options.destroy;
50
- if (destroyOptions && destroyOptions.mode === DestroyMode.split) {
46
+ if (destroyOptions?.mode === DestroyMode.split) {
51
47
  split(this.engine, this.container, particle);
52
48
  }
53
49
  }
package/browser/Utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PixelMode, getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRange, setRangeValue, } from "@tsparticles/engine";
1
+ import { PixelMode, getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
2
2
  const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
3
3
  function addSplitParticle(engine, container, parent, splitParticlesOptions) {
4
4
  const destroyOptions = parent.options.destroy;
@@ -43,14 +43,14 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
43
43
  }
44
44
  options.load(splitParticlesOptions);
45
45
  const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
46
- x: parent.position.x + randomInRange(offset),
47
- y: parent.position.y + randomInRange(offset),
46
+ x: parent.position.x + randomInRangeValue(offset),
47
+ y: parent.position.y + randomInRangeValue(offset),
48
48
  };
49
49
  return container.particles.addParticle(position, options, parent.group, (particle) => {
50
50
  if (particle.size.value < minDestroySize) {
51
51
  return false;
52
52
  }
53
- particle.velocity.length = randomInRange(setRangeValue(parent.velocity.length, particle.velocity.length));
53
+ particle.velocity.length = randomInRangeValue(setRangeValue(parent.velocity.length, particle.velocity.length));
54
54
  particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
55
55
  particle.unbreakable = true;
56
56
  setTimeout(() => {
package/browser/index.js CHANGED
@@ -1,7 +1,9 @@
1
- import { DestroyUpdater } from "./DestroyUpdater.js";
2
- export async function loadDestroyUpdater(engine, refresh = true) {
3
- engine.checkVersion("3.9.1");
4
- await engine.addParticleUpdater("destroy", container => {
5
- return Promise.resolve(new DestroyUpdater(engine, container));
6
- }, refresh);
1
+ export function loadDestroyUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.1");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("destroy", async (container) => {
5
+ const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
+ return new DestroyUpdater(e, container);
7
+ });
8
+ });
7
9
  }
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DestroyUpdater = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const Destroy_js_1 = require("./Options/Classes/Destroy.js");
6
- const DestroyMode_js_1 = require("./Enums/DestroyMode.js");
7
- const Utils_js_1 = require("./Utils.js");
8
- class DestroyUpdater {
1
+ import { getRangeValue, percentDenominator, } from "@tsparticles/engine";
2
+ import { Destroy } from "./Options/Classes/Destroy.js";
3
+ import { DestroyMode } from "./Enums/DestroyMode.js";
4
+ import { split } from "./Utils.js";
5
+ export class DestroyUpdater {
9
6
  constructor(engine, container) {
10
7
  this.container = container;
11
8
  this.engine = engine;
@@ -17,30 +14,26 @@ class DestroyUpdater {
17
14
  }
18
15
  particle.splitCount = 0;
19
16
  const destroyBoundsOptions = destroyOptions.bounds;
20
- if (!particle.destroyBounds) {
21
- particle.destroyBounds = {};
22
- }
17
+ particle.destroyBounds ??= {};
23
18
  const { bottom, left, right, top } = destroyBoundsOptions, { destroyBounds } = particle, canvasSize = container.canvas.size;
24
19
  if (bottom) {
25
- destroyBounds.bottom = ((0, engine_1.getRangeValue)(bottom) * canvasSize.height) / engine_1.percentDenominator;
20
+ destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / percentDenominator;
26
21
  }
27
22
  if (left) {
28
- destroyBounds.left = ((0, engine_1.getRangeValue)(left) * canvasSize.width) / engine_1.percentDenominator;
23
+ destroyBounds.left = (getRangeValue(left) * canvasSize.width) / percentDenominator;
29
24
  }
30
25
  if (right) {
31
- destroyBounds.right = ((0, engine_1.getRangeValue)(right) * canvasSize.width) / engine_1.percentDenominator;
26
+ destroyBounds.right = (getRangeValue(right) * canvasSize.width) / percentDenominator;
32
27
  }
33
28
  if (top) {
34
- destroyBounds.top = ((0, engine_1.getRangeValue)(top) * canvasSize.height) / engine_1.percentDenominator;
29
+ destroyBounds.top = (getRangeValue(top) * canvasSize.height) / percentDenominator;
35
30
  }
36
31
  }
37
32
  isEnabled(particle) {
38
33
  return !particle.destroyed;
39
34
  }
40
35
  loadOptions(options, ...sources) {
41
- if (!options.destroy) {
42
- options.destroy = new Destroy_js_1.Destroy();
43
- }
36
+ options.destroy ??= new Destroy();
44
37
  for (const source of sources) {
45
38
  options.destroy.load(source?.destroy);
46
39
  }
@@ -50,8 +43,8 @@ class DestroyUpdater {
50
43
  return;
51
44
  }
52
45
  const destroyOptions = particle.options.destroy;
53
- if (destroyOptions && destroyOptions.mode === DestroyMode_js_1.DestroyMode.split) {
54
- (0, Utils_js_1.split)(this.engine, this.container, particle);
46
+ if (destroyOptions?.mode === DestroyMode.split) {
47
+ split(this.engine, this.container, particle);
55
48
  }
56
49
  }
57
50
  update(particle) {
@@ -70,4 +63,3 @@ class DestroyUpdater {
70
63
  }
71
64
  }
72
65
  }
73
- exports.DestroyUpdater = DestroyUpdater;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DestroyMode = void 0;
4
- var DestroyMode;
1
+ export var DestroyMode;
5
2
  (function (DestroyMode) {
6
3
  DestroyMode["none"] = "none";
7
4
  DestroyMode["split"] = "split";
8
- })(DestroyMode || (exports.DestroyMode = DestroyMode = {}));
5
+ })(DestroyMode || (DestroyMode = {}));
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Destroy = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const DestroyBounds_js_1 = require("./DestroyBounds.js");
6
- const DestroyMode_js_1 = require("../../Enums/DestroyMode.js");
7
- const Split_js_1 = require("./Split.js");
8
- class Destroy {
1
+ import { isNull } from "@tsparticles/engine";
2
+ import { DestroyBounds } from "./DestroyBounds.js";
3
+ import { DestroyMode } from "../../Enums/DestroyMode.js";
4
+ import { Split } from "./Split.js";
5
+ export class Destroy {
9
6
  constructor() {
10
- this.bounds = new DestroyBounds_js_1.DestroyBounds();
11
- this.mode = DestroyMode_js_1.DestroyMode.none;
12
- this.split = new Split_js_1.Split();
7
+ this.bounds = new DestroyBounds();
8
+ this.mode = DestroyMode.none;
9
+ this.split = new Split();
13
10
  }
14
11
  load(data) {
15
- if ((0, engine_1.isNull)(data)) {
12
+ if (isNull(data)) {
16
13
  return;
17
14
  }
18
15
  if (data.mode) {
@@ -24,4 +21,3 @@ class Destroy {
24
21
  this.split.load(data.split);
25
22
  }
26
23
  }
27
- exports.Destroy = Destroy;
@@ -1,24 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DestroyBounds = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class DestroyBounds {
1
+ import { isNull, setRangeValue } from "@tsparticles/engine";
2
+ export class DestroyBounds {
6
3
  load(data) {
7
- if ((0, engine_1.isNull)(data)) {
4
+ if (isNull(data)) {
8
5
  return;
9
6
  }
10
7
  if (data.bottom !== undefined) {
11
- this.bottom = (0, engine_1.setRangeValue)(data.bottom);
8
+ this.bottom = setRangeValue(data.bottom);
12
9
  }
13
10
  if (data.left !== undefined) {
14
- this.left = (0, engine_1.setRangeValue)(data.left);
11
+ this.left = setRangeValue(data.left);
15
12
  }
16
13
  if (data.right !== undefined) {
17
- this.right = (0, engine_1.setRangeValue)(data.right);
14
+ this.right = setRangeValue(data.right);
18
15
  }
19
16
  if (data.top !== undefined) {
20
- this.top = (0, engine_1.setRangeValue)(data.top);
17
+ this.top = setRangeValue(data.top);
21
18
  }
22
19
  }
23
20
  }
24
- exports.DestroyBounds = DestroyBounds;
@@ -1,30 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Split = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const SplitFactor_js_1 = require("./SplitFactor.js");
6
- const SplitRate_js_1 = require("./SplitRate.js");
7
- class Split {
1
+ import { OptionsColor, deepExtend, executeOnSingleOrMultiple, isNull, } from "@tsparticles/engine";
2
+ import { SplitFactor } from "./SplitFactor.js";
3
+ import { SplitRate } from "./SplitRate.js";
4
+ export class Split {
8
5
  constructor() {
9
6
  this.count = 1;
10
- this.factor = new SplitFactor_js_1.SplitFactor();
11
- this.rate = new SplitRate_js_1.SplitRate();
7
+ this.factor = new SplitFactor();
8
+ this.rate = new SplitRate();
12
9
  this.sizeOffset = true;
13
10
  }
14
11
  load(data) {
15
- if ((0, engine_1.isNull)(data)) {
12
+ if (isNull(data)) {
16
13
  return;
17
14
  }
18
15
  if (data.color !== undefined) {
19
- this.color = engine_1.OptionsColor.create(this.color, data.color);
16
+ this.color = OptionsColor.create(this.color, data.color);
20
17
  }
21
18
  if (data.count !== undefined) {
22
19
  this.count = data.count;
23
20
  }
24
21
  this.factor.load(data.factor);
25
22
  this.rate.load(data.rate);
26
- this.particles = (0, engine_1.executeOnSingleOrMultiple)(data.particles, particles => {
27
- return (0, engine_1.deepExtend)({}, particles);
23
+ this.particles = executeOnSingleOrMultiple(data.particles, particles => {
24
+ return deepExtend({}, particles);
28
25
  });
29
26
  if (data.sizeOffset !== undefined) {
30
27
  this.sizeOffset = data.sizeOffset;
@@ -43,4 +40,3 @@ class Split {
43
40
  }
44
41
  }
45
42
  }
46
- exports.Split = Split;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SplitFactor = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class SplitFactor extends engine_1.ValueWithRandom {
1
+ import { ValueWithRandom } from "@tsparticles/engine";
2
+ export class SplitFactor extends ValueWithRandom {
6
3
  constructor() {
7
4
  super();
8
5
  this.value = 3;
9
6
  }
10
7
  }
11
- exports.SplitFactor = SplitFactor;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SplitRate = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class SplitRate extends engine_1.ValueWithRandom {
1
+ import { ValueWithRandom } from "@tsparticles/engine";
2
+ export class SplitRate extends ValueWithRandom {
6
3
  constructor() {
7
4
  super();
8
5
  this.value = { min: 4, max: 9 };
9
6
  }
10
7
  }
11
- exports.SplitRate = SplitRate;
@@ -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,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/Types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/cjs/Utils.js CHANGED
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.split = split;
4
- const engine_1 = require("@tsparticles/engine");
1
+ import { PixelMode, getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
5
2
  const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
6
3
  function addSplitParticle(engine, container, parent, splitParticlesOptions) {
7
4
  const destroyOptions = parent.options.destroy;
8
5
  if (!destroyOptions) {
9
6
  return;
10
7
  }
11
- const splitOptions = destroyOptions.split, options = (0, engine_1.loadParticlesOptions)(engine, container, parent.options), factor = (0, engine_1.getRangeValue)(splitOptions.factor.value), parentColor = parent.getFillColor();
8
+ const splitOptions = destroyOptions.split, options = loadParticlesOptions(engine, container, parent.options), factor = getRangeValue(splitOptions.factor.value), parentColor = parent.getFillColor();
12
9
  if (splitOptions.color) {
13
10
  options.color.load(splitOptions.color);
14
11
  }
@@ -16,9 +13,9 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
16
13
  options.color.load({
17
14
  value: {
18
15
  hsl: {
19
- h: parentColor.h + (0, engine_1.getRangeValue)(splitOptions.colorOffset.h ?? defaultOffset),
20
- s: parentColor.s + (0, engine_1.getRangeValue)(splitOptions.colorOffset.s ?? defaultOffset),
21
- l: parentColor.l + (0, engine_1.getRangeValue)(splitOptions.colorOffset.l ?? defaultOffset),
16
+ h: parentColor.h + getRangeValue(splitOptions.colorOffset.h ?? defaultOffset),
17
+ s: parentColor.s + getRangeValue(splitOptions.colorOffset.s ?? defaultOffset),
18
+ l: parentColor.l + getRangeValue(splitOptions.colorOffset.l ?? defaultOffset),
22
19
  },
23
20
  },
24
21
  });
@@ -34,10 +31,10 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
34
31
  center: {
35
32
  x: parent.position.x,
36
33
  y: parent.position.y,
37
- mode: engine_1.PixelMode.precise,
34
+ mode: PixelMode.precise,
38
35
  },
39
36
  });
40
- if ((0, engine_1.isNumber)(options.size.value)) {
37
+ if (isNumber(options.size.value)) {
41
38
  options.size.value /= factor;
42
39
  }
43
40
  else {
@@ -45,15 +42,15 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
45
42
  options.size.value.max /= factor;
46
43
  }
47
44
  options.load(splitParticlesOptions);
48
- const offset = splitOptions.sizeOffset ? (0, engine_1.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset, position = {
49
- x: parent.position.x + (0, engine_1.randomInRange)(offset),
50
- y: parent.position.y + (0, engine_1.randomInRange)(offset),
45
+ const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
46
+ x: parent.position.x + randomInRangeValue(offset),
47
+ y: parent.position.y + randomInRangeValue(offset),
51
48
  };
52
49
  return container.particles.addParticle(position, options, parent.group, (particle) => {
53
50
  if (particle.size.value < minDestroySize) {
54
51
  return false;
55
52
  }
56
- particle.velocity.length = (0, engine_1.randomInRange)((0, engine_1.setRangeValue)(parent.velocity.length, particle.velocity.length));
53
+ particle.velocity.length = randomInRangeValue(setRangeValue(parent.velocity.length, particle.velocity.length));
57
54
  particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
58
55
  particle.unbreakable = true;
59
56
  setTimeout(() => {
@@ -62,7 +59,7 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
62
59
  return true;
63
60
  });
64
61
  }
65
- function split(engine, container, particle) {
62
+ export function split(engine, container, particle) {
66
63
  const destroyOptions = particle.options.destroy;
67
64
  if (!destroyOptions) {
68
65
  return;
@@ -72,7 +69,7 @@ function split(engine, container, particle) {
72
69
  (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {
73
70
  return;
74
71
  }
75
- const rate = (0, engine_1.getRangeValue)(splitOptions.rate.value), particlesSplitOptions = (0, engine_1.itemFromSingleOrMultiple)(splitOptions.particles);
72
+ const rate = getRangeValue(splitOptions.rate.value), particlesSplitOptions = itemFromSingleOrMultiple(splitOptions.particles);
76
73
  for (let i = 0; i < rate; i++) {
77
74
  addSplitParticle(engine, container, particle, particlesSplitOptions);
78
75
  }
package/cjs/index.js CHANGED
@@ -1,10 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadDestroyUpdater = loadDestroyUpdater;
4
- const DestroyUpdater_js_1 = require("./DestroyUpdater.js");
5
- async function loadDestroyUpdater(engine, refresh = true) {
6
- engine.checkVersion("3.9.1");
7
- await engine.addParticleUpdater("destroy", container => {
8
- return Promise.resolve(new DestroyUpdater_js_1.DestroyUpdater(engine, container));
9
- }, refresh);
1
+ export function loadDestroyUpdater(engine) {
2
+ engine.checkVersion("4.0.0-alpha.1");
3
+ engine.register(e => {
4
+ e.addParticleUpdater("destroy", async (container) => {
5
+ const { DestroyUpdater } = await import("./DestroyUpdater.js");
6
+ return new DestroyUpdater(e, container);
7
+ });
8
+ });
10
9
  }
@@ -0,0 +1,100 @@
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.1
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_destroy"] = this["webpackChunk_tsparticles_updater_destroy"] || []).push([["dist_browser_DestroyUpdater_js"],{
19
+
20
+ /***/ "./dist/browser/DestroyUpdater.js"
21
+ /*!****************************************!*\
22
+ !*** ./dist/browser/DestroyUpdater.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 */ DestroyUpdater: () => (/* binding */ DestroyUpdater)\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_Destroy_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Destroy.js */ \"./dist/browser/Options/Classes/Destroy.js\");\n/* harmony import */ var _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Enums/DestroyMode.js */ \"./dist/browser/Enums/DestroyMode.js\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\n\nclass DestroyUpdater {\n constructor(engine, container) {\n this.container = container;\n this.engine = engine;\n }\n init(particle) {\n const container = this.container,\n particlesOptions = particle.options,\n destroyOptions = particlesOptions.destroy;\n if (!destroyOptions) {\n return;\n }\n particle.splitCount = 0;\n const destroyBoundsOptions = destroyOptions.bounds;\n particle.destroyBounds ??= {};\n const {\n bottom,\n left,\n right,\n top\n } = destroyBoundsOptions,\n {\n destroyBounds\n } = particle,\n canvasSize = container.canvas.size;\n if (bottom) {\n destroyBounds.bottom = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(bottom) * canvasSize.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n if (left) {\n destroyBounds.left = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(left) * canvasSize.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n if (right) {\n destroyBounds.right = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(right) * canvasSize.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n if (top) {\n destroyBounds.top = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(top) * canvasSize.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n }\n isEnabled(particle) {\n return !particle.destroyed;\n }\n loadOptions(options, ...sources) {\n options.destroy ??= new _Options_Classes_Destroy_js__WEBPACK_IMPORTED_MODULE_1__.Destroy();\n for (const source of sources) {\n options.destroy.load(source?.destroy);\n }\n }\n particleDestroyed(particle, override) {\n if (override) {\n return;\n }\n const destroyOptions = particle.options.destroy;\n if (destroyOptions?.mode === _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__.DestroyMode.split) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__.split)(this.engine, this.container, particle);\n }\n }\n update(particle) {\n if (!this.isEnabled(particle)) {\n return;\n }\n const position = particle.getPosition(),\n bounds = particle.destroyBounds;\n if (!bounds) {\n return;\n }\n if (bounds.bottom !== undefined && position.y >= bounds.bottom || bounds.left !== undefined && position.x <= bounds.left || bounds.right !== undefined && position.x >= bounds.right || bounds.top !== undefined && position.y <= bounds.top) {\n particle.destroy();\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/DestroyUpdater.js?\n}");
27
+
28
+ /***/ },
29
+
30
+ /***/ "./dist/browser/Enums/DestroyMode.js"
31
+ /*!*******************************************!*\
32
+ !*** ./dist/browser/Enums/DestroyMode.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 */ DestroyMode: () => (/* binding */ DestroyMode)\n/* harmony export */ });\nvar DestroyMode;\n(function (DestroyMode) {\n DestroyMode[\"none\"] = \"none\";\n DestroyMode[\"split\"] = \"split\";\n})(DestroyMode || (DestroyMode = {}));\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Enums/DestroyMode.js?\n}");
37
+
38
+ /***/ },
39
+
40
+ /***/ "./dist/browser/Options/Classes/Destroy.js"
41
+ /*!*************************************************!*\
42
+ !*** ./dist/browser/Options/Classes/Destroy.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 */ Destroy: () => (/* binding */ Destroy)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _DestroyBounds_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DestroyBounds.js */ \"./dist/browser/Options/Classes/DestroyBounds.js\");\n/* harmony import */ var _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Enums/DestroyMode.js */ \"./dist/browser/Enums/DestroyMode.js\");\n/* harmony import */ var _Split_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Split.js */ \"./dist/browser/Options/Classes/Split.js\");\n\n\n\n\nclass Destroy {\n constructor() {\n this.bounds = new _DestroyBounds_js__WEBPACK_IMPORTED_MODULE_1__.DestroyBounds();\n this.mode = _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__.DestroyMode.none;\n this.split = new _Split_js__WEBPACK_IMPORTED_MODULE_3__.Split();\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.mode) {\n this.mode = data.mode;\n }\n if (data.bounds) {\n this.bounds.load(data.bounds);\n }\n this.split.load(data.split);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Options/Classes/Destroy.js?\n}");
47
+
48
+ /***/ },
49
+
50
+ /***/ "./dist/browser/Options/Classes/DestroyBounds.js"
51
+ /*!*******************************************************!*\
52
+ !*** ./dist/browser/Options/Classes/DestroyBounds.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 */ DestroyBounds: () => (/* binding */ DestroyBounds)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass DestroyBounds {\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.bottom !== undefined) {\n this.bottom = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.bottom);\n }\n if (data.left !== undefined) {\n this.left = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.left);\n }\n if (data.right !== undefined) {\n this.right = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.right);\n }\n if (data.top !== undefined) {\n this.top = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.top);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Options/Classes/DestroyBounds.js?\n}");
57
+
58
+ /***/ },
59
+
60
+ /***/ "./dist/browser/Options/Classes/Split.js"
61
+ /*!***********************************************!*\
62
+ !*** ./dist/browser/Options/Classes/Split.js ***!
63
+ \***********************************************/
64
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
65
+
66
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Split: () => (/* binding */ Split)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _SplitFactor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SplitFactor.js */ \"./dist/browser/Options/Classes/SplitFactor.js\");\n/* harmony import */ var _SplitRate_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SplitRate.js */ \"./dist/browser/Options/Classes/SplitRate.js\");\n\n\n\nclass Split {\n constructor() {\n this.count = 1;\n this.factor = new _SplitFactor_js__WEBPACK_IMPORTED_MODULE_1__.SplitFactor();\n this.rate = new _SplitRate_js__WEBPACK_IMPORTED_MODULE_2__.SplitRate();\n this.sizeOffset = true;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.color !== undefined) {\n this.color = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(this.color, data.color);\n }\n if (data.count !== undefined) {\n this.count = data.count;\n }\n this.factor.load(data.factor);\n this.rate.load(data.rate);\n this.particles = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.executeOnSingleOrMultiple)(data.particles, particles => {\n return (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, particles);\n });\n if (data.sizeOffset !== undefined) {\n this.sizeOffset = data.sizeOffset;\n }\n if (data.colorOffset) {\n this.colorOffset = this.colorOffset ?? {};\n if (data.colorOffset.h !== undefined) {\n this.colorOffset.h = data.colorOffset.h;\n }\n if (data.colorOffset.s !== undefined) {\n this.colorOffset.s = data.colorOffset.s;\n }\n if (data.colorOffset.l !== undefined) {\n this.colorOffset.l = data.colorOffset.l;\n }\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Options/Classes/Split.js?\n}");
67
+
68
+ /***/ },
69
+
70
+ /***/ "./dist/browser/Options/Classes/SplitFactor.js"
71
+ /*!*****************************************************!*\
72
+ !*** ./dist/browser/Options/Classes/SplitFactor.js ***!
73
+ \*****************************************************/
74
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
75
+
76
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SplitFactor: () => (/* binding */ SplitFactor)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass SplitFactor extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n constructor() {\n super();\n this.value = 3;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Options/Classes/SplitFactor.js?\n}");
77
+
78
+ /***/ },
79
+
80
+ /***/ "./dist/browser/Options/Classes/SplitRate.js"
81
+ /*!***************************************************!*\
82
+ !*** ./dist/browser/Options/Classes/SplitRate.js ***!
83
+ \***************************************************/
84
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
85
+
86
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SplitRate: () => (/* binding */ SplitRate)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass SplitRate extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n constructor() {\n super();\n this.value = {\n min: 4,\n max: 9\n };\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Options/Classes/SplitRate.js?\n}");
87
+
88
+ /***/ },
89
+
90
+ /***/ "./dist/browser/Utils.js"
91
+ /*!*******************************!*\
92
+ !*** ./dist/browser/Utils.js ***!
93
+ \*******************************/
94
+ (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
95
+
96
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ split: () => (/* binding */ split)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultOffset = 0,\n minDestroySize = 0.5,\n defaultSplitCount = 0,\n increment = 1,\n unbreakableTime = 500,\n minSplitCount = 0;\nfunction addSplitParticle(engine, container, parent, splitParticlesOptions) {\n const destroyOptions = parent.options.destroy;\n if (!destroyOptions) {\n return;\n }\n const splitOptions = destroyOptions.split,\n options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.loadParticlesOptions)(engine, container, parent.options),\n factor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.factor.value),\n parentColor = parent.getFillColor();\n if (splitOptions.color) {\n options.color.load(splitOptions.color);\n } else if (splitOptions.colorOffset && parentColor) {\n options.color.load({\n value: {\n hsl: {\n h: parentColor.h + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.colorOffset.h ?? defaultOffset),\n s: parentColor.s + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.colorOffset.s ?? defaultOffset),\n l: parentColor.l + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.colorOffset.l ?? defaultOffset)\n }\n }\n });\n } else {\n options.color.load({\n value: {\n hsl: parent.getFillColor()\n }\n });\n }\n options.move.load({\n center: {\n x: parent.position.x,\n y: parent.position.y,\n mode: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.PixelMode.precise\n }\n });\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNumber)(options.size.value)) {\n options.size.value /= factor;\n } else {\n options.size.value.min /= factor;\n options.size.value.max /= factor;\n }\n options.load(splitParticlesOptions);\n const offset = splitOptions.sizeOffset ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset,\n position = {\n x: parent.position.x + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)(offset),\n y: parent.position.y + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)(offset)\n };\n return container.particles.addParticle(position, options, parent.group, particle => {\n if (particle.size.value < minDestroySize) {\n return false;\n }\n particle.velocity.length = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(parent.velocity.length, particle.velocity.length));\n particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;\n particle.unbreakable = true;\n setTimeout(() => {\n particle.unbreakable = false;\n }, unbreakableTime);\n return true;\n });\n}\nfunction split(engine, container, particle) {\n const destroyOptions = particle.options.destroy;\n if (!destroyOptions) {\n return;\n }\n const splitOptions = destroyOptions.split;\n if (splitOptions.count >= minSplitCount && (particle.splitCount === undefined || particle.splitCount++ > splitOptions.count)) {\n return;\n }\n const rate = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.rate.value),\n particlesSplitOptions = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(splitOptions.particles);\n for (let i = 0; i < rate; i++) {\n addSplitParticle(engine, container, particle, particlesSplitOptions);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Utils.js?\n}");
97
+
98
+ /***/ }
99
+
100
+ }]);
@@ -14,9 +14,7 @@ export class DestroyUpdater {
14
14
  }
15
15
  particle.splitCount = 0;
16
16
  const destroyBoundsOptions = destroyOptions.bounds;
17
- if (!particle.destroyBounds) {
18
- particle.destroyBounds = {};
19
- }
17
+ particle.destroyBounds ??= {};
20
18
  const { bottom, left, right, top } = destroyBoundsOptions, { destroyBounds } = particle, canvasSize = container.canvas.size;
21
19
  if (bottom) {
22
20
  destroyBounds.bottom = (getRangeValue(bottom) * canvasSize.height) / percentDenominator;
@@ -35,9 +33,7 @@ export class DestroyUpdater {
35
33
  return !particle.destroyed;
36
34
  }
37
35
  loadOptions(options, ...sources) {
38
- if (!options.destroy) {
39
- options.destroy = new Destroy();
40
- }
36
+ options.destroy ??= new Destroy();
41
37
  for (const source of sources) {
42
38
  options.destroy.load(source?.destroy);
43
39
  }
@@ -47,7 +43,7 @@ export class DestroyUpdater {
47
43
  return;
48
44
  }
49
45
  const destroyOptions = particle.options.destroy;
50
- if (destroyOptions && destroyOptions.mode === DestroyMode.split) {
46
+ if (destroyOptions?.mode === DestroyMode.split) {
51
47
  split(this.engine, this.container, particle);
52
48
  }
53
49
  }
package/esm/Utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PixelMode, getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRange, setRangeValue, } from "@tsparticles/engine";
1
+ import { PixelMode, getRangeValue, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
2
2
  const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
3
3
  function addSplitParticle(engine, container, parent, splitParticlesOptions) {
4
4
  const destroyOptions = parent.options.destroy;
@@ -43,14 +43,14 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
43
43
  }
44
44
  options.load(splitParticlesOptions);
45
45
  const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
46
- x: parent.position.x + randomInRange(offset),
47
- y: parent.position.y + randomInRange(offset),
46
+ x: parent.position.x + randomInRangeValue(offset),
47
+ y: parent.position.y + randomInRangeValue(offset),
48
48
  };
49
49
  return container.particles.addParticle(position, options, parent.group, (particle) => {
50
50
  if (particle.size.value < minDestroySize) {
51
51
  return false;
52
52
  }
53
- particle.velocity.length = randomInRange(setRangeValue(parent.velocity.length, particle.velocity.length));
53
+ particle.velocity.length = randomInRangeValue(setRangeValue(parent.velocity.length, particle.velocity.length));
54
54
  particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
55
55
  particle.unbreakable = true;
56
56
  setTimeout(() => {