tsparticles 2.3.1 → 2.3.3

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
- * v2.3.1
7
+ * v2.3.3
8
8
  */
9
9
  (function webpackUniversalModuleDefinition(root, factory) {
10
10
  if(typeof exports === 'object' && typeof module === 'object')
@@ -20,7 +20,7 @@ return /******/ (() => { // webpackBootstrap
20
20
  /******/ "use strict";
21
21
  /******/ var __webpack_modules__ = ({
22
22
 
23
- /***/ 441:
23
+ /***/ 74:
24
24
  /***/ (() => {
25
25
 
26
26
 
@@ -1898,8 +1898,6 @@ __webpack_require__.d(__webpack_exports__, {
1898
1898
  "Rectangle": () => (/* reexport */ Rectangle),
1899
1899
  "Responsive": () => (/* reexport */ Responsive),
1900
1900
  "RgbColorManager": () => (/* reexport */ RgbColorManager),
1901
- "Rotate": () => (/* reexport */ Rotate),
1902
- "RotateAnimation": () => (/* reexport */ RotateAnimation),
1903
1901
  "Shadow": () => (/* reexport */ Shadow),
1904
1902
  "Shape": () => (/* reexport */ Shape),
1905
1903
  "Size": () => (/* reexport */ Size),
@@ -1962,6 +1960,7 @@ __webpack_require__.d(__webpack_exports__, {
1962
1960
  "getStyleFromHsl": () => (/* reexport */ getStyleFromHsl),
1963
1961
  "getStyleFromRgb": () => (/* reexport */ getStyleFromRgb),
1964
1962
  "getValue": () => (/* reexport */ getValue),
1963
+ "hasMatchMedia": () => (/* reexport */ hasMatchMedia),
1965
1964
  "hslToRgb": () => (/* reexport */ hslToRgb),
1966
1965
  "hslaToRgba": () => (/* reexport */ hslaToRgba),
1967
1966
  "isDivModeEnabled": () => (/* reexport */ isDivModeEnabled),
@@ -1989,6 +1988,7 @@ __webpack_require__.d(__webpack_exports__, {
1989
1988
  "rectBounce": () => (/* reexport */ rectBounce),
1990
1989
  "resizeEvent": () => (/* reexport */ resizeEvent),
1991
1990
  "rgbToHsl": () => (/* reexport */ rgbToHsl),
1991
+ "safeMatchMedia": () => (/* reexport */ safeMatchMedia),
1992
1992
  "setRandom": () => (/* reexport */ setRandom),
1993
1993
  "setRangeValue": () => (/* reexport */ setRangeValue),
1994
1994
  "singleDivModeExecute": () => (/* reexport */ singleDivModeExecute),
@@ -2489,6 +2489,16 @@ function checkSelector(element, selectors) {
2489
2489
  function isSsr() {
2490
2490
  return typeof window === "undefined" || !window || typeof window.document === "undefined" || !window.document;
2491
2491
  }
2492
+ function hasMatchMedia() {
2493
+ return !isSsr() && typeof matchMedia !== "undefined";
2494
+ }
2495
+ function safeMatchMedia(query) {
2496
+ if (!hasMatchMedia()) {
2497
+ return;
2498
+ }
2499
+
2500
+ return matchMedia(query);
2501
+ }
2492
2502
  function animate() {
2493
2503
  return isSsr() ? callback => setTimeout(callback) : callback => (requestAnimationFrame || setTimeout)(callback);
2494
2504
  }
@@ -2507,8 +2517,7 @@ function arrayRandomIndex(array) {
2507
2517
  return Math.floor(getRandom() * array.length);
2508
2518
  }
2509
2519
  function itemFromArray(array, index, useIndex = true) {
2510
- const fixedIndex = index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array);
2511
- return array[fixedIndex];
2520
+ return array[index !== undefined && useIndex ? index % array.length : arrayRandomIndex(array)];
2512
2521
  }
2513
2522
  function isPointInside(point, size, offset, radius, direction) {
2514
2523
  return areBoundsInside(calculateBounds(point, radius !== null && radius !== void 0 ? radius : 0), size, offset, direction);
@@ -2709,8 +2718,8 @@ function findItemFromSingleOrMultiple(obj, callback) {
2709
2718
  const randomColorValue = "random",
2710
2719
  midColorValue = "mid",
2711
2720
  colorManagers = new Map();
2712
- function addColorManager(key, manager) {
2713
- colorManagers.set(key, manager);
2721
+ function addColorManager(manager) {
2722
+ colorManagers.set(manager.key, manager);
2714
2723
  }
2715
2724
 
2716
2725
  function hue2rgb(p, q, t) {
@@ -2965,6 +2974,8 @@ function getLinkRandomColor(optColor, blink, consent) {
2965
2974
  return randomColorValue;
2966
2975
  }
2967
2976
 
2977
+ return midColorValue;
2978
+ } else if (color === midColorValue) {
2968
2979
  return midColorValue;
2969
2980
  } else {
2970
2981
  return rangeColorToRgb({
@@ -3070,7 +3081,7 @@ function drawParticle(data) {
3070
3081
  }
3071
3082
 
3072
3083
  context.beginPath();
3073
- const angle = particle.rotation + (particle.options.rotate.path ? particle.velocity.angle : 0);
3084
+ const angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : 0);
3074
3085
 
3075
3086
  if (angle !== 0) {
3076
3087
  context.rotate(angle);
@@ -3800,7 +3811,7 @@ class EventListeners {
3800
3811
  container.interactivity.element = container.canvas.element;
3801
3812
  }
3802
3813
 
3803
- const mediaMatch = !isSsr() && typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)");
3814
+ const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)");
3804
3815
 
3805
3816
  if (mediaMatch) {
3806
3817
  if (mediaMatch.addEventListener !== undefined) {
@@ -5455,70 +5466,6 @@ class ParticlesNumber {
5455
5466
  }
5456
5467
  }
5457
5468
 
5458
- }
5459
- ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Rotate/RotateAnimation.js
5460
-
5461
- class RotateAnimation {
5462
- constructor() {
5463
- this.enable = false;
5464
- this.speed = 0;
5465
- this.decay = 0;
5466
- this.sync = false;
5467
- }
5468
-
5469
- load(data) {
5470
- if (!data) {
5471
- return;
5472
- }
5473
-
5474
- if (data.enable !== undefined) {
5475
- this.enable = data.enable;
5476
- }
5477
-
5478
- if (data.speed !== undefined) {
5479
- this.speed = setRangeValue(data.speed);
5480
- }
5481
-
5482
- if (data.decay !== undefined) {
5483
- this.decay = setRangeValue(data.decay);
5484
- }
5485
-
5486
- if (data.sync !== undefined) {
5487
- this.sync = data.sync;
5488
- }
5489
- }
5490
-
5491
- }
5492
- ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Rotate/Rotate.js
5493
-
5494
-
5495
- class Rotate extends ValueWithRandom {
5496
- constructor() {
5497
- super();
5498
- this.animation = new RotateAnimation();
5499
- this.direction = "clockwise";
5500
- this.path = false;
5501
- this.value = 0;
5502
- }
5503
-
5504
- load(data) {
5505
- if (!data) {
5506
- return;
5507
- }
5508
-
5509
- super.load(data);
5510
-
5511
- if (data.direction !== undefined) {
5512
- this.direction = data.direction;
5513
- }
5514
-
5515
- this.animation.load(data.animation);
5516
-
5517
- if (data.path !== undefined) {
5518
- this.path = data.path;
5519
- }
5520
- }
5521
-
5522
5469
  }
5523
5470
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Options/Classes/Particles/Shadow.js
5524
5471
 
@@ -5843,7 +5790,6 @@ class ZIndex extends ValueWithRandom {
5843
5790
 
5844
5791
 
5845
5792
 
5846
-
5847
5793
  class ParticlesOptions {
5848
5794
  constructor(engine, container) {
5849
5795
  this._engine = engine;
@@ -5857,7 +5803,6 @@ class ParticlesOptions {
5857
5803
  this.number = new ParticlesNumber();
5858
5804
  this.opacity = new Opacity();
5859
5805
  this.reduceDuplicates = false;
5860
- this.rotate = new Rotate();
5861
5806
  this.shadow = new Shadow();
5862
5807
  this.shape = new Shape();
5863
5808
  this.size = new Size();
@@ -5893,7 +5838,6 @@ class ParticlesOptions {
5893
5838
  this.reduceDuplicates = data.reduceDuplicates;
5894
5839
  }
5895
5840
 
5896
- this.rotate.load(data.rotate);
5897
5841
  this.shape.load(data.shape);
5898
5842
  this.size.load(data.size);
5899
5843
  this.shadow.load(data.shadow);
@@ -6135,7 +6079,7 @@ class Options {
6135
6079
  this.load(chosenTheme.options);
6136
6080
  }
6137
6081
  } else {
6138
- const mediaMatch = typeof matchMedia !== "undefined" && matchMedia("(prefers-color-scheme: dark)"),
6082
+ const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"),
6139
6083
  clientDarkMode = mediaMatch && mediaMatch.matches,
6140
6084
  defaultTheme = this._findDefaultTheme(clientDarkMode ? "dark" : "light");
6141
6085
 
@@ -6262,6 +6206,7 @@ class Particle {
6262
6206
  this.group = group;
6263
6207
  this._engine = engine;
6264
6208
  this.fill = true;
6209
+ this.pathRotation = false;
6265
6210
  this.close = true;
6266
6211
  this.lastPathTime = 0;
6267
6212
  this.destroyed = false;
@@ -6847,10 +6792,6 @@ class Particles {
6847
6792
  this.limit = 0;
6848
6793
  this.needsSort = false;
6849
6794
  this.lastZIndex = 0;
6850
- this.freqs = {
6851
- links: new Map(),
6852
- triangles: new Map()
6853
- };
6854
6795
  this.interactionManager = new InteractionManager(this._engine, container);
6855
6796
  const canvasSize = this.container.canvas.size;
6856
6797
  this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, canvasSize.width * 3 / 2, canvasSize.height * 3 / 2), 4);
@@ -6924,45 +6865,6 @@ class Particles {
6924
6865
  }
6925
6866
  }
6926
6867
 
6927
- getLinkFrequency(p1, p2) {
6928
- const range = setRangeValue(p1.id, p2.id),
6929
- key = `${getRangeMin(range)}_${getRangeMax(range)}`;
6930
- let res = this.freqs.links.get(key);
6931
-
6932
- if (res === undefined) {
6933
- res = getRandom();
6934
- this.freqs.links.set(key, res);
6935
- }
6936
-
6937
- return res;
6938
- }
6939
-
6940
- getTriangleFrequency(p1, p2, p3) {
6941
- let [id1, id2, id3] = [p1.id, p2.id, p3.id];
6942
-
6943
- if (id1 > id2) {
6944
- [id2, id1] = [id1, id2];
6945
- }
6946
-
6947
- if (id2 > id3) {
6948
- [id3, id2] = [id2, id3];
6949
- }
6950
-
6951
- if (id1 > id3) {
6952
- [id3, id1] = [id1, id3];
6953
- }
6954
-
6955
- const key = `${id1}_${id2}_${id3}`;
6956
- let res = this.freqs.triangles.get(key);
6957
-
6958
- if (res === undefined) {
6959
- res = getRandom();
6960
- this.freqs.triangles.set(key, res);
6961
- }
6962
-
6963
- return res;
6964
- }
6965
-
6966
6868
  handleClickMode(mode) {
6967
6869
  this.interactionManager.handleClickMode(mode);
6968
6870
  }
@@ -6974,8 +6876,6 @@ class Particles {
6974
6876
  options = container.actualOptions;
6975
6877
  this.lastZIndex = 0;
6976
6878
  this.needsSort = false;
6977
- this.freqs.links = new Map();
6978
- this.freqs.triangles = new Map();
6979
6879
  let handled = false;
6980
6880
  this.updaters = this._engine.plugins.getUpdaters(container, true);
6981
6881
  this.interactionManager.init();
@@ -7037,7 +6937,7 @@ class Particles {
7037
6937
  }
7038
6938
 
7039
6939
  removeAt(index, quantity = 1, group, override) {
7040
- if (!(index >= 0 && index <= this.count)) {
6940
+ if (index < 0 || index > this.count) {
7041
6941
  return;
7042
6942
  }
7043
6943
 
@@ -7227,26 +7127,24 @@ class Retina {
7227
7127
  const motionOptions = this.container.actualOptions.motion;
7228
7128
 
7229
7129
  if (motionOptions && (motionOptions.disable || motionOptions.reduce.value)) {
7230
- if (isSsr() || typeof matchMedia === "undefined" || !matchMedia) {
7231
- this.reduceFactor = 1;
7232
- } else {
7233
- const mediaQuery = matchMedia("(prefers-reduced-motion: reduce)");
7130
+ const mediaQuery = safeMatchMedia("(prefers-reduced-motion: reduce)");
7234
7131
 
7235
- if (mediaQuery) {
7236
- this._handleMotionChange(mediaQuery);
7132
+ if (mediaQuery) {
7133
+ this._handleMotionChange(mediaQuery);
7237
7134
 
7238
- const handleChange = () => {
7239
- this._handleMotionChange(mediaQuery);
7135
+ const handleChange = () => {
7136
+ this._handleMotionChange(mediaQuery);
7240
7137
 
7241
- container.refresh().catch(() => {});
7242
- };
7138
+ container.refresh().catch(() => {});
7139
+ };
7243
7140
 
7244
- if (mediaQuery.addEventListener !== undefined) {
7245
- mediaQuery.addEventListener("change", handleChange);
7246
- } else if (mediaQuery.addListener !== undefined) {
7247
- mediaQuery.addListener(handleChange);
7248
- }
7141
+ if (mediaQuery.addEventListener !== undefined) {
7142
+ mediaQuery.addEventListener("change", handleChange);
7143
+ } else if (mediaQuery.addListener !== undefined) {
7144
+ mediaQuery.addListener(handleChange);
7249
7145
  }
7146
+ } else {
7147
+ this.reduceFactor = 1;
7250
7148
  }
7251
7149
  } else {
7252
7150
  this.reduceFactor = 1;
@@ -7540,7 +7438,13 @@ class Container {
7540
7438
  }
7541
7439
 
7542
7440
  exportConfiguration() {
7543
- return JSON.stringify(this.actualOptions, undefined, 2);
7441
+ return JSON.stringify(this.actualOptions, (key, value) => {
7442
+ if (key === "_engine" || key === "_container") {
7443
+ return;
7444
+ }
7445
+
7446
+ return value;
7447
+ }, 2);
7544
7448
  }
7545
7449
 
7546
7450
  exportImage(callback, type, quality) {
@@ -8047,6 +7951,17 @@ class Loader {
8047
7951
 
8048
7952
  }
8049
7953
  ;// CONCATENATED MODULE: ../../engine/dist/esm/Core/Utils/Plugins.js
7954
+ function getItemsFromInitializer(container, map, initializers, force = false) {
7955
+ let res = map.get(container);
7956
+
7957
+ if (!res || force) {
7958
+ res = [...initializers.values()].map(t => t(container));
7959
+ map.set(container, res);
7960
+ }
7961
+
7962
+ return res;
7963
+ }
7964
+
8050
7965
  class Plugins {
8051
7966
  constructor(engine) {
8052
7967
  this._engine = engine;
@@ -8119,25 +8034,11 @@ class Plugins {
8119
8034
  }
8120
8035
 
8121
8036
  getInteractors(container, force = false) {
8122
- let res = this.interactors.get(container);
8123
-
8124
- if (!res || force) {
8125
- res = [...this.interactorsInitializers.values()].map(t => t(container));
8126
- this.interactors.set(container, res);
8127
- }
8128
-
8129
- return res;
8037
+ return getItemsFromInitializer(container, this.interactors, this.interactorsInitializers, force);
8130
8038
  }
8131
8039
 
8132
8040
  getMovers(container, force = false) {
8133
- let res = this.movers.get(container);
8134
-
8135
- if (!res || force) {
8136
- res = [...this.moversInitializers.values()].map(t => t(container));
8137
- this.movers.set(container, res);
8138
- }
8139
-
8140
- return res;
8041
+ return getItemsFromInitializer(container, this.movers, this.moversInitializers, force);
8141
8042
  }
8142
8043
 
8143
8044
  getPathGenerator(type) {
@@ -8161,14 +8062,7 @@ class Plugins {
8161
8062
  }
8162
8063
 
8163
8064
  getUpdaters(container, force = false) {
8164
- let res = this.updaters.get(container);
8165
-
8166
- if (!res || force) {
8167
- res = [...this.updatersInitializers.values()].map(t => t(container));
8168
- this.updaters.set(container, res);
8169
- }
8170
-
8171
- return res;
8065
+ return getItemsFromInitializer(container, this.updaters, this.updatersInitializers, force);
8172
8066
  }
8173
8067
 
8174
8068
  loadOptions(options, sourceOptions) {
@@ -8330,6 +8224,7 @@ class Engine {
8330
8224
 
8331
8225
  class HslColorManager {
8332
8226
  constructor() {
8227
+ this.key = "hsl";
8333
8228
  this.stringPrefix = "hsl";
8334
8229
  }
8335
8230
 
@@ -8379,6 +8274,7 @@ class HslColorManager {
8379
8274
 
8380
8275
  class RgbColorManager {
8381
8276
  constructor() {
8277
+ this.key = "rgb";
8382
8278
  this.stringPrefix = "rgb";
8383
8279
  }
8384
8280
 
@@ -8447,8 +8343,8 @@ class ParticlesInteractorBase {
8447
8343
 
8448
8344
  const rgbColorManager = new RgbColorManager(),
8449
8345
  hslColorManager = new HslColorManager();
8450
- addColorManager("rgb", rgbColorManager);
8451
- addColorManager("hsl", hslColorManager);
8346
+ addColorManager(rgbColorManager);
8347
+ addColorManager(hslColorManager);
8452
8348
  const tsParticles = new Engine();
8453
8349
  tsParticles.init();
8454
8350
 
@@ -8627,10 +8523,6 @@ tsParticles.init();
8627
8523
 
8628
8524
 
8629
8525
 
8630
-
8631
-
8632
-
8633
-
8634
8526
 
8635
8527
 
8636
8528
 
@@ -10379,7 +10271,7 @@ async function loadExternalTrailInteraction(engine) {
10379
10271
 
10380
10272
 
10381
10273
  // EXTERNAL MODULE: ../../plugins/polygonMask/dist/esm/pathseg.js
10382
- var pathseg = __webpack_require__(441);
10274
+ var pathseg = __webpack_require__(74);
10383
10275
  ;// CONCATENATED MODULE: ../../plugins/polygonMask/dist/esm/Options/Classes/PolygonMaskDrawStroke.js
10384
10276
 
10385
10277
  class PolygonMaskDrawStroke {
@@ -11443,20 +11335,85 @@ const initPjs = engine => {
11443
11335
  };
11444
11336
 
11445
11337
 
11446
- ;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/AngleUpdater.js
11338
+ ;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/Options/Classes/RotateAnimation.js
11339
+
11340
+ class RotateAnimation {
11341
+ constructor() {
11342
+ this.enable = false;
11343
+ this.speed = 0;
11344
+ this.decay = 0;
11345
+ this.sync = false;
11346
+ }
11347
+
11348
+ load(data) {
11349
+ if (!data) {
11350
+ return;
11351
+ }
11352
+
11353
+ if (data.enable !== undefined) {
11354
+ this.enable = data.enable;
11355
+ }
11356
+
11357
+ if (data.speed !== undefined) {
11358
+ this.speed = setRangeValue(data.speed);
11359
+ }
11360
+
11361
+ if (data.decay !== undefined) {
11362
+ this.decay = setRangeValue(data.decay);
11363
+ }
11364
+
11365
+ if (data.sync !== undefined) {
11366
+ this.sync = data.sync;
11367
+ }
11368
+ }
11369
+
11370
+ }
11371
+ ;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/Options/Classes/Rotate.js
11372
+
11373
+
11374
+ class Rotate extends ValueWithRandom {
11375
+ constructor() {
11376
+ super();
11377
+ this.animation = new RotateAnimation();
11378
+ this.direction = "clockwise";
11379
+ this.path = false;
11380
+ this.value = 0;
11381
+ }
11382
+
11383
+ load(data) {
11384
+ if (!data) {
11385
+ return;
11386
+ }
11387
+
11388
+ super.load(data);
11389
+
11390
+ if (data.direction !== undefined) {
11391
+ this.direction = data.direction;
11392
+ }
11393
+
11394
+ this.animation.load(data.animation);
11395
+
11396
+ if (data.path !== undefined) {
11397
+ this.path = data.path;
11398
+ }
11399
+ }
11400
+
11401
+ }
11402
+ ;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/RotateUpdater.js
11403
+
11447
11404
 
11448
11405
 
11449
11406
  function updateAngle(particle, delta) {
11450
11407
  var _a, _b;
11451
11408
 
11452
- const rotate = particle.rotate;
11409
+ const rotate = particle.rotate,
11410
+ rotateOptions = particle.options.rotate;
11453
11411
 
11454
- if (!rotate) {
11412
+ if (!rotate || !rotateOptions) {
11455
11413
  return;
11456
11414
  }
11457
11415
 
11458
- const rotateOptions = particle.options.rotate,
11459
- rotateAnimation = rotateOptions.animation,
11416
+ const rotateAnimation = rotateOptions.animation,
11460
11417
  speed = ((_a = rotate.velocity) !== null && _a !== void 0 ? _a : 0) * delta.factor,
11461
11418
  max = 2 * Math.PI,
11462
11419
  decay = (_b = rotate.decay) !== null && _b !== void 0 ? _b : 1;
@@ -11491,17 +11448,23 @@ function updateAngle(particle, delta) {
11491
11448
  }
11492
11449
  }
11493
11450
 
11494
- class AngleUpdater {
11451
+ class RotateUpdater {
11495
11452
  constructor(container) {
11496
11453
  this.container = container;
11497
11454
  }
11498
11455
 
11499
11456
  init(particle) {
11500
11457
  const rotateOptions = particle.options.rotate;
11458
+
11459
+ if (!rotateOptions) {
11460
+ return;
11461
+ }
11462
+
11501
11463
  particle.rotate = {
11502
11464
  enable: rotateOptions.animation.enable,
11503
11465
  value: getRangeValue(rotateOptions.value) * Math.PI / 180
11504
11466
  };
11467
+ particle.pathRotation = rotateOptions.path;
11505
11468
  let rotateDirection = rotateOptions.direction;
11506
11469
 
11507
11470
  if (rotateDirection === "random") {
@@ -11520,7 +11483,7 @@ class AngleUpdater {
11520
11483
  break;
11521
11484
  }
11522
11485
 
11523
- const rotateAnimation = particle.options.rotate.animation;
11486
+ const rotateAnimation = rotateOptions.animation;
11524
11487
 
11525
11488
  if (rotateAnimation.enable) {
11526
11489
  particle.rotate.decay = 1 - getRangeValue(rotateAnimation.decay);
@@ -11535,9 +11498,23 @@ class AngleUpdater {
11535
11498
  }
11536
11499
 
11537
11500
  isEnabled(particle) {
11538
- const rotate = particle.options.rotate,
11539
- rotateAnimation = rotate.animation;
11540
- return !particle.destroyed && !particle.spawning && rotateAnimation.enable && !rotate.path;
11501
+ const rotate = particle.options.rotate;
11502
+
11503
+ if (!rotate) {
11504
+ return false;
11505
+ }
11506
+
11507
+ return !particle.destroyed && !particle.spawning && rotate.animation.enable && !rotate.path;
11508
+ }
11509
+
11510
+ loadOptions(options, ...sources) {
11511
+ if (!options.rotate) {
11512
+ options.rotate = new Rotate();
11513
+ }
11514
+
11515
+ for (const source of sources) {
11516
+ options.rotate.load(source === null || source === void 0 ? void 0 : source.rotate);
11517
+ }
11541
11518
  }
11542
11519
 
11543
11520
  update(particle, delta) {
@@ -11555,7 +11532,7 @@ class AngleUpdater {
11555
11532
  ;// CONCATENATED MODULE: ../../updaters/angle/dist/esm/index.js
11556
11533
 
11557
11534
  async function loadAngleUpdater(engine) {
11558
- await engine.addParticleUpdater("angle", container => new AngleUpdater(container));
11535
+ await engine.addParticleUpdater("rotate", container => new RotateUpdater(container));
11559
11536
  }
11560
11537
  ;// CONCATENATED MODULE: ../../move/base/dist/esm/Utils.js
11561
11538
 
@@ -15564,9 +15541,31 @@ function drawLinkTriangle(context, pos1, pos2, pos3, backgroundMask, composite,
15564
15541
  ;// CONCATENATED MODULE: ../../interactions/particles/links/dist/esm/LinkInstance.js
15565
15542
 
15566
15543
 
15544
+
15545
+ function getLinkKey(ids) {
15546
+ ids.sort((a, b) => a - b);
15547
+ return ids.join("_");
15548
+ }
15549
+
15550
+ function setLinkFrequency(particles, dictionary) {
15551
+ const key = getLinkKey(particles.map(t => t.id));
15552
+ let res = dictionary.get(key);
15553
+
15554
+ if (res === undefined) {
15555
+ res = getRandom();
15556
+ dictionary.set(key, res);
15557
+ }
15558
+
15559
+ return res;
15560
+ }
15561
+
15567
15562
  class LinkInstance {
15568
15563
  constructor(container) {
15569
15564
  this.container = container;
15565
+ this._freqs = {
15566
+ links: new Map(),
15567
+ triangles: new Map()
15568
+ };
15570
15569
  }
15571
15570
 
15572
15571
  drawParticle(context, particle) {
@@ -15580,7 +15579,7 @@ class LinkInstance {
15580
15579
  }
15581
15580
 
15582
15581
  context.save();
15583
- const p1Links = particle.links.filter(l => pOptions.links && container.particles.getLinkFrequency(particle, l.destination) <= pOptions.links.frequency);
15582
+ const p1Links = particle.links.filter(l => pOptions.links && this.getLinkFrequency(particle, l.destination) <= pOptions.links.frequency);
15584
15583
 
15585
15584
  for (const link of p1Links) {
15586
15585
  this.drawTriangles(container, pOptions, particle, link, p1Links);
@@ -15593,6 +15592,11 @@ class LinkInstance {
15593
15592
  context.restore();
15594
15593
  }
15595
15594
 
15595
+ init() {
15596
+ this._freqs.links = new Map();
15597
+ this._freqs.triangles = new Map();
15598
+ }
15599
+
15596
15600
  particleCreated(particle) {
15597
15601
  particle.links = [];
15598
15602
 
@@ -15702,15 +15706,14 @@ class LinkInstance {
15702
15706
  drawTriangles(container, options, p1, link, p1Links) {
15703
15707
  var _a, _b, _c;
15704
15708
 
15705
- const p2 = link.destination,
15706
- particles = container.particles;
15709
+ const p2 = link.destination;
15707
15710
 
15708
15711
  if (!(((_a = options.links) === null || _a === void 0 ? void 0 : _a.triangles.enable) && ((_b = p2.options.links) === null || _b === void 0 ? void 0 : _b.triangles.enable))) {
15709
15712
  return;
15710
15713
  }
15711
15714
 
15712
15715
  const vertices = (_c = p2.links) === null || _c === void 0 ? void 0 : _c.filter(t => {
15713
- const linkFreq = container.particles.getLinkFrequency(p2, t.destination);
15716
+ const linkFreq = this.getLinkFrequency(p2, t.destination);
15714
15717
  return p2.options.links && linkFreq <= p2.options.links.frequency && p1Links.findIndex(l => l.destination === t.destination) >= 0;
15715
15718
  });
15716
15719
 
@@ -15720,7 +15723,7 @@ class LinkInstance {
15720
15723
 
15721
15724
  for (const vertex of vertices) {
15722
15725
  const p3 = vertex.destination,
15723
- triangleFreq = particles.getTriangleFrequency(p1, p2, p3);
15726
+ triangleFreq = this.getTriangleFrequency(p1, p2, p3);
15724
15727
 
15725
15728
  if (triangleFreq > options.links.triangles.frequency) {
15726
15729
  continue;
@@ -15730,6 +15733,14 @@ class LinkInstance {
15730
15733
  }
15731
15734
  }
15732
15735
 
15736
+ getLinkFrequency(p1, p2) {
15737
+ return setLinkFrequency([p1, p2], this._freqs.links);
15738
+ }
15739
+
15740
+ getTriangleFrequency(p1, p2, p3) {
15741
+ return setLinkFrequency([p1, p2, p3], this._freqs.triangles);
15742
+ }
15743
+
15733
15744
  }
15734
15745
  ;// CONCATENATED MODULE: ../../interactions/particles/links/dist/esm/plugin.js
15735
15746