@tsparticles/plugin-poisson-disc 4.0.5 → 4.1.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/browser/PoissonDisc.js +4 -4
- package/browser/PoissonDiscPluginInstance.js +16 -15
- package/browser/index.js +1 -1
- package/browser/index.lazy.js +1 -1
- package/cjs/PoissonDisc.js +4 -4
- package/cjs/PoissonDiscPluginInstance.js +16 -15
- package/cjs/index.js +1 -1
- package/cjs/index.lazy.js +1 -1
- package/esm/PoissonDisc.js +4 -4
- package/esm/PoissonDiscPluginInstance.js +16 -15
- package/esm/index.js +1 -1
- package/esm/index.lazy.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.plugin.poisson.js +22 -21
- package/tsparticles.plugin.poisson.min.js +1 -1
- package/types/PoissonDisc.d.ts +1 -2
- package/types/PoissonDiscPluginInstance.d.ts +1 -3
package/browser/PoissonDisc.js
CHANGED
|
@@ -88,10 +88,10 @@ export class PoissonDisc {
|
|
|
88
88
|
if (this.active.length <= minCount) {
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
|
-
this
|
|
91
|
+
this.#step();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
#getNewPoint(currentPoint, tries) {
|
|
95
95
|
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * double), offset = {
|
|
96
96
|
x: Math.cos(newAngle) * newDist,
|
|
97
97
|
y: Math.sin(newAngle) * newDist,
|
|
@@ -149,7 +149,7 @@ export class PoissonDisc {
|
|
|
149
149
|
}
|
|
150
150
|
return newPoint;
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
#step() {
|
|
153
153
|
const minCount = 0, randomActive = this.getRandom(minCount, this.active.length);
|
|
154
154
|
let foundNewPoint = false;
|
|
155
155
|
for (let tries = 0; tries < this.retries; tries++) {
|
|
@@ -161,7 +161,7 @@ export class PoissonDisc {
|
|
|
161
161
|
if (!point) {
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
const newPoint = this
|
|
164
|
+
const newPoint = this.#getNewPoint(point, tries);
|
|
165
165
|
if (newPoint) {
|
|
166
166
|
foundNewPoint = true;
|
|
167
167
|
this.addPoint(newPoint);
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { getRangeMax } from "@tsparticles/engine";
|
|
2
|
+
const defaultSize = 1;
|
|
2
3
|
export class PoissonDiscPluginInstance {
|
|
3
4
|
poissonDisc;
|
|
4
5
|
redrawTimeout;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
#container;
|
|
7
|
+
#currentIndex;
|
|
7
8
|
constructor(container) {
|
|
8
|
-
this
|
|
9
|
-
this
|
|
9
|
+
this.#container = container;
|
|
10
|
+
this.#currentIndex = 0;
|
|
10
11
|
}
|
|
11
12
|
async init() {
|
|
12
|
-
await this
|
|
13
|
+
await this.#initData();
|
|
13
14
|
}
|
|
14
15
|
particlePosition(position) {
|
|
15
|
-
const container = this
|
|
16
|
-
if (!this.poissonDisc || !(options?.enable ?? false) || this
|
|
16
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
17
|
+
if (!this.poissonDisc || !(options?.enable ?? false) || this.#currentIndex >= this.poissonDisc.points.length) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
return position ?? this.poissonDisc.points[this
|
|
20
|
+
return position ?? this.poissonDisc.points[this.#currentIndex++]?.position;
|
|
20
21
|
}
|
|
21
22
|
resize() {
|
|
22
|
-
const container = this
|
|
23
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
23
24
|
if (!(options?.enable ?? false)) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -29,10 +30,10 @@ export class PoissonDiscPluginInstance {
|
|
|
29
30
|
const timeout = 250;
|
|
30
31
|
this.redrawTimeout = setTimeout(() => {
|
|
31
32
|
void (async () => {
|
|
32
|
-
if (this.
|
|
33
|
+
if (this.#container.destroyed) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
await this
|
|
36
|
+
await this.#initData();
|
|
36
37
|
await container.particles.redraw();
|
|
37
38
|
})();
|
|
38
39
|
}, timeout);
|
|
@@ -40,16 +41,16 @@ export class PoissonDiscPluginInstance {
|
|
|
40
41
|
stop() {
|
|
41
42
|
delete this.poissonDisc;
|
|
42
43
|
}
|
|
43
|
-
async
|
|
44
|
-
const container = this
|
|
44
|
+
async #initData() {
|
|
45
|
+
const container = this.#container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
|
|
45
46
|
if (!poissonOptions?.enable) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
this
|
|
49
|
+
this.#currentIndex = 0;
|
|
49
50
|
const { PoissonDisc } = await import("./PoissonDisc.js");
|
|
50
51
|
this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius
|
|
51
52
|
? poissonOptions.radius * pixelRatio
|
|
52
|
-
: Math.max(getRangeMax(particlesOptions
|
|
53
|
+
: Math.max(getRangeMax(particlesOptions["size.value"] ?? defaultSize) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
|
|
53
54
|
const noSteps = 0;
|
|
54
55
|
if (poissonOptions.steps > noSteps) {
|
|
55
56
|
this.poissonDisc.steps(poissonOptions.steps);
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoissonDiscPlugin } from "./PoissonDiscPlugin.js";
|
|
2
2
|
export async function loadPoissonDiscPlugin(engine) {
|
|
3
|
-
engine.checkVersion("4.
|
|
3
|
+
engine.checkVersion("4.1.1");
|
|
4
4
|
await engine.pluginManager.register(e => {
|
|
5
5
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
6
6
|
});
|
package/browser/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.1.1");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
5
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
package/cjs/PoissonDisc.js
CHANGED
|
@@ -88,10 +88,10 @@ export class PoissonDisc {
|
|
|
88
88
|
if (this.active.length <= minCount) {
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
|
-
this
|
|
91
|
+
this.#step();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
#getNewPoint(currentPoint, tries) {
|
|
95
95
|
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * double), offset = {
|
|
96
96
|
x: Math.cos(newAngle) * newDist,
|
|
97
97
|
y: Math.sin(newAngle) * newDist,
|
|
@@ -149,7 +149,7 @@ export class PoissonDisc {
|
|
|
149
149
|
}
|
|
150
150
|
return newPoint;
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
#step() {
|
|
153
153
|
const minCount = 0, randomActive = this.getRandom(minCount, this.active.length);
|
|
154
154
|
let foundNewPoint = false;
|
|
155
155
|
for (let tries = 0; tries < this.retries; tries++) {
|
|
@@ -161,7 +161,7 @@ export class PoissonDisc {
|
|
|
161
161
|
if (!point) {
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
const newPoint = this
|
|
164
|
+
const newPoint = this.#getNewPoint(point, tries);
|
|
165
165
|
if (newPoint) {
|
|
166
166
|
foundNewPoint = true;
|
|
167
167
|
this.addPoint(newPoint);
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { getRangeMax } from "@tsparticles/engine";
|
|
2
|
+
const defaultSize = 1;
|
|
2
3
|
export class PoissonDiscPluginInstance {
|
|
3
4
|
poissonDisc;
|
|
4
5
|
redrawTimeout;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
#container;
|
|
7
|
+
#currentIndex;
|
|
7
8
|
constructor(container) {
|
|
8
|
-
this
|
|
9
|
-
this
|
|
9
|
+
this.#container = container;
|
|
10
|
+
this.#currentIndex = 0;
|
|
10
11
|
}
|
|
11
12
|
async init() {
|
|
12
|
-
await this
|
|
13
|
+
await this.#initData();
|
|
13
14
|
}
|
|
14
15
|
particlePosition(position) {
|
|
15
|
-
const container = this
|
|
16
|
-
if (!this.poissonDisc || !(options?.enable ?? false) || this
|
|
16
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
17
|
+
if (!this.poissonDisc || !(options?.enable ?? false) || this.#currentIndex >= this.poissonDisc.points.length) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
return position ?? this.poissonDisc.points[this
|
|
20
|
+
return position ?? this.poissonDisc.points[this.#currentIndex++]?.position;
|
|
20
21
|
}
|
|
21
22
|
resize() {
|
|
22
|
-
const container = this
|
|
23
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
23
24
|
if (!(options?.enable ?? false)) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -29,10 +30,10 @@ export class PoissonDiscPluginInstance {
|
|
|
29
30
|
const timeout = 250;
|
|
30
31
|
this.redrawTimeout = setTimeout(() => {
|
|
31
32
|
void (async () => {
|
|
32
|
-
if (this.
|
|
33
|
+
if (this.#container.destroyed) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
await this
|
|
36
|
+
await this.#initData();
|
|
36
37
|
await container.particles.redraw();
|
|
37
38
|
})();
|
|
38
39
|
}, timeout);
|
|
@@ -40,16 +41,16 @@ export class PoissonDiscPluginInstance {
|
|
|
40
41
|
stop() {
|
|
41
42
|
delete this.poissonDisc;
|
|
42
43
|
}
|
|
43
|
-
async
|
|
44
|
-
const container = this
|
|
44
|
+
async #initData() {
|
|
45
|
+
const container = this.#container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
|
|
45
46
|
if (!poissonOptions?.enable) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
this
|
|
49
|
+
this.#currentIndex = 0;
|
|
49
50
|
const { PoissonDisc } = await import("./PoissonDisc.js");
|
|
50
51
|
this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius
|
|
51
52
|
? poissonOptions.radius * pixelRatio
|
|
52
|
-
: Math.max(getRangeMax(particlesOptions
|
|
53
|
+
: Math.max(getRangeMax(particlesOptions["size.value"] ?? defaultSize) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
|
|
53
54
|
const noSteps = 0;
|
|
54
55
|
if (poissonOptions.steps > noSteps) {
|
|
55
56
|
this.poissonDisc.steps(poissonOptions.steps);
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoissonDiscPlugin } from "./PoissonDiscPlugin.js";
|
|
2
2
|
export async function loadPoissonDiscPlugin(engine) {
|
|
3
|
-
engine.checkVersion("4.
|
|
3
|
+
engine.checkVersion("4.1.1");
|
|
4
4
|
await engine.pluginManager.register(e => {
|
|
5
5
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
6
6
|
});
|
package/cjs/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.1.1");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
5
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
package/esm/PoissonDisc.js
CHANGED
|
@@ -88,10 +88,10 @@ export class PoissonDisc {
|
|
|
88
88
|
if (this.active.length <= minCount) {
|
|
89
89
|
continue;
|
|
90
90
|
}
|
|
91
|
-
this
|
|
91
|
+
this.#step();
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
|
|
94
|
+
#getNewPoint(currentPoint, tries) {
|
|
95
95
|
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * double), offset = {
|
|
96
96
|
x: Math.cos(newAngle) * newDist,
|
|
97
97
|
y: Math.sin(newAngle) * newDist,
|
|
@@ -149,7 +149,7 @@ export class PoissonDisc {
|
|
|
149
149
|
}
|
|
150
150
|
return newPoint;
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
#step() {
|
|
153
153
|
const minCount = 0, randomActive = this.getRandom(minCount, this.active.length);
|
|
154
154
|
let foundNewPoint = false;
|
|
155
155
|
for (let tries = 0; tries < this.retries; tries++) {
|
|
@@ -161,7 +161,7 @@ export class PoissonDisc {
|
|
|
161
161
|
if (!point) {
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
164
|
-
const newPoint = this
|
|
164
|
+
const newPoint = this.#getNewPoint(point, tries);
|
|
165
165
|
if (newPoint) {
|
|
166
166
|
foundNewPoint = true;
|
|
167
167
|
this.addPoint(newPoint);
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import { getRangeMax } from "@tsparticles/engine";
|
|
2
|
+
const defaultSize = 1;
|
|
2
3
|
export class PoissonDiscPluginInstance {
|
|
3
4
|
poissonDisc;
|
|
4
5
|
redrawTimeout;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
#container;
|
|
7
|
+
#currentIndex;
|
|
7
8
|
constructor(container) {
|
|
8
|
-
this
|
|
9
|
-
this
|
|
9
|
+
this.#container = container;
|
|
10
|
+
this.#currentIndex = 0;
|
|
10
11
|
}
|
|
11
12
|
async init() {
|
|
12
|
-
await this
|
|
13
|
+
await this.#initData();
|
|
13
14
|
}
|
|
14
15
|
particlePosition(position) {
|
|
15
|
-
const container = this
|
|
16
|
-
if (!this.poissonDisc || !(options?.enable ?? false) || this
|
|
16
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
17
|
+
if (!this.poissonDisc || !(options?.enable ?? false) || this.#currentIndex >= this.poissonDisc.points.length) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
return position ?? this.poissonDisc.points[this
|
|
20
|
+
return position ?? this.poissonDisc.points[this.#currentIndex++]?.position;
|
|
20
21
|
}
|
|
21
22
|
resize() {
|
|
22
|
-
const container = this
|
|
23
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
23
24
|
if (!(options?.enable ?? false)) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -29,10 +30,10 @@ export class PoissonDiscPluginInstance {
|
|
|
29
30
|
const timeout = 250;
|
|
30
31
|
this.redrawTimeout = setTimeout(() => {
|
|
31
32
|
void (async () => {
|
|
32
|
-
if (this.
|
|
33
|
+
if (this.#container.destroyed) {
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
await this
|
|
36
|
+
await this.#initData();
|
|
36
37
|
await container.particles.redraw();
|
|
37
38
|
})();
|
|
38
39
|
}, timeout);
|
|
@@ -40,16 +41,16 @@ export class PoissonDiscPluginInstance {
|
|
|
40
41
|
stop() {
|
|
41
42
|
delete this.poissonDisc;
|
|
42
43
|
}
|
|
43
|
-
async
|
|
44
|
-
const container = this
|
|
44
|
+
async #initData() {
|
|
45
|
+
const container = this.#container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
|
|
45
46
|
if (!poissonOptions?.enable) {
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
|
-
this
|
|
49
|
+
this.#currentIndex = 0;
|
|
49
50
|
const { PoissonDisc } = await import("./PoissonDisc.js");
|
|
50
51
|
this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius
|
|
51
52
|
? poissonOptions.radius * pixelRatio
|
|
52
|
-
: Math.max(getRangeMax(particlesOptions
|
|
53
|
+
: Math.max(getRangeMax(particlesOptions["size.value"] ?? defaultSize) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
|
|
53
54
|
const noSteps = 0;
|
|
54
55
|
if (poissonOptions.steps > noSteps) {
|
|
55
56
|
this.poissonDisc.steps(poissonOptions.steps);
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoissonDiscPlugin } from "./PoissonDiscPlugin.js";
|
|
2
2
|
export async function loadPoissonDiscPlugin(engine) {
|
|
3
|
-
engine.checkVersion("4.
|
|
3
|
+
engine.checkVersion("4.1.1");
|
|
4
4
|
await engine.pluginManager.register(e => {
|
|
5
5
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
6
6
|
});
|
package/esm/index.lazy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export async function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.
|
|
2
|
+
engine.checkVersion("4.1.1");
|
|
3
3
|
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
5
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-poisson-disc",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "tsParticles poisson disc plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"./package.json": "./package.json"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"@tsparticles/engine": "4.
|
|
94
|
+
"@tsparticles/engine": "4.1.1"
|
|
95
95
|
},
|
|
96
96
|
"publishConfig": {
|
|
97
97
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -4930,7 +4930,7 @@ var drawChart = (function (exports) {
|
|
|
4930
4930
|
</script>
|
|
4931
4931
|
<script>
|
|
4932
4932
|
/*<!--*/
|
|
4933
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.plugin.poisson.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes/Poisson.js","uid":"
|
|
4933
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tsparticles.plugin.poisson.js","children":[{"name":"dist/browser","children":[{"name":"Options/Classes/Poisson.js","uid":"83bf6a65-1"},{"uid":"83bf6a65-3","name":"PoissonDiscPlugin.js"},{"uid":"83bf6a65-5","name":"index.js"},{"uid":"83bf6a65-7","name":"browser.js"},{"uid":"83bf6a65-9","name":"PoissonDiscPluginInstance.js"},{"uid":"83bf6a65-11","name":"PoissonDisc.js"}]}]}],"isRoot":true},"nodeParts":{"83bf6a65-1":{"renderedLength":828,"gzipLength":0,"brotliLength":0,"metaUid":"83bf6a65-0"},"83bf6a65-3":{"renderedLength":803,"gzipLength":0,"brotliLength":0,"metaUid":"83bf6a65-2"},"83bf6a65-5":{"renderedLength":221,"gzipLength":0,"brotliLength":0,"metaUid":"83bf6a65-4"},"83bf6a65-7":{"renderedLength":185,"gzipLength":0,"brotliLength":0,"metaUid":"83bf6a65-6"},"83bf6a65-9":{"renderedLength":2580,"gzipLength":0,"brotliLength":0,"metaUid":"83bf6a65-8"},"83bf6a65-11":{"renderedLength":6574,"gzipLength":0,"brotliLength":0,"metaUid":"83bf6a65-10"}},"nodeMetas":{"83bf6a65-0":{"id":"/dist/browser/Options/Classes/Poisson.js","moduleParts":{"tsparticles.plugin.poisson.js":"83bf6a65-1"},"imported":[{"uid":"83bf6a65-12"}],"importedBy":[{"uid":"83bf6a65-2"}]},"83bf6a65-2":{"id":"/dist/browser/PoissonDiscPlugin.js","moduleParts":{"tsparticles.plugin.poisson.js":"83bf6a65-3"},"imported":[{"uid":"83bf6a65-0"},{"uid":"83bf6a65-8","dynamic":true}],"importedBy":[{"uid":"83bf6a65-4"}]},"83bf6a65-4":{"id":"/dist/browser/index.js","moduleParts":{"tsparticles.plugin.poisson.js":"83bf6a65-5"},"imported":[{"uid":"83bf6a65-2"}],"importedBy":[{"uid":"83bf6a65-6"}]},"83bf6a65-6":{"id":"/dist/browser/browser.js","moduleParts":{"tsparticles.plugin.poisson.js":"83bf6a65-7"},"imported":[{"uid":"83bf6a65-4"}],"importedBy":[],"isEntry":true},"83bf6a65-8":{"id":"/dist/browser/PoissonDiscPluginInstance.js","moduleParts":{"tsparticles.plugin.poisson.js":"83bf6a65-9"},"imported":[{"uid":"83bf6a65-12"},{"uid":"83bf6a65-10","dynamic":true}],"importedBy":[{"uid":"83bf6a65-2"}]},"83bf6a65-10":{"id":"/dist/browser/PoissonDisc.js","moduleParts":{"tsparticles.plugin.poisson.js":"83bf6a65-11"},"imported":[{"uid":"83bf6a65-12"}],"importedBy":[{"uid":"83bf6a65-8"}]},"83bf6a65-12":{"id":"@tsparticles/engine","moduleParts":{},"imported":[],"importedBy":[{"uid":"83bf6a65-0"},{"uid":"83bf6a65-8"},{"uid":"83bf6a65-10"}],"isExternal":true}},"env":{"rollup":"4.60.4"},"options":{"gzip":false,"brotli":false,"sourcemap":false}};
|
|
4934
4934
|
|
|
4935
4935
|
const run = () => {
|
|
4936
4936
|
const width = window.innerWidth;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
|
|
2
|
-
/* Plugin v4.
|
|
2
|
+
/* Plugin v4.1.1 */
|
|
3
3
|
(function (global, factory) {
|
|
4
4
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
|
|
5
5
|
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
async function loadPoissonDiscPlugin(engine) {
|
|
63
|
-
engine.checkVersion("4.
|
|
63
|
+
engine.checkVersion("4.1.1");
|
|
64
64
|
await engine.pluginManager.register(e => {
|
|
65
65
|
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
66
66
|
});
|
|
@@ -70,27 +70,28 @@
|
|
|
70
70
|
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
71
71
|
globalObject.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
|
|
72
72
|
|
|
73
|
+
const defaultSize = 1;
|
|
73
74
|
class PoissonDiscPluginInstance {
|
|
74
75
|
poissonDisc;
|
|
75
76
|
redrawTimeout;
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
#container;
|
|
78
|
+
#currentIndex;
|
|
78
79
|
constructor(container) {
|
|
79
|
-
this
|
|
80
|
-
this
|
|
80
|
+
this.#container = container;
|
|
81
|
+
this.#currentIndex = 0;
|
|
81
82
|
}
|
|
82
83
|
async init() {
|
|
83
|
-
await this
|
|
84
|
+
await this.#initData();
|
|
84
85
|
}
|
|
85
86
|
particlePosition(position) {
|
|
86
|
-
const container = this
|
|
87
|
-
if (!this.poissonDisc || !(options?.enable ?? false) || this
|
|
87
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
88
|
+
if (!this.poissonDisc || !(options?.enable ?? false) || this.#currentIndex >= this.poissonDisc.points.length) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
return position ?? this.poissonDisc.points[this
|
|
91
|
+
return position ?? this.poissonDisc.points[this.#currentIndex++]?.position;
|
|
91
92
|
}
|
|
92
93
|
resize() {
|
|
93
|
-
const container = this
|
|
94
|
+
const container = this.#container, options = container.actualOptions.poisson;
|
|
94
95
|
if (!(options?.enable ?? false)) {
|
|
95
96
|
return;
|
|
96
97
|
}
|
|
@@ -100,10 +101,10 @@
|
|
|
100
101
|
const timeout = 250;
|
|
101
102
|
this.redrawTimeout = setTimeout(() => {
|
|
102
103
|
void (async () => {
|
|
103
|
-
if (this.
|
|
104
|
+
if (this.#container.destroyed) {
|
|
104
105
|
return;
|
|
105
106
|
}
|
|
106
|
-
await this
|
|
107
|
+
await this.#initData();
|
|
107
108
|
await container.particles.redraw();
|
|
108
109
|
})();
|
|
109
110
|
}, timeout);
|
|
@@ -111,16 +112,16 @@
|
|
|
111
112
|
stop() {
|
|
112
113
|
delete this.poissonDisc;
|
|
113
114
|
}
|
|
114
|
-
async
|
|
115
|
-
const container = this
|
|
115
|
+
async #initData() {
|
|
116
|
+
const container = this.#container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
|
|
116
117
|
if (!poissonOptions?.enable) {
|
|
117
118
|
return;
|
|
118
119
|
}
|
|
119
|
-
this
|
|
120
|
+
this.#currentIndex = 0;
|
|
120
121
|
const { PoissonDisc } = await Promise.resolve().then(function () { return PoissonDisc$1; });
|
|
121
122
|
this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius
|
|
122
123
|
? poissonOptions.radius * pixelRatio
|
|
123
|
-
: Math.max(engine.getRangeMax(particlesOptions
|
|
124
|
+
: Math.max(engine.getRangeMax(particlesOptions["size.value"] ?? defaultSize) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
|
|
124
125
|
const noSteps = 0;
|
|
125
126
|
if (poissonOptions.steps > noSteps) {
|
|
126
127
|
this.poissonDisc.steps(poissonOptions.steps);
|
|
@@ -225,10 +226,10 @@
|
|
|
225
226
|
if (this.active.length <= minCount) {
|
|
226
227
|
continue;
|
|
227
228
|
}
|
|
228
|
-
this
|
|
229
|
+
this.#step();
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
|
-
|
|
232
|
+
#getNewPoint(currentPoint, tries) {
|
|
232
233
|
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (engine.doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * engine.double), offset = {
|
|
233
234
|
x: Math.cos(newAngle) * newDist,
|
|
234
235
|
y: Math.sin(newAngle) * newDist,
|
|
@@ -286,7 +287,7 @@
|
|
|
286
287
|
}
|
|
287
288
|
return newPoint;
|
|
288
289
|
}
|
|
289
|
-
|
|
290
|
+
#step() {
|
|
290
291
|
const minCount = 0, randomActive = this.getRandom(minCount, this.active.length);
|
|
291
292
|
let foundNewPoint = false;
|
|
292
293
|
for (let tries = 0; tries < this.retries; tries++) {
|
|
@@ -298,7 +299,7 @@
|
|
|
298
299
|
if (!point) {
|
|
299
300
|
continue;
|
|
300
301
|
}
|
|
301
|
-
const newPoint = this
|
|
302
|
+
const newPoint = this.#getNewPoint(point, tries);
|
|
302
303
|
if (newPoint) {
|
|
303
304
|
foundNewPoint = true;
|
|
304
305
|
this.addPoint(newPoint);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(s){s.__tsParticlesInternals=s.__tsParticlesInternals||{},s.__tsParticlesInternals.bundles=s.__tsParticlesInternals.bundles||{},s.__tsParticlesInternals.effects=s.__tsParticlesInternals.effects||{},s.__tsParticlesInternals.engine=s.__tsParticlesInternals.engine||{},s.__tsParticlesInternals.interactions=s.__tsParticlesInternals.interactions||{},s.__tsParticlesInternals.palettes=s.__tsParticlesInternals.palettes||{},s.__tsParticlesInternals.paths=s.__tsParticlesInternals.paths||{},s.__tsParticlesInternals.plugins=s.__tsParticlesInternals.plugins||{},s.__tsParticlesInternals.plugins=s.__tsParticlesInternals.plugins||{},s.__tsParticlesInternals.plugins.emittersShapes=s.__tsParticlesInternals.plugins.emittersShapes||{},s.__tsParticlesInternals.presets=s.__tsParticlesInternals.presets||{},s.__tsParticlesInternals.shapes=s.__tsParticlesInternals.shapes||{},s.__tsParticlesInternals.updaters=s.__tsParticlesInternals.updaters||{},s.__tsParticlesInternals.utils=s.__tsParticlesInternals.utils||{},s.__tsParticlesInternals.canvas=s.__tsParticlesInternals.canvas||{},s.__tsParticlesInternals.canvas=s.__tsParticlesInternals.canvas||{},s.__tsParticlesInternals.canvas.utils=s.__tsParticlesInternals.canvas.utils||{},s.__tsParticlesInternals.path=s.__tsParticlesInternals.path||{},s.__tsParticlesInternals.path=s.__tsParticlesInternals.path||{},s.__tsParticlesInternals.path.utils=s.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(s){return new Proxy(s,{get:function(s,t){return t in s||(s[t]={}),s[t]}})}:function(s){return s};s.__tsParticlesInternals.bundles=t(s.__tsParticlesInternals.bundles),s.__tsParticlesInternals.effects=t(s.__tsParticlesInternals.effects),s.__tsParticlesInternals.interactions=t(s.__tsParticlesInternals.interactions),s.__tsParticlesInternals.palettes=t(s.__tsParticlesInternals.palettes),s.__tsParticlesInternals.paths=t(s.__tsParticlesInternals.paths),s.__tsParticlesInternals.plugins=t(s.__tsParticlesInternals.plugins),s.__tsParticlesInternals.plugins.emittersShapes=t(s.__tsParticlesInternals.plugins.emittersShapes),s.__tsParticlesInternals.presets=t(s.__tsParticlesInternals.presets),s.__tsParticlesInternals.shapes=t(s.__tsParticlesInternals.shapes),s.__tsParticlesInternals.updaters=t(s.__tsParticlesInternals.updaters),s.__tsParticlesInternals.utils=t(s.__tsParticlesInternals.utils),s.__tsParticlesInternals.canvas=t(s.__tsParticlesInternals.canvas),s.__tsParticlesInternals.path=t(s.__tsParticlesInternals.path),s.tsparticlesInternalExports=s.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(s,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],t):t(((s="undefined"!=typeof globalThis?globalThis:s||self).__tsParticlesInternals=s.__tsParticlesInternals||{},s.__tsParticlesInternals.plugins=s.__tsParticlesInternals.plugins||{},s.__tsParticlesInternals.plugins.poisson=s.__tsParticlesInternals.plugins.poisson||{}),s.__tsParticlesInternals.engine)}(this,function(s,t){"use strict";class i{dimensions;enable;radius;retries;steps;constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(s){t.isNull(s)||(void 0!==s.enable&&(this.enable=s.enable),void 0!==s.dimensions&&(this.dimensions=s.dimensions),void 0!==s.radius&&(this.radius=s.radius),void 0!==s.retries&&(this.retries=s.retries))}}class e{id="poisson";async getPlugin(s){const{PoissonDiscPluginInstance:t}=await Promise.resolve().then(function(){return r});return new t(s)}loadOptions(s,t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let n=t.poisson;void 0===n?.load&&(t.poisson=n=new i),n.load(e?.poisson)}needsPlugin(s){return s?.poisson?.enable??!1}}async function n(s){s.checkVersion("4.
|
|
1
|
+
!function(s){s.__tsParticlesInternals=s.__tsParticlesInternals||{},s.__tsParticlesInternals.bundles=s.__tsParticlesInternals.bundles||{},s.__tsParticlesInternals.effects=s.__tsParticlesInternals.effects||{},s.__tsParticlesInternals.engine=s.__tsParticlesInternals.engine||{},s.__tsParticlesInternals.interactions=s.__tsParticlesInternals.interactions||{},s.__tsParticlesInternals.palettes=s.__tsParticlesInternals.palettes||{},s.__tsParticlesInternals.paths=s.__tsParticlesInternals.paths||{},s.__tsParticlesInternals.plugins=s.__tsParticlesInternals.plugins||{},s.__tsParticlesInternals.plugins=s.__tsParticlesInternals.plugins||{},s.__tsParticlesInternals.plugins.emittersShapes=s.__tsParticlesInternals.plugins.emittersShapes||{},s.__tsParticlesInternals.presets=s.__tsParticlesInternals.presets||{},s.__tsParticlesInternals.shapes=s.__tsParticlesInternals.shapes||{},s.__tsParticlesInternals.updaters=s.__tsParticlesInternals.updaters||{},s.__tsParticlesInternals.utils=s.__tsParticlesInternals.utils||{},s.__tsParticlesInternals.canvas=s.__tsParticlesInternals.canvas||{},s.__tsParticlesInternals.canvas=s.__tsParticlesInternals.canvas||{},s.__tsParticlesInternals.canvas.utils=s.__tsParticlesInternals.canvas.utils||{},s.__tsParticlesInternals.path=s.__tsParticlesInternals.path||{},s.__tsParticlesInternals.path=s.__tsParticlesInternals.path||{},s.__tsParticlesInternals.path.utils=s.__tsParticlesInternals.path.utils||{};var t="undefined"!=typeof Proxy?function(s){return new Proxy(s,{get:function(s,t){return t in s||(s[t]={}),s[t]}})}:function(s){return s};s.__tsParticlesInternals.bundles=t(s.__tsParticlesInternals.bundles),s.__tsParticlesInternals.effects=t(s.__tsParticlesInternals.effects),s.__tsParticlesInternals.interactions=t(s.__tsParticlesInternals.interactions),s.__tsParticlesInternals.palettes=t(s.__tsParticlesInternals.palettes),s.__tsParticlesInternals.paths=t(s.__tsParticlesInternals.paths),s.__tsParticlesInternals.plugins=t(s.__tsParticlesInternals.plugins),s.__tsParticlesInternals.plugins.emittersShapes=t(s.__tsParticlesInternals.plugins.emittersShapes),s.__tsParticlesInternals.presets=t(s.__tsParticlesInternals.presets),s.__tsParticlesInternals.shapes=t(s.__tsParticlesInternals.shapes),s.__tsParticlesInternals.updaters=t(s.__tsParticlesInternals.updaters),s.__tsParticlesInternals.utils=t(s.__tsParticlesInternals.utils),s.__tsParticlesInternals.canvas=t(s.__tsParticlesInternals.canvas),s.__tsParticlesInternals.path=t(s.__tsParticlesInternals.path),s.tsparticlesInternalExports=s.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(s,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],t):t(((s="undefined"!=typeof globalThis?globalThis:s||self).__tsParticlesInternals=s.__tsParticlesInternals||{},s.__tsParticlesInternals.plugins=s.__tsParticlesInternals.plugins||{},s.__tsParticlesInternals.plugins.poisson=s.__tsParticlesInternals.plugins.poisson||{}),s.__tsParticlesInternals.engine)}(this,function(s,t){"use strict";class i{dimensions;enable;radius;retries;steps;constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(s){t.isNull(s)||(void 0!==s.enable&&(this.enable=s.enable),void 0!==s.dimensions&&(this.dimensions=s.dimensions),void 0!==s.radius&&(this.radius=s.radius),void 0!==s.retries&&(this.retries=s.retries))}}class e{id="poisson";async getPlugin(s){const{PoissonDiscPluginInstance:t}=await Promise.resolve().then(function(){return r});return new t(s)}loadOptions(s,t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let n=t.poisson;void 0===n?.load&&(t.poisson=n=new i),n.load(e?.poisson)}needsPlugin(s){return s?.poisson?.enable??!1}}async function n(s){s.checkVersion("4.1.1"),await s.pluginManager.register(s=>{s.pluginManager.addPlugin(new e)})}const a=globalThis;a.__tsParticlesInternals=a.__tsParticlesInternals??{},a.loadPoissonDiscPlugin=n;var r=Object.freeze({__proto__:null,PoissonDiscPluginInstance:class{poissonDisc;redrawTimeout;#s;#t;constructor(s){this.#s=s,this.#t=0}async init(){await this.#i()}particlePosition(s){const t=this.#s.actualOptions.poisson;if(this.poissonDisc&&t?.enable&&!(this.#t>=this.poissonDisc.points.length))return s??this.poissonDisc.points[this.#t++]?.position}resize(){const s=this.#s,t=s.actualOptions.poisson;if(!t?.enable)return;this.redrawTimeout&&clearTimeout(this.redrawTimeout);this.redrawTimeout=setTimeout(()=>{(async()=>{this.#s.destroyed||(await this.#i(),await s.particles.redraw())})()},250)}stop(){delete this.poissonDisc}async#i(){const s=this.#s,i=s.actualOptions.poisson,e=s.actualOptions.particles,n=s.canvas.size,a=s.retina.pixelRatio;if(!i?.enable)return;this.#t=0;const{PoissonDisc:r}=await Promise.resolve().then(function(){return l});this.poissonDisc=new r(n,i.radius?i.radius*a:Math.max(t.getRangeMax(e["size.value"]??1)*a,Math.sqrt(n.width*n.height/e.number.value)),i.retries,i.dimensions);i.steps>0?this.poissonDisc.steps(i.steps):await this.poissonDisc.run()}}});var l=Object.freeze({__proto__:null,PoissonDisc:class{active;cellSize;cols;dimensions;firstPoint;grid;points;radius;retries;rows;size;constructor(s,t,i,e,n){this.size={...s},this.radius=t,this.retries=i,this.dimensions=e,this.cellSize=Math.floor(this.radius/Math.sqrt(this.dimensions)),this.cols=Math.floor(this.size.width/this.cellSize),this.rows=Math.floor(this.size.height/this.cellSize),this.points=[],this.active=[],this.grid=[],this.firstPoint=n?{...n}:void 0,this.reset()}addPoint(s){const t={position:{...s},gridPosition:{x:Math.floor(s.x/this.cellSize),y:Math.floor(s.y/this.cellSize)}},i=this.points.length,e=this.grid[t.gridPosition.y];e&&(this.points.push(t),e[t.gridPosition.x]=i,this.active.push(i))}getRandom(s,i){return Math.floor(t.getRandom()*(i-s))+s}initialiseGrid(){for(let s=0;s<=this.rows;s++){this.grid[s]=[];const t=this.grid[s];if(t)for(let s=0;s<=this.cols;s++)t[s]=-1}}reset(){if(this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint)this.addPoint(this.firstPoint);else{const s=0;this.addPoint({x:this.getRandom(s,this.size.width),y:this.getRandom(s,this.size.height)})}}async run(){this.reset();let s=0;for(;this.active.length>0;)this.steps(1),++s%100==0&&await new Promise(s=>setTimeout(s))}steps(s){for(let t=0;t<s;t++)this.active.length<=0||this.#e()}#n(s,i){const e=i*(t.doublePI/this.retries),n=this.getRandom(this.radius,this.radius*t.double),a=Math.cos(e)*n,r=Math.sin(e)*n,l={x:Math.floor(s.position.x+a),y:Math.floor(s.position.y+r)},o=Math.floor(l.x/this.cellSize),c=Math.floor(l.y/this.cellSize);if(l.x<=0||l.x>=this.size.width||l.y<=0||l.y>=this.size.height)return;const h=this.grid[c];if(!h)return;const _=h[o];if(void 0!==_&&!(_>=0)){for(let s=-1;s<=1;s++)for(let i=-1;i<=1;i++){if(!s&&!i)continue;const e={x:o+i,y:c+s};if(e.x<0||e.y<0||e.x>=this.cols||e.y>=this.rows)continue;const n=this.grid[e.y]?.[e.x];if(void 0===n||n<0)continue;const a=this.points[n];if(a&&t.getDistance(l,a.position)<this.radius)return}return l}}#e(){const s=this.getRandom(0,this.active.length);let t=!1;for(let i=0;i<this.retries;i++){const e=this.active[s];if(void 0===e)continue;const n=this.points[e];if(!n)continue;const a=this.#n(n,i);if(a){t=!0,this.addPoint(a);break}}if(!t){const t=1;this.active.splice(s,t)}}}});s.loadPoissonDiscPlugin=n}),Object.assign(globalThis.window||globalThis,{loadPoissonDiscPlugin:(globalThis.__tsParticlesInternals.plugins.poisson||{}).loadPoissonDiscPlugin}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
|
package/types/PoissonDisc.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ICoordinates, type IDimension } from "@tsparticles/engine";
|
|
2
2
|
import type { IPoissonPoint } from "./Interfaces/IPoissonPoint.js";
|
|
3
3
|
export declare class PoissonDisc {
|
|
4
|
+
#private;
|
|
4
5
|
active: number[];
|
|
5
6
|
cellSize: number;
|
|
6
7
|
cols: number;
|
|
@@ -22,6 +23,4 @@ export declare class PoissonDisc {
|
|
|
22
23
|
reset(): void;
|
|
23
24
|
run(): Promise<void>;
|
|
24
25
|
steps(steps: number): void;
|
|
25
|
-
private _getNewPoint;
|
|
26
|
-
private _step;
|
|
27
26
|
}
|
|
@@ -2,14 +2,12 @@ import { type IContainerPlugin, type ICoordinates } from "@tsparticles/engine";
|
|
|
2
2
|
import type { PoissonContainer } from "./types.js";
|
|
3
3
|
import type { PoissonDisc } from "./PoissonDisc.js";
|
|
4
4
|
export declare class PoissonDiscPluginInstance implements IContainerPlugin {
|
|
5
|
+
#private;
|
|
5
6
|
poissonDisc?: PoissonDisc;
|
|
6
7
|
redrawTimeout?: number;
|
|
7
|
-
private readonly _container;
|
|
8
|
-
private _currentIndex;
|
|
9
8
|
constructor(container: PoissonContainer);
|
|
10
9
|
init(): Promise<void>;
|
|
11
10
|
particlePosition(position?: ICoordinates): ICoordinates | undefined;
|
|
12
11
|
resize(): void;
|
|
13
12
|
stop(): void;
|
|
14
|
-
private _initData;
|
|
15
13
|
}
|