@tsparticles/engine 4.0.0-alpha.23 → 4.0.0-alpha.25

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 (73) hide show
  1. package/152.min.js +1 -0
  2. package/browser/Core/Container.js +1 -4
  3. package/browser/Core/Engine.js +1 -1
  4. package/browser/Core/Particle.js +1 -2
  5. package/browser/Core/Particles.js +8 -14
  6. package/browser/Core/Utils/Constants.js +1 -1
  7. package/browser/Core/Utils/Ranges.js +1 -1
  8. package/browser/Core/Utils/SpatialHashGrid.js +82 -0
  9. package/browser/Core/Utils/Vectors.js +3 -10
  10. package/browser/Utils/CanvasUtils.js +2 -13
  11. package/browser/Utils/ColorUtils.js +9 -1
  12. package/browser/Utils/MathUtils.js +4 -6
  13. package/browser/exports.js +0 -1
  14. package/cjs/Core/Container.js +1 -4
  15. package/cjs/Core/Engine.js +1 -1
  16. package/cjs/Core/Particle.js +1 -2
  17. package/cjs/Core/Particles.js +8 -14
  18. package/cjs/Core/Utils/Constants.js +1 -1
  19. package/cjs/Core/Utils/Ranges.js +1 -1
  20. package/cjs/Core/Utils/SpatialHashGrid.js +82 -0
  21. package/cjs/Core/Utils/Vectors.js +3 -10
  22. package/cjs/Utils/CanvasUtils.js +2 -13
  23. package/cjs/Utils/ColorUtils.js +9 -1
  24. package/cjs/Utils/MathUtils.js +4 -6
  25. package/cjs/exports.js +0 -1
  26. package/dist_browser_Core_Container_js.js +9 -9
  27. package/esm/Core/Container.js +1 -4
  28. package/esm/Core/Engine.js +1 -1
  29. package/esm/Core/Particle.js +1 -2
  30. package/esm/Core/Particles.js +8 -14
  31. package/esm/Core/Utils/Constants.js +1 -1
  32. package/esm/Core/Utils/Ranges.js +1 -1
  33. package/esm/Core/Utils/SpatialHashGrid.js +82 -0
  34. package/esm/Core/Utils/Vectors.js +3 -10
  35. package/esm/Utils/CanvasUtils.js +2 -13
  36. package/esm/Utils/ColorUtils.js +9 -1
  37. package/esm/Utils/MathUtils.js +4 -6
  38. package/esm/exports.js +0 -1
  39. package/package.json +1 -1
  40. package/report.html +1 -1
  41. package/tsparticles.engine.js +10 -20
  42. package/tsparticles.engine.min.js +2 -2
  43. package/types/Core/Particles.d.ts +2 -2
  44. package/types/Core/Utils/Constants.d.ts +1 -1
  45. package/types/Core/Utils/SpatialHashGrid.d.ts +18 -0
  46. package/types/Core/Utils/Vectors.d.ts +2 -4
  47. package/types/Utils/CanvasUtils.d.ts +0 -3
  48. package/types/Utils/ColorUtils.d.ts +2 -0
  49. package/types/export-types.d.ts +1 -1
  50. package/types/exports.d.ts +0 -1
  51. package/umd/Core/Container.js +1 -4
  52. package/umd/Core/Engine.js +1 -1
  53. package/umd/Core/Particle.js +3 -4
  54. package/umd/Core/Particles.js +8 -14
  55. package/umd/Core/Utils/Constants.js +2 -2
  56. package/umd/Core/Utils/Ranges.js +1 -1
  57. package/umd/Core/Utils/SpatialHashGrid.js +96 -0
  58. package/umd/Core/Utils/Vectors.js +3 -10
  59. package/umd/Utils/CanvasUtils.js +2 -14
  60. package/umd/Utils/ColorUtils.js +10 -1
  61. package/umd/Utils/MathUtils.js +4 -6
  62. package/umd/exports.js +1 -2
  63. package/515.min.js +0 -1
  64. package/browser/Core/Utils/Point.js +0 -8
  65. package/browser/Core/Utils/QuadTree.js +0 -64
  66. package/cjs/Core/Utils/Point.js +0 -8
  67. package/cjs/Core/Utils/QuadTree.js +0 -64
  68. package/esm/Core/Utils/Point.js +0 -8
  69. package/esm/Core/Utils/QuadTree.js +0 -64
  70. package/types/Core/Utils/Point.d.ts +0 -7
  71. package/types/Core/Utils/QuadTree.d.ts +0 -18
  72. package/umd/Core/Utils/Point.js +0 -22
  73. package/umd/Core/Utils/QuadTree.js +0 -78
@@ -1,78 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Ranges.js", "./Constants.js", "../../Utils/MathUtils.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.QuadTree = void 0;
13
- const Ranges_js_1 = require("./Ranges.js");
14
- const Constants_js_1 = require("./Constants.js");
15
- const MathUtils_js_1 = require("../../Utils/MathUtils.js");
16
- class QuadTree {
17
- rectangle;
18
- capacity;
19
- _divided;
20
- _points;
21
- _subs;
22
- constructor(rectangle, capacity) {
23
- this.rectangle = rectangle;
24
- this.capacity = capacity;
25
- this._points = [];
26
- this._divided = false;
27
- this._subs = [];
28
- }
29
- insert(point) {
30
- if (!this.rectangle.contains(point.position)) {
31
- return false;
32
- }
33
- if (this._points.length < this.capacity) {
34
- this._points.push(point);
35
- return true;
36
- }
37
- if (!this._divided) {
38
- this._subdivide();
39
- }
40
- return this._subs.some(sub => sub.insert(point));
41
- }
42
- query(range, check) {
43
- const res = [];
44
- if (!range.intersects(this.rectangle)) {
45
- return [];
46
- }
47
- for (const p of this._points) {
48
- if (!range.contains(p.position) &&
49
- (0, MathUtils_js_1.getDistance)(range.position, p.position) > p.particle.getRadius() &&
50
- (!check || check(p.particle))) {
51
- continue;
52
- }
53
- res.push(p.particle);
54
- }
55
- if (this._divided) {
56
- for (const sub of this._subs) {
57
- res.push(...sub.query(range, check));
58
- }
59
- }
60
- return res;
61
- }
62
- queryCircle(position, radius, check) {
63
- return this.query(new Ranges_js_1.Circle(position.x, position.y, radius), check);
64
- }
65
- queryRectangle(position, size, check) {
66
- return this.query(new Ranges_js_1.Rectangle(position.x, position.y, size.width, size.height), check);
67
- }
68
- _subdivide = () => {
69
- const { x, y } = this.rectangle.position, { width, height } = this.rectangle.size, { capacity } = this;
70
- for (let i = 0; i < Constants_js_1.subdivideCount; i++) {
71
- const fixedIndex = i % Constants_js_1.double;
72
- this._subs.push(new QuadTree(new Ranges_js_1.Rectangle(x + width * Constants_js_1.half * fixedIndex, y + height * Constants_js_1.half * (Math.round(i * Constants_js_1.half) - fixedIndex), width * Constants_js_1.half, height * Constants_js_1.half), capacity));
73
- }
74
- this._divided = true;
75
- };
76
- }
77
- exports.QuadTree = QuadTree;
78
- });