@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.
- package/152.min.js +1 -0
- package/browser/Core/Container.js +1 -4
- package/browser/Core/Engine.js +1 -1
- package/browser/Core/Particle.js +1 -2
- package/browser/Core/Particles.js +8 -14
- package/browser/Core/Utils/Constants.js +1 -1
- package/browser/Core/Utils/Ranges.js +1 -1
- package/browser/Core/Utils/SpatialHashGrid.js +82 -0
- package/browser/Core/Utils/Vectors.js +3 -10
- package/browser/Utils/CanvasUtils.js +2 -13
- package/browser/Utils/ColorUtils.js +9 -1
- package/browser/Utils/MathUtils.js +4 -6
- package/browser/exports.js +0 -1
- package/cjs/Core/Container.js +1 -4
- package/cjs/Core/Engine.js +1 -1
- package/cjs/Core/Particle.js +1 -2
- package/cjs/Core/Particles.js +8 -14
- package/cjs/Core/Utils/Constants.js +1 -1
- package/cjs/Core/Utils/Ranges.js +1 -1
- package/cjs/Core/Utils/SpatialHashGrid.js +82 -0
- package/cjs/Core/Utils/Vectors.js +3 -10
- package/cjs/Utils/CanvasUtils.js +2 -13
- package/cjs/Utils/ColorUtils.js +9 -1
- package/cjs/Utils/MathUtils.js +4 -6
- package/cjs/exports.js +0 -1
- package/dist_browser_Core_Container_js.js +9 -9
- package/esm/Core/Container.js +1 -4
- package/esm/Core/Engine.js +1 -1
- package/esm/Core/Particle.js +1 -2
- package/esm/Core/Particles.js +8 -14
- package/esm/Core/Utils/Constants.js +1 -1
- package/esm/Core/Utils/Ranges.js +1 -1
- package/esm/Core/Utils/SpatialHashGrid.js +82 -0
- package/esm/Core/Utils/Vectors.js +3 -10
- package/esm/Utils/CanvasUtils.js +2 -13
- package/esm/Utils/ColorUtils.js +9 -1
- package/esm/Utils/MathUtils.js +4 -6
- package/esm/exports.js +0 -1
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +10 -20
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/Particles.d.ts +2 -2
- package/types/Core/Utils/Constants.d.ts +1 -1
- package/types/Core/Utils/SpatialHashGrid.d.ts +18 -0
- package/types/Core/Utils/Vectors.d.ts +2 -4
- package/types/Utils/CanvasUtils.d.ts +0 -3
- package/types/Utils/ColorUtils.d.ts +2 -0
- package/types/export-types.d.ts +1 -1
- package/types/exports.d.ts +0 -1
- package/umd/Core/Container.js +1 -4
- package/umd/Core/Engine.js +1 -1
- package/umd/Core/Particle.js +3 -4
- package/umd/Core/Particles.js +8 -14
- package/umd/Core/Utils/Constants.js +2 -2
- package/umd/Core/Utils/Ranges.js +1 -1
- package/umd/Core/Utils/SpatialHashGrid.js +96 -0
- package/umd/Core/Utils/Vectors.js +3 -10
- package/umd/Utils/CanvasUtils.js +2 -14
- package/umd/Utils/ColorUtils.js +10 -1
- package/umd/Utils/MathUtils.js +4 -6
- package/umd/exports.js +1 -2
- package/515.min.js +0 -1
- package/browser/Core/Utils/Point.js +0 -8
- package/browser/Core/Utils/QuadTree.js +0 -64
- package/cjs/Core/Utils/Point.js +0 -8
- package/cjs/Core/Utils/QuadTree.js +0 -64
- package/esm/Core/Utils/Point.js +0 -8
- package/esm/Core/Utils/QuadTree.js +0 -64
- package/types/Core/Utils/Point.d.ts +0 -7
- package/types/Core/Utils/QuadTree.d.ts +0 -18
- package/umd/Core/Utils/Point.js +0 -22
- 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
|
-
});
|