@tsparticles/plugin-poisson-disc 4.0.0-beta.12 → 4.0.0-beta.15
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/browser.js +5 -0
- package/browser/index.js +3 -3
- package/browser/index.lazy.js +7 -0
- package/cjs/browser.js +5 -0
- package/cjs/index.js +3 -3
- package/cjs/index.lazy.js +7 -0
- package/esm/browser.js +5 -0
- package/esm/index.js +3 -3
- package/esm/index.lazy.js +7 -0
- package/package.json +9 -2
- package/report.html +4949 -94
- package/tsparticles.plugin.poisson.js +317 -310
- package/tsparticles.plugin.poisson.min.js +1 -2
- package/types/browser.d.ts +1 -0
- package/types/index.lazy.d.ts +2 -0
- package/41.min.js +0 -1
- package/87.min.js +0 -1
- package/945.min.js +0 -1
- package/dist_browser_PoissonDiscPluginInstance_js.js +0 -30
- package/dist_browser_PoissonDiscPlugin_js.js +0 -40
- package/dist_browser_PoissonDisc_js.js +0 -30
|
@@ -1,317 +1,324 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
/*
|
|
10
|
-
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
11
|
-
* This devtool is neither made for production nor for readable output files.
|
|
12
|
-
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
13
|
-
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
14
|
-
* or disable the default devtool with "devtool: false".
|
|
15
|
-
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
16
|
-
*/
|
|
17
|
-
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
|
-
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
-
module.exports = factory(require("@tsparticles/engine"));
|
|
20
|
-
else if(typeof define === 'function' && define.amd)
|
|
21
|
-
define(["@tsparticles/engine"], factory);
|
|
22
|
-
else {
|
|
23
|
-
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
24
|
-
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
-
}
|
|
26
|
-
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
27
|
-
return /******/ (() => { // webpackBootstrap
|
|
28
|
-
/******/ "use strict";
|
|
29
|
-
/******/ var __webpack_modules__ = ({
|
|
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.0.0-beta.15 */
|
|
3
|
+
(function (global, factory) {
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.plugins = global.__tsParticlesInternals.plugins || {}, global.__tsParticlesInternals.plugins.poisson = global.__tsParticlesInternals.plugins.poisson || {}), global.__tsParticlesInternals.engine));
|
|
7
|
+
})(this, (function (exports, engine) { 'use strict';
|
|
30
8
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
9
|
+
class Poisson {
|
|
10
|
+
dimensions;
|
|
11
|
+
enable;
|
|
12
|
+
radius;
|
|
13
|
+
retries;
|
|
14
|
+
steps;
|
|
15
|
+
constructor() {
|
|
16
|
+
this.enable = false;
|
|
17
|
+
this.dimensions = 2;
|
|
18
|
+
this.radius = 0;
|
|
19
|
+
this.retries = 30;
|
|
20
|
+
this.steps = 0;
|
|
21
|
+
}
|
|
22
|
+
load(data) {
|
|
23
|
+
if (engine.isNull(data)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (data.enable !== undefined) {
|
|
27
|
+
this.enable = data.enable;
|
|
28
|
+
}
|
|
29
|
+
if (data.dimensions !== undefined) {
|
|
30
|
+
this.dimensions = data.dimensions;
|
|
31
|
+
}
|
|
32
|
+
if (data.radius !== undefined) {
|
|
33
|
+
this.radius = data.radius;
|
|
34
|
+
}
|
|
35
|
+
if (data.retries !== undefined) {
|
|
36
|
+
this.retries = data.retries;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
class PoissonDiscPlugin {
|
|
42
|
+
id = "poisson";
|
|
43
|
+
async getPlugin(container) {
|
|
44
|
+
const { PoissonDiscPluginInstance } = await Promise.resolve().then(function () { return PoissonDiscPluginInstance$1; });
|
|
45
|
+
return new PoissonDiscPluginInstance(container);
|
|
46
|
+
}
|
|
47
|
+
loadOptions(_container, options, source) {
|
|
48
|
+
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let poissonOptions = options.poisson;
|
|
52
|
+
if (poissonOptions?.load === undefined) {
|
|
53
|
+
options.poisson = poissonOptions = new Poisson();
|
|
54
|
+
}
|
|
55
|
+
poissonOptions.load(source?.poisson);
|
|
56
|
+
}
|
|
57
|
+
needsPlugin(options) {
|
|
58
|
+
return options?.poisson?.enable ?? false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
38
61
|
|
|
39
|
-
|
|
62
|
+
async function loadPoissonDiscPlugin(engine) {
|
|
63
|
+
engine.checkVersion("4.0.0-beta.15");
|
|
64
|
+
await engine.pluginManager.register(e => {
|
|
65
|
+
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
66
|
+
});
|
|
67
|
+
}
|
|
40
68
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
\*******************************/
|
|
45
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
69
|
+
const globalObject = globalThis;
|
|
70
|
+
globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
|
|
71
|
+
globalObject.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
|
|
46
72
|
|
|
47
|
-
|
|
73
|
+
class PoissonDiscPluginInstance {
|
|
74
|
+
poissonDisc;
|
|
75
|
+
redrawTimeout;
|
|
76
|
+
_container;
|
|
77
|
+
_currentIndex;
|
|
78
|
+
constructor(container) {
|
|
79
|
+
this._container = container;
|
|
80
|
+
this._currentIndex = 0;
|
|
81
|
+
}
|
|
82
|
+
async init() {
|
|
83
|
+
await this._initData();
|
|
84
|
+
}
|
|
85
|
+
particlePosition(position) {
|
|
86
|
+
const container = this._container, options = container.actualOptions.poisson;
|
|
87
|
+
if (!this.poissonDisc || !(options?.enable ?? false) || this._currentIndex >= this.poissonDisc.points.length) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
return position ?? this.poissonDisc.points[this._currentIndex++]?.position;
|
|
91
|
+
}
|
|
92
|
+
resize() {
|
|
93
|
+
const container = this._container, options = container.actualOptions.poisson;
|
|
94
|
+
if (!(options?.enable ?? false)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (this.redrawTimeout) {
|
|
98
|
+
clearTimeout(this.redrawTimeout);
|
|
99
|
+
}
|
|
100
|
+
const timeout = 250;
|
|
101
|
+
this.redrawTimeout = setTimeout(() => {
|
|
102
|
+
void (async () => {
|
|
103
|
+
if (this._container.destroyed) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
await this._initData();
|
|
107
|
+
await container.particles.redraw();
|
|
108
|
+
})();
|
|
109
|
+
}, timeout);
|
|
110
|
+
}
|
|
111
|
+
stop() {
|
|
112
|
+
delete this.poissonDisc;
|
|
113
|
+
}
|
|
114
|
+
async _initData() {
|
|
115
|
+
const container = this._container, poissonOptions = container.actualOptions.poisson, particlesOptions = container.actualOptions.particles, canvasSize = container.canvas.size, pixelRatio = container.retina.pixelRatio;
|
|
116
|
+
if (!poissonOptions?.enable) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this._currentIndex = 0;
|
|
120
|
+
const { PoissonDisc } = await Promise.resolve().then(function () { return PoissonDisc$1; });
|
|
121
|
+
this.poissonDisc = new PoissonDisc(canvasSize, poissonOptions.radius
|
|
122
|
+
? poissonOptions.radius * pixelRatio
|
|
123
|
+
: Math.max(engine.getRangeMax(particlesOptions.size.value) * pixelRatio, Math.sqrt((canvasSize.width * canvasSize.height) / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);
|
|
124
|
+
const noSteps = 0;
|
|
125
|
+
if (poissonOptions.steps > noSteps) {
|
|
126
|
+
this.poissonDisc.steps(poissonOptions.steps);
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
await this.poissonDisc.run();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
48
133
|
|
|
49
|
-
|
|
134
|
+
var PoissonDiscPluginInstance$1 = /*#__PURE__*/Object.freeze({
|
|
135
|
+
__proto__: null,
|
|
136
|
+
PoissonDiscPluginInstance: PoissonDiscPluginInstance
|
|
137
|
+
});
|
|
50
138
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
/******/ if(true) { // all chunks have JS
|
|
238
|
-
/******/ // setup Promise in chunk cache
|
|
239
|
-
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
240
|
-
/******/ promises.push(installedChunkData[2] = promise);
|
|
241
|
-
/******/
|
|
242
|
-
/******/ // start chunk loading
|
|
243
|
-
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
|
244
|
-
/******/ // create error before stack unwound to get useful stacktrace later
|
|
245
|
-
/******/ var error = new Error();
|
|
246
|
-
/******/ var loadingEnded = (event) => {
|
|
247
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
248
|
-
/******/ installedChunkData = installedChunks[chunkId];
|
|
249
|
-
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
250
|
-
/******/ if(installedChunkData) {
|
|
251
|
-
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
252
|
-
/******/ var realSrc = event && event.target && event.target.src;
|
|
253
|
-
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
254
|
-
/******/ error.name = 'ChunkLoadError';
|
|
255
|
-
/******/ error.type = errorType;
|
|
256
|
-
/******/ error.request = realSrc;
|
|
257
|
-
/******/ installedChunkData[1](error);
|
|
258
|
-
/******/ }
|
|
259
|
-
/******/ }
|
|
260
|
-
/******/ };
|
|
261
|
-
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
|
262
|
-
/******/ }
|
|
263
|
-
/******/ }
|
|
264
|
-
/******/ }
|
|
265
|
-
/******/ };
|
|
266
|
-
/******/
|
|
267
|
-
/******/ // no prefetching
|
|
268
|
-
/******/
|
|
269
|
-
/******/ // no preloaded
|
|
270
|
-
/******/
|
|
271
|
-
/******/ // no HMR
|
|
272
|
-
/******/
|
|
273
|
-
/******/ // no HMR manifest
|
|
274
|
-
/******/
|
|
275
|
-
/******/ // no on chunks loaded
|
|
276
|
-
/******/
|
|
277
|
-
/******/ // install a JSONP callback for chunk loading
|
|
278
|
-
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
279
|
-
/******/ var [chunkIds, moreModules, runtime] = data;
|
|
280
|
-
/******/ // add "moreModules" to the modules object,
|
|
281
|
-
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
282
|
-
/******/ var moduleId, chunkId, i = 0;
|
|
283
|
-
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
284
|
-
/******/ for(moduleId in moreModules) {
|
|
285
|
-
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
286
|
-
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
287
|
-
/******/ }
|
|
288
|
-
/******/ }
|
|
289
|
-
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
290
|
-
/******/ }
|
|
291
|
-
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
292
|
-
/******/ for(;i < chunkIds.length; i++) {
|
|
293
|
-
/******/ chunkId = chunkIds[i];
|
|
294
|
-
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
295
|
-
/******/ installedChunks[chunkId][0]();
|
|
296
|
-
/******/ }
|
|
297
|
-
/******/ installedChunks[chunkId] = 0;
|
|
298
|
-
/******/ }
|
|
299
|
-
/******/
|
|
300
|
-
/******/ }
|
|
301
|
-
/******/
|
|
302
|
-
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_poisson_disc"] = this["webpackChunk_tsparticles_plugin_poisson_disc"] || [];
|
|
303
|
-
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
304
|
-
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
305
|
-
/******/ })();
|
|
306
|
-
/******/
|
|
307
|
-
/************************************************************************/
|
|
308
|
-
/******/
|
|
309
|
-
/******/ // startup
|
|
310
|
-
/******/ // Load entry module and return exports
|
|
311
|
-
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
312
|
-
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
313
|
-
/******/
|
|
314
|
-
/******/ return __webpack_exports__;
|
|
315
|
-
/******/ })()
|
|
316
|
-
;
|
|
317
|
-
});
|
|
139
|
+
class PoissonDisc {
|
|
140
|
+
active;
|
|
141
|
+
cellSize;
|
|
142
|
+
cols;
|
|
143
|
+
dimensions;
|
|
144
|
+
firstPoint;
|
|
145
|
+
grid;
|
|
146
|
+
points;
|
|
147
|
+
radius;
|
|
148
|
+
retries;
|
|
149
|
+
rows;
|
|
150
|
+
size;
|
|
151
|
+
constructor(size, radius, retries, dimensions, firstPoint) {
|
|
152
|
+
this.size = { ...size };
|
|
153
|
+
this.radius = radius;
|
|
154
|
+
this.retries = retries;
|
|
155
|
+
this.dimensions = dimensions;
|
|
156
|
+
this.cellSize = Math.floor(this.radius / Math.sqrt(this.dimensions));
|
|
157
|
+
this.cols = Math.floor(this.size.width / this.cellSize);
|
|
158
|
+
this.rows = Math.floor(this.size.height / this.cellSize);
|
|
159
|
+
this.points = [];
|
|
160
|
+
this.active = [];
|
|
161
|
+
this.grid = [];
|
|
162
|
+
this.firstPoint = firstPoint ? { ...firstPoint } : undefined;
|
|
163
|
+
this.reset();
|
|
164
|
+
}
|
|
165
|
+
addPoint(inputPoint) {
|
|
166
|
+
const point = {
|
|
167
|
+
position: { ...inputPoint },
|
|
168
|
+
gridPosition: {
|
|
169
|
+
x: Math.floor(inputPoint.x / this.cellSize),
|
|
170
|
+
y: Math.floor(inputPoint.y / this.cellSize),
|
|
171
|
+
},
|
|
172
|
+
}, pointIndex = this.points.length, row = this.grid[point.gridPosition.y];
|
|
173
|
+
if (!row) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
this.points.push(point);
|
|
177
|
+
row[point.gridPosition.x] = pointIndex;
|
|
178
|
+
this.active.push(pointIndex);
|
|
179
|
+
}
|
|
180
|
+
getRandom(min, max) {
|
|
181
|
+
return Math.floor(engine.getRandom() * (max - min)) + min;
|
|
182
|
+
}
|
|
183
|
+
initialiseGrid() {
|
|
184
|
+
for (let y = 0; y <= this.rows; y++) {
|
|
185
|
+
this.grid[y] = [];
|
|
186
|
+
const row = this.grid[y];
|
|
187
|
+
if (!row) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
for (let x = 0; x <= this.cols; x++) {
|
|
191
|
+
row[x] = -1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
reset() {
|
|
196
|
+
this.points = [];
|
|
197
|
+
this.active = [];
|
|
198
|
+
this.grid = [];
|
|
199
|
+
this.initialiseGrid();
|
|
200
|
+
if (this.firstPoint) {
|
|
201
|
+
this.addPoint(this.firstPoint);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
const minCoordinate = 0;
|
|
205
|
+
this.addPoint({
|
|
206
|
+
x: this.getRandom(minCoordinate, this.size.width),
|
|
207
|
+
y: this.getRandom(minCoordinate, this.size.height),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async run() {
|
|
212
|
+
this.reset();
|
|
213
|
+
const minCount = 0, step = 1, yieldEvery = 100, yieldStepModule = 0;
|
|
214
|
+
let iterations = 0;
|
|
215
|
+
while (this.active.length > minCount) {
|
|
216
|
+
this.steps(step);
|
|
217
|
+
if (++iterations % yieldEvery === yieldStepModule) {
|
|
218
|
+
await new Promise(resolve => setTimeout(resolve));
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
steps(steps) {
|
|
223
|
+
const minCount = 0;
|
|
224
|
+
for (let i = 0; i < steps; i++) {
|
|
225
|
+
if (this.active.length <= minCount) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
this._step();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
_getNewPoint(currentPoint, tries) {
|
|
232
|
+
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (engine.doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * engine.double), offset = {
|
|
233
|
+
x: Math.cos(newAngle) * newDist,
|
|
234
|
+
y: Math.sin(newAngle) * newDist,
|
|
235
|
+
}, newPoint = {
|
|
236
|
+
x: Math.floor(currentPoint.position.x + offset.x),
|
|
237
|
+
y: Math.floor(currentPoint.position.y + offset.y),
|
|
238
|
+
}, newGridCoords = {
|
|
239
|
+
x: Math.floor(newPoint.x / this.cellSize),
|
|
240
|
+
y: Math.floor(newPoint.y / this.cellSize),
|
|
241
|
+
};
|
|
242
|
+
if (newPoint.x <= minCoordinate ||
|
|
243
|
+
newPoint.x >= this.size.width ||
|
|
244
|
+
newPoint.y <= minCoordinate ||
|
|
245
|
+
newPoint.y >= this.size.height) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const row = this.grid[newGridCoords.y];
|
|
249
|
+
if (!row) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const cellValue = row[newGridCoords.x];
|
|
253
|
+
if (cellValue === undefined) {
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (cellValue >= gridMinValue) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
for (let i = -1; i <= maxNeighbourIndex; i++) {
|
|
260
|
+
for (let j = -1; j <= maxNeighbourIndex; j++) {
|
|
261
|
+
if (!i && !j) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const neighbourGrid = {
|
|
265
|
+
x: newGridCoords.x + j,
|
|
266
|
+
y: newGridCoords.y + i,
|
|
267
|
+
};
|
|
268
|
+
if (neighbourGrid.x < minCoordinate ||
|
|
269
|
+
neighbourGrid.y < minCoordinate ||
|
|
270
|
+
neighbourGrid.x >= this.cols ||
|
|
271
|
+
neighbourGrid.y >= this.rows) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const neighbourCellValue = this.grid[neighbourGrid.y]?.[neighbourGrid.x];
|
|
275
|
+
if (neighbourCellValue === undefined || neighbourCellValue < gridMinValue) {
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
const neighbour = this.points[neighbourCellValue];
|
|
279
|
+
if (!neighbour) {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
if (engine.getDistance(newPoint, neighbour.position) < this.radius) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return newPoint;
|
|
288
|
+
}
|
|
289
|
+
_step() {
|
|
290
|
+
const minCount = 0, randomActive = this.getRandom(minCount, this.active.length);
|
|
291
|
+
let foundNewPoint = false;
|
|
292
|
+
for (let tries = 0; tries < this.retries; tries++) {
|
|
293
|
+
const randomActivePointIndex = this.active[randomActive];
|
|
294
|
+
if (randomActivePointIndex === undefined) {
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const point = this.points[randomActivePointIndex];
|
|
298
|
+
if (!point) {
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
const newPoint = this._getNewPoint(point, tries);
|
|
302
|
+
if (newPoint) {
|
|
303
|
+
foundNewPoint = true;
|
|
304
|
+
this.addPoint(newPoint);
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!foundNewPoint) {
|
|
309
|
+
const deleteCount = 1;
|
|
310
|
+
this.active.splice(randomActive, deleteCount);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
var PoissonDisc$1 = /*#__PURE__*/Object.freeze({
|
|
316
|
+
__proto__: null,
|
|
317
|
+
PoissonDisc: PoissonDisc
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
|
|
321
|
+
|
|
322
|
+
}));
|
|
323
|
+
Object.assign(globalThis.window || globalThis, { loadPoissonDiscPlugin: (globalThis.__tsParticlesInternals.plugins.poisson || {}).loadPoissonDiscPlugin });
|
|
324
|
+
delete (globalThis.window || globalThis).tsparticlesInternalExports;
|