@tsparticles/plugin-poisson-disc 4.0.0-alpha.2 → 4.0.0-alpha.4
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/336.min.js +2 -0
- package/336.min.js.LICENSE.txt +1 -0
- package/879.min.js +2 -0
- package/879.min.js.LICENSE.txt +1 -0
- package/browser/PoissonDisc.js +1 -2
- package/browser/PoissonDiscPlugin.js +4 -4
- package/{esm/PoissonInstance.js → browser/PoissonDiscPluginInstance.js} +1 -1
- package/browser/index.js +1 -1
- package/cjs/PoissonDisc.js +1 -2
- package/cjs/PoissonDiscPlugin.js +4 -4
- package/{browser/PoissonInstance.js → cjs/PoissonDiscPluginInstance.js} +1 -1
- package/cjs/index.js +1 -1
- package/dist_browser_PoissonDiscPluginInstance_js.js +40 -0
- package/dist_browser_PoissonDiscPlugin_js.js +2 -22
- package/esm/PoissonDisc.js +1 -2
- package/esm/PoissonDiscPlugin.js +4 -4
- package/{cjs/PoissonInstance.js → esm/PoissonDiscPluginInstance.js} +1 -1
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.plugin.poisson.js +4 -16
- package/tsparticles.plugin.poisson.min.js +1 -1
- package/tsparticles.plugin.poisson.min.js.LICENSE.txt +1 -1
- package/types/PoissonDiscPlugin.d.ts +3 -4
- package/types/{PoissonInstance.d.ts → PoissonDiscPluginInstance.d.ts} +1 -1
- package/umd/PoissonDisc.js +1 -2
- package/umd/PoissonDiscPlugin.js +39 -5
- package/umd/{PoissonInstance.js → PoissonDiscPluginInstance.js} +3 -3
- package/umd/index.js +1 -1
- package/295.min.js +0 -2
- package/295.min.js.LICENSE.txt +0 -1
package/336.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 336.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[336],{336(i,t,s){s.d(t,{PoissonDiscPluginInstance:()=>n});var e=s(303);class o{constructor(i,t,s,e,o){this.size={...i},this.radius=t,this.retries=s,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=o?{...o}:void 0,this.reset()}addPoint(i){const t={position:{...i},gridPosition:{x:Math.floor(i.x/this.cellSize),y:Math.floor(i.y/this.cellSize)}},s=this.points.length,e=this.grid[t.gridPosition.y];e&&(this.points.push(t),e[t.gridPosition.x]=s,this.active.push(s))}getRandom(i,t){return Math.floor((0,e.getRandom)()*(t-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];const t=this.grid[i];if(t)for(let i=0;i<=this.cols;i++)t[i]=-1}}reset(){if(this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint)this.addPoint(this.firstPoint);else{const i=0;this.addPoint({x:this.getRandom(i,this.size.width),y:this.getRandom(i,this.size.height)})}}async run(){this.reset();for(;this.active.length>0;)await this.steps(1)}async steps(i){for(let t=0;t<i;t++)this.active.length<=0||await this._step()}_getNewPoint(i,t){const s=t*(e.doublePI/this.retries),o=this.getRandom(this.radius,this.radius*e.double),n=Math.cos(s)*o,h=Math.sin(s)*o,r={x:Math.floor(i.position.x+n),y:Math.floor(i.position.y+h)},a=Math.floor(r.x/this.cellSize),c=Math.floor(r.y/this.cellSize);if(r.x>0&&r.x<this.size.width&&r.y>0&&r.y<this.size.height){{const i=this.grid[c];if(!i)return;const t=i[a];if(void 0===t)return;if(!(t<0))return;for(let i=-1;i<=1;i++)for(let s=-1;s<=1;s++){const o={x:a+s,y:c+i};if(o.x>=0&&o.y>=0&&o.x<this.cols&&o.y<this.rows&&(o.x!==a||o.y!==c)&&t>=0){const i=t,s=this.points[i];if(!s)continue;if((0,e.getDistance)(r,s.position)<this.radius)return}}}return r}}async _step(){const i=this.getRandom(0,this.active.length);return new Promise((t=>{let s=!1;for(let t=0;t<this.retries;t++){const e=this.active[i];if(void 0===e)continue;const o=this.points[e];if(!o)continue;const n=this._getNewPoint(o,t);if(n){s=!0,this.addPoint(n);break}}if(!s){const t=1;this.active.splice(i,t)}t()}))}}class n{constructor(i){this._container=i,this._currentIndex=0}async init(){await this._initData()}particlePosition(i){const t=this._container.actualOptions.poisson;if(this.poissonDisc&&t?.enable&&!(this._currentIndex>=this.poissonDisc.points.length))return i??this.poissonDisc.points[this._currentIndex++]?.position}resize(){const i=this._container,t=i.actualOptions.poisson;if(!t?.enable)return;this.redrawTimeout&&clearTimeout(this.redrawTimeout);this.redrawTimeout=setTimeout((()=>{(async()=>{await this._initData(),await i.particles.redraw()})()}),250)}stop(){delete this.poissonDisc}async _initData(){const i=this._container,t=i.actualOptions.poisson,s=i.actualOptions.particles,n=i.canvas.size,h=i.retina.pixelRatio;if(!t?.enable)return;this._currentIndex=0,this.poissonDisc=new o(n,t.radius?t.radius*h:Math.max((0,e.getRangeMax)(s.size.value)*h,Math.sqrt(n.width*n.height/s.number.value)),t.retries,t.dimensions);t.steps>0?await this.poissonDisc.steps(t.steps):await this.poissonDisc.run()}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Poisson Disc Plugin v4.0.0-alpha.4 by Matteo Bruni */
|
package/879.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 879.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[879],{879(s,i,n){n.d(i,{PoissonDiscPlugin:()=>t});var e=n(303);class o{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(s){(0,e.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 t{constructor(){this.id="poisson"}async getPlugin(s){const{PoissonDiscPluginInstance:i}=await n.e(336).then(n.bind(n,336));return new i(s)}loadOptions(s,i,n){if(!this.needsPlugin(i)&&!this.needsPlugin(n))return;let e=i.poisson;void 0===e?.load&&(i.poisson=e=new o),e.load(n?.poisson)}needsPlugin(s){return s?.poisson?.enable??!1}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Poisson Disc Plugin v4.0.0-alpha.4 by Matteo Bruni */
|
package/browser/PoissonDisc.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getDistance, getRandom } from "@tsparticles/engine";
|
|
2
|
-
const double = 2, doublePI = Math.PI * double;
|
|
1
|
+
import { double, doublePI, getDistance, getRandom } from "@tsparticles/engine";
|
|
3
2
|
export class PoissonDisc {
|
|
4
3
|
constructor(size, radius, retries, dimensions, firstPoint) {
|
|
5
4
|
this.size = { ...size };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Poisson } from "./Options/Classes/Poisson.js";
|
|
2
|
-
import { PoissonInstance } from "./PoissonInstance.js";
|
|
3
2
|
export class PoissonDiscPlugin {
|
|
4
3
|
constructor() {
|
|
5
4
|
this.id = "poisson";
|
|
6
5
|
}
|
|
7
|
-
getPlugin(container) {
|
|
8
|
-
|
|
6
|
+
async getPlugin(container) {
|
|
7
|
+
const { PoissonDiscPluginInstance } = await import("./PoissonDiscPluginInstance.js");
|
|
8
|
+
return new PoissonDiscPluginInstance(container);
|
|
9
9
|
}
|
|
10
|
-
loadOptions(options, source) {
|
|
10
|
+
loadOptions(_container, options, source) {
|
|
11
11
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
3
3
|
engine.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
5
|
e.addPlugin(new PoissonDiscPlugin());
|
package/cjs/PoissonDisc.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getDistance, getRandom } from "@tsparticles/engine";
|
|
2
|
-
const double = 2, doublePI = Math.PI * double;
|
|
1
|
+
import { double, doublePI, getDistance, getRandom } from "@tsparticles/engine";
|
|
3
2
|
export class PoissonDisc {
|
|
4
3
|
constructor(size, radius, retries, dimensions, firstPoint) {
|
|
5
4
|
this.size = { ...size };
|
package/cjs/PoissonDiscPlugin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Poisson } from "./Options/Classes/Poisson.js";
|
|
2
|
-
import { PoissonInstance } from "./PoissonInstance.js";
|
|
3
2
|
export class PoissonDiscPlugin {
|
|
4
3
|
constructor() {
|
|
5
4
|
this.id = "poisson";
|
|
6
5
|
}
|
|
7
|
-
getPlugin(container) {
|
|
8
|
-
|
|
6
|
+
async getPlugin(container) {
|
|
7
|
+
const { PoissonDiscPluginInstance } = await import("./PoissonDiscPluginInstance.js");
|
|
8
|
+
return new PoissonDiscPluginInstance(container);
|
|
9
9
|
}
|
|
10
|
-
loadOptions(options, source) {
|
|
10
|
+
loadOptions(_container, options, source) {
|
|
11
11
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
3
3
|
engine.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
5
|
e.addPlugin(new PoissonDiscPlugin());
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.4
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_plugin_poisson_disc"] = this["webpackChunk_tsparticles_plugin_poisson_disc"] || []).push([["dist_browser_PoissonDiscPluginInstance_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/PoissonDisc.js"
|
|
21
|
+
/*!*************************************!*\
|
|
22
|
+
!*** ./dist/browser/PoissonDisc.js ***!
|
|
23
|
+
\*************************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PoissonDisc: () => (/* binding */ PoissonDisc)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass PoissonDisc {\n constructor(size, radius, retries, dimensions, firstPoint) {\n this.size = {\n ...size\n };\n this.radius = radius;\n this.retries = retries;\n this.dimensions = dimensions;\n this.cellSize = Math.floor(this.radius / Math.sqrt(this.dimensions));\n this.cols = Math.floor(this.size.width / this.cellSize);\n this.rows = Math.floor(this.size.height / this.cellSize);\n this.points = [];\n this.active = [];\n this.grid = [];\n this.firstPoint = firstPoint ? {\n ...firstPoint\n } : undefined;\n this.reset();\n }\n addPoint(inputPoint) {\n const point = {\n position: {\n ...inputPoint\n },\n gridPosition: {\n x: Math.floor(inputPoint.x / this.cellSize),\n y: Math.floor(inputPoint.y / this.cellSize)\n }\n },\n pointIndex = this.points.length,\n row = this.grid[point.gridPosition.y];\n if (!row) {\n return;\n }\n this.points.push(point);\n row[point.gridPosition.x] = pointIndex;\n this.active.push(pointIndex);\n }\n getRandom(min, max) {\n return Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * (max - min)) + min;\n }\n initialiseGrid() {\n for (let y = 0; y <= this.rows; y++) {\n this.grid[y] = [];\n const row = this.grid[y];\n if (!row) {\n continue;\n }\n for (let x = 0; x <= this.cols; x++) {\n row[x] = -1;\n }\n }\n }\n reset() {\n this.points = [];\n this.active = [];\n this.grid = [];\n this.initialiseGrid();\n if (this.firstPoint) {\n this.addPoint(this.firstPoint);\n } else {\n const minCoordinate = 0;\n this.addPoint({\n x: this.getRandom(minCoordinate, this.size.width),\n y: this.getRandom(minCoordinate, this.size.height)\n });\n }\n }\n async run() {\n this.reset();\n const minCount = 0,\n step = 1;\n while (this.active.length > minCount) {\n await this.steps(step);\n }\n }\n async steps(steps) {\n const minCount = 0;\n for (let i = 0; i < steps; i++) {\n if (this.active.length <= minCount) {\n continue;\n }\n await this._step();\n }\n }\n _getNewPoint(currentPoint, tries) {\n const minCoordinate = 0,\n gridMinValue = 0,\n maxNeighbourIndex = 1,\n newAngle = tries * (_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI / this.retries),\n newDist = this.getRandom(this.radius, this.radius * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.double),\n offset = {\n x: Math.cos(newAngle) * newDist,\n y: Math.sin(newAngle) * newDist\n },\n newPoint = {\n x: Math.floor(currentPoint.position.x + offset.x),\n y: Math.floor(currentPoint.position.y + offset.y)\n },\n newGridCoords = {\n x: Math.floor(newPoint.x / this.cellSize),\n y: Math.floor(newPoint.y / this.cellSize)\n };\n if (newPoint.x > minCoordinate && newPoint.x < this.size.width && newPoint.y > minCoordinate && newPoint.y < this.size.height) {\n const row = this.grid[newGridCoords.y];\n if (!row) {\n return;\n }\n const point = row[newGridCoords.x];\n if (point === undefined) {\n return;\n }\n if (point < gridMinValue) {\n for (let i = -1; i <= maxNeighbourIndex; i++) {\n for (let j = -1; j <= maxNeighbourIndex; j++) {\n const neighbourGrid = {\n x: newGridCoords.x + j,\n y: newGridCoords.y + i\n };\n if (neighbourGrid.x >= minCoordinate && neighbourGrid.y >= minCoordinate && neighbourGrid.x < this.cols && neighbourGrid.y < this.rows && (neighbourGrid.x !== newGridCoords.x || neighbourGrid.y !== newGridCoords.y)) {\n if (point >= gridMinValue) {\n const neighbourIndex = point,\n neighbour = this.points[neighbourIndex];\n if (!neighbour) {\n continue;\n }\n const dist = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(newPoint, neighbour.position);\n if (dist < this.radius) {\n return;\n }\n }\n }\n }\n }\n } else {\n return;\n }\n } else {\n return;\n }\n return newPoint;\n }\n async _step() {\n const minCount = 0,\n randomActive = this.getRandom(minCount, this.active.length);\n return new Promise(resolve => {\n let foundNewPoint = false;\n for (let tries = 0; tries < this.retries; tries++) {\n const randomActivePointIndex = this.active[randomActive];\n if (randomActivePointIndex === undefined) {\n continue;\n }\n const point = this.points[randomActivePointIndex];\n if (!point) {\n continue;\n }\n const newPoint = this._getNewPoint(point, tries);\n if (newPoint) {\n foundNewPoint = true;\n this.addPoint(newPoint);\n break;\n }\n }\n if (!foundNewPoint) {\n const deleteCount = 1;\n this.active.splice(randomActive, deleteCount);\n }\n resolve();\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/PoissonDisc.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/PoissonDiscPluginInstance.js"
|
|
31
|
+
/*!***************************************************!*\
|
|
32
|
+
!*** ./dist/browser/PoissonDiscPluginInstance.js ***!
|
|
33
|
+
\***************************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PoissonDiscPluginInstance: () => (/* binding */ PoissonDiscPluginInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _PoissonDisc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PoissonDisc.js */ \"./dist/browser/PoissonDisc.js\");\n\n\nclass PoissonDiscPluginInstance {\n constructor(container) {\n this._container = container;\n this._currentIndex = 0;\n }\n async init() {\n await this._initData();\n }\n particlePosition(position) {\n const container = this._container,\n options = container.actualOptions.poisson;\n if (!this.poissonDisc || !(options?.enable ?? false) || this._currentIndex >= this.poissonDisc.points.length) {\n return;\n }\n return position ?? this.poissonDisc.points[this._currentIndex++]?.position;\n }\n resize() {\n const container = this._container,\n options = container.actualOptions.poisson;\n if (!(options?.enable ?? false)) {\n return;\n }\n if (this.redrawTimeout) {\n clearTimeout(this.redrawTimeout);\n }\n const timeout = 250;\n this.redrawTimeout = setTimeout(() => {\n void (async () => {\n await this._initData();\n await container.particles.redraw();\n })();\n }, timeout);\n }\n stop() {\n delete this.poissonDisc;\n }\n async _initData() {\n const container = this._container,\n poissonOptions = container.actualOptions.poisson,\n particlesOptions = container.actualOptions.particles,\n canvasSize = container.canvas.size,\n pixelRatio = container.retina.pixelRatio;\n if (!poissonOptions?.enable) {\n return;\n }\n this._currentIndex = 0;\n this.poissonDisc = new _PoissonDisc_js__WEBPACK_IMPORTED_MODULE_1__.PoissonDisc(canvasSize, poissonOptions.radius ? poissonOptions.radius * pixelRatio : Math.max((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeMax)(particlesOptions.size.value) * pixelRatio, Math.sqrt(canvasSize.width * canvasSize.height / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);\n const noSteps = 0;\n if (poissonOptions.steps > noSteps) {\n await this.poissonDisc.steps(poissonOptions.steps);\n } else {\n await this.poissonDisc.run();\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/PoissonDiscPluginInstance.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ }
|
|
39
|
+
|
|
40
|
+
}]);
|
|
@@ -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
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.4
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -27,33 +27,13 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
30
|
-
/***/ "./dist/browser/PoissonDisc.js"
|
|
31
|
-
/*!*************************************!*\
|
|
32
|
-
!*** ./dist/browser/PoissonDisc.js ***!
|
|
33
|
-
\*************************************/
|
|
34
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
-
|
|
36
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PoissonDisc: () => (/* binding */ PoissonDisc)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst double = 2,\n doublePI = Math.PI * double;\nclass PoissonDisc {\n constructor(size, radius, retries, dimensions, firstPoint) {\n this.size = {\n ...size\n };\n this.radius = radius;\n this.retries = retries;\n this.dimensions = dimensions;\n this.cellSize = Math.floor(this.radius / Math.sqrt(this.dimensions));\n this.cols = Math.floor(this.size.width / this.cellSize);\n this.rows = Math.floor(this.size.height / this.cellSize);\n this.points = [];\n this.active = [];\n this.grid = [];\n this.firstPoint = firstPoint ? {\n ...firstPoint\n } : undefined;\n this.reset();\n }\n addPoint(inputPoint) {\n const point = {\n position: {\n ...inputPoint\n },\n gridPosition: {\n x: Math.floor(inputPoint.x / this.cellSize),\n y: Math.floor(inputPoint.y / this.cellSize)\n }\n },\n pointIndex = this.points.length,\n row = this.grid[point.gridPosition.y];\n if (!row) {\n return;\n }\n this.points.push(point);\n row[point.gridPosition.x] = pointIndex;\n this.active.push(pointIndex);\n }\n getRandom(min, max) {\n return Math.floor((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * (max - min)) + min;\n }\n initialiseGrid() {\n for (let y = 0; y <= this.rows; y++) {\n this.grid[y] = [];\n const row = this.grid[y];\n if (!row) {\n continue;\n }\n for (let x = 0; x <= this.cols; x++) {\n row[x] = -1;\n }\n }\n }\n reset() {\n this.points = [];\n this.active = [];\n this.grid = [];\n this.initialiseGrid();\n if (this.firstPoint) {\n this.addPoint(this.firstPoint);\n } else {\n const minCoordinate = 0;\n this.addPoint({\n x: this.getRandom(minCoordinate, this.size.width),\n y: this.getRandom(minCoordinate, this.size.height)\n });\n }\n }\n async run() {\n this.reset();\n const minCount = 0,\n step = 1;\n while (this.active.length > minCount) {\n await this.steps(step);\n }\n }\n async steps(steps) {\n const minCount = 0;\n for (let i = 0; i < steps; i++) {\n if (this.active.length <= minCount) {\n continue;\n }\n await this._step();\n }\n }\n _getNewPoint(currentPoint, tries) {\n const minCoordinate = 0,\n gridMinValue = 0,\n maxNeighbourIndex = 1,\n newAngle = tries * (doublePI / this.retries),\n newDist = this.getRandom(this.radius, this.radius * double),\n offset = {\n x: Math.cos(newAngle) * newDist,\n y: Math.sin(newAngle) * newDist\n },\n newPoint = {\n x: Math.floor(currentPoint.position.x + offset.x),\n y: Math.floor(currentPoint.position.y + offset.y)\n },\n newGridCoords = {\n x: Math.floor(newPoint.x / this.cellSize),\n y: Math.floor(newPoint.y / this.cellSize)\n };\n if (newPoint.x > minCoordinate && newPoint.x < this.size.width && newPoint.y > minCoordinate && newPoint.y < this.size.height) {\n const row = this.grid[newGridCoords.y];\n if (!row) {\n return;\n }\n const point = row[newGridCoords.x];\n if (point === undefined) {\n return;\n }\n if (point < gridMinValue) {\n for (let i = -1; i <= maxNeighbourIndex; i++) {\n for (let j = -1; j <= maxNeighbourIndex; j++) {\n const neighbourGrid = {\n x: newGridCoords.x + j,\n y: newGridCoords.y + i\n };\n if (neighbourGrid.x >= minCoordinate && neighbourGrid.y >= minCoordinate && neighbourGrid.x < this.cols && neighbourGrid.y < this.rows && (neighbourGrid.x !== newGridCoords.x || neighbourGrid.y !== newGridCoords.y)) {\n if (point >= gridMinValue) {\n const neighbourIndex = point,\n neighbour = this.points[neighbourIndex];\n if (!neighbour) {\n continue;\n }\n const dist = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getDistance)(newPoint, neighbour.position);\n if (dist < this.radius) {\n return;\n }\n }\n }\n }\n }\n } else {\n return;\n }\n } else {\n return;\n }\n return newPoint;\n }\n async _step() {\n const minCount = 0,\n randomActive = this.getRandom(minCount, this.active.length);\n return new Promise(resolve => {\n let foundNewPoint = false;\n for (let tries = 0; tries < this.retries; tries++) {\n const randomActivePointIndex = this.active[randomActive];\n if (randomActivePointIndex === undefined) {\n continue;\n }\n const point = this.points[randomActivePointIndex];\n if (!point) {\n continue;\n }\n const newPoint = this._getNewPoint(point, tries);\n if (newPoint) {\n foundNewPoint = true;\n this.addPoint(newPoint);\n break;\n }\n }\n if (!foundNewPoint) {\n const deleteCount = 1;\n this.active.splice(randomActive, deleteCount);\n }\n resolve();\n });\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/PoissonDisc.js?\n}");
|
|
37
|
-
|
|
38
|
-
/***/ },
|
|
39
|
-
|
|
40
30
|
/***/ "./dist/browser/PoissonDiscPlugin.js"
|
|
41
31
|
/*!*******************************************!*\
|
|
42
32
|
!*** ./dist/browser/PoissonDiscPlugin.js ***!
|
|
43
33
|
\*******************************************/
|
|
44
34
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
35
|
|
|
46
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PoissonDiscPlugin: () => (/* binding */ PoissonDiscPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Poisson_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Poisson.js */ \"./dist/browser/Options/Classes/Poisson.js\");\n
|
|
47
|
-
|
|
48
|
-
/***/ },
|
|
49
|
-
|
|
50
|
-
/***/ "./dist/browser/PoissonInstance.js"
|
|
51
|
-
/*!*****************************************!*\
|
|
52
|
-
!*** ./dist/browser/PoissonInstance.js ***!
|
|
53
|
-
\*****************************************/
|
|
54
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
55
|
-
|
|
56
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PoissonInstance: () => (/* binding */ PoissonInstance)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _PoissonDisc_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PoissonDisc.js */ \"./dist/browser/PoissonDisc.js\");\n\n\nclass PoissonInstance {\n constructor(container) {\n this._container = container;\n this._currentIndex = 0;\n }\n async init() {\n await this._initData();\n }\n particlePosition(position) {\n const container = this._container,\n options = container.actualOptions.poisson;\n if (!this.poissonDisc || !(options?.enable ?? false) || this._currentIndex >= this.poissonDisc.points.length) {\n return;\n }\n return position ?? this.poissonDisc.points[this._currentIndex++]?.position;\n }\n resize() {\n const container = this._container,\n options = container.actualOptions.poisson;\n if (!(options?.enable ?? false)) {\n return;\n }\n if (this.redrawTimeout) {\n clearTimeout(this.redrawTimeout);\n }\n const timeout = 250;\n this.redrawTimeout = setTimeout(() => {\n void (async () => {\n await this._initData();\n await container.particles.redraw();\n })();\n }, timeout);\n }\n stop() {\n delete this.poissonDisc;\n }\n async _initData() {\n const container = this._container,\n poissonOptions = container.actualOptions.poisson,\n particlesOptions = container.actualOptions.particles,\n canvasSize = container.canvas.size,\n pixelRatio = container.retina.pixelRatio;\n if (!poissonOptions?.enable) {\n return;\n }\n this._currentIndex = 0;\n this.poissonDisc = new _PoissonDisc_js__WEBPACK_IMPORTED_MODULE_1__.PoissonDisc(canvasSize, poissonOptions.radius ? poissonOptions.radius * pixelRatio : Math.max((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeMax)(particlesOptions.size.value) * pixelRatio, Math.sqrt(canvasSize.width * canvasSize.height / particlesOptions.number.value)), poissonOptions.retries, poissonOptions.dimensions);\n const noSteps = 0;\n if (poissonOptions.steps > noSteps) {\n await this.poissonDisc.steps(poissonOptions.steps);\n } else {\n await this.poissonDisc.run();\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/PoissonInstance.js?\n}");
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ PoissonDiscPlugin: () => (/* binding */ PoissonDiscPlugin)\n/* harmony export */ });\n/* harmony import */ var _Options_Classes_Poisson_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Options/Classes/Poisson.js */ \"./dist/browser/Options/Classes/Poisson.js\");\n\nclass PoissonDiscPlugin {\n constructor() {\n this.id = \"poisson\";\n }\n async getPlugin(container) {\n const {\n PoissonDiscPluginInstance\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_PoissonDiscPluginInstance_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PoissonDiscPluginInstance.js */ \"./dist/browser/PoissonDiscPluginInstance.js\"));\n return new PoissonDiscPluginInstance(container);\n }\n loadOptions(_container, options, source) {\n if (!this.needsPlugin(options) && !this.needsPlugin(source)) {\n return;\n }\n let poissonOptions = options.poisson;\n if (poissonOptions?.load === undefined) {\n options.poisson = poissonOptions = new _Options_Classes_Poisson_js__WEBPACK_IMPORTED_MODULE_0__.Poisson();\n }\n poissonOptions.load(source?.poisson);\n }\n needsPlugin(options) {\n return options?.poisson?.enable ?? false;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/PoissonDiscPlugin.js?\n}");
|
|
57
37
|
|
|
58
38
|
/***/ }
|
|
59
39
|
|
package/esm/PoissonDisc.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getDistance, getRandom } from "@tsparticles/engine";
|
|
2
|
-
const double = 2, doublePI = Math.PI * double;
|
|
1
|
+
import { double, doublePI, getDistance, getRandom } from "@tsparticles/engine";
|
|
3
2
|
export class PoissonDisc {
|
|
4
3
|
constructor(size, radius, retries, dimensions, firstPoint) {
|
|
5
4
|
this.size = { ...size };
|
package/esm/PoissonDiscPlugin.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Poisson } from "./Options/Classes/Poisson.js";
|
|
2
|
-
import { PoissonInstance } from "./PoissonInstance.js";
|
|
3
2
|
export class PoissonDiscPlugin {
|
|
4
3
|
constructor() {
|
|
5
4
|
this.id = "poisson";
|
|
6
5
|
}
|
|
7
|
-
getPlugin(container) {
|
|
8
|
-
|
|
6
|
+
async getPlugin(container) {
|
|
7
|
+
const { PoissonDiscPluginInstance } = await import("./PoissonDiscPluginInstance.js");
|
|
8
|
+
return new PoissonDiscPluginInstance(container);
|
|
9
9
|
}
|
|
10
|
-
loadOptions(options, source) {
|
|
10
|
+
loadOptions(_container, options, source) {
|
|
11
11
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-alpha.
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
3
3
|
engine.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
5
|
e.addPlugin(new PoissonDiscPlugin());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-poisson-disc",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.4",
|
|
4
4
|
"description": "tsParticles poisson disc plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"./package.json": "./package.json"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@tsparticles/engine": "4.0.0-alpha.
|
|
88
|
+
"@tsparticles/engine": "4.0.0-alpha.4"
|
|
89
89
|
},
|
|
90
90
|
"publishConfig": {
|
|
91
91
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/plugin-poisson-disc [
|
|
6
|
+
<title>@tsparticles/plugin-poisson-disc [21 Jan 2026 at 14:33]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|
|
@@ -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
|
-
* v4.0.0-alpha.
|
|
7
|
+
* v4.0.0-alpha.4
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
34
34
|
\*******************************/
|
|
35
35
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
36
36
|
|
|
37
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPoissonDiscPlugin: () => (/* binding */ loadPoissonDiscPlugin)\n/* harmony export */ });\nfunction loadPoissonDiscPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPoissonDiscPlugin: () => (/* binding */ loadPoissonDiscPlugin)\n/* harmony export */ });\nfunction loadPoissonDiscPlugin(engine) {\n engine.checkVersion(\"4.0.0-alpha.4\");\n engine.register(async e => {\n const {\n PoissonDiscPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_PoissonDiscPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./PoissonDiscPlugin.js */ \"./dist/browser/PoissonDiscPlugin.js\"));\n e.addPlugin(new PoissonDiscPlugin());\n });\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/index.js?\n}");
|
|
38
38
|
|
|
39
39
|
/***/ },
|
|
40
40
|
|
|
@@ -118,18 +118,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
118
118
|
/******/ };
|
|
119
119
|
/******/ })();
|
|
120
120
|
/******/
|
|
121
|
-
/******/ /* webpack/runtime/global */
|
|
122
|
-
/******/ (() => {
|
|
123
|
-
/******/ __webpack_require__.g = (function() {
|
|
124
|
-
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
125
|
-
/******/ try {
|
|
126
|
-
/******/ return this || new Function('return this')();
|
|
127
|
-
/******/ } catch (e) {
|
|
128
|
-
/******/ if (typeof window === 'object') return window;
|
|
129
|
-
/******/ }
|
|
130
|
-
/******/ })();
|
|
131
|
-
/******/ })();
|
|
132
|
-
/******/
|
|
133
121
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
134
122
|
/******/ (() => {
|
|
135
123
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
@@ -194,8 +182,8 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
194
182
|
/******/ /* webpack/runtime/publicPath */
|
|
195
183
|
/******/ (() => {
|
|
196
184
|
/******/ var scriptUrl;
|
|
197
|
-
/******/ if (
|
|
198
|
-
/******/ var document =
|
|
185
|
+
/******/ if (globalThis.importScripts) scriptUrl = globalThis.location + "";
|
|
186
|
+
/******/ var document = globalThis.document;
|
|
199
187
|
/******/ if (!scriptUrl && document) {
|
|
200
188
|
/******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
|
|
201
189
|
/******/ scriptUrl = document.currentScript.src;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.plugin.poisson.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={303(t){t.exports=e}},i={};function n(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,n),r.exports}n.m=o,n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>e+".min.js",n.
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(e=>(()=>{var t,r,o={303(t){t.exports=e}},i={};function n(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}};return o[e](r,r.exports,n),r.exports}n.m=o,n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce(((t,r)=>(n.f[r](e,t),t)),[])),n.u=e=>e+".min.js",n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),t={},r="@tsparticles/plugin-poisson-disc:",n.l=(e,o,i,a)=>{if(t[e])t[e].push(o);else{var s,l;if(void 0!==i)for(var p=document.getElementsByTagName("script"),c=0;c<p.length;c++){var u=p[c];if(u.getAttribute("src")==e||u.getAttribute("data-webpack")==r+i){s=u;break}}s||(l=!0,(s=document.createElement("script")).charset="utf-8",n.nc&&s.setAttribute("nonce",n.nc),s.setAttribute("data-webpack",r+i),s.src=e),t[e]=[o];var d=(r,o)=>{s.onerror=s.onload=null,clearTimeout(f);var i=t[e];if(delete t[e],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach((e=>e(o))),r)return r(o)},f=setTimeout(d.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=d.bind(null,s.onerror),s.onload=d.bind(null,s.onload),l&&document.head.appendChild(s)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var t=globalThis.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&(!e||!/^http(s?):/.test(e));)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),(()=>{var e={189:0};n.f.j=(t,r)=>{var o=n.o(e,t)?e[t]:void 0;if(0!==o)if(o)r.push(o[2]);else{var i=new Promise(((r,i)=>o=e[t]=[r,i]));r.push(o[2]=i);var a=n.p+n.u(t),s=new Error;n.l(a,(r=>{if(n.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var i=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;s.message="Loading chunk "+t+" failed.\n("+i+": "+a+")",s.name="ChunkLoadError",s.type=i,s.request=a,o[1](s)}}),"chunk-"+t,t)}};var t=(t,r)=>{var o,i,[a,s,l]=r,p=0;if(a.some((t=>0!==e[t]))){for(o in s)n.o(s,o)&&(n.m[o]=s[o]);if(l)l(n)}for(t&&t(r);p<a.length;p++)i=a[p],n.o(e,i)&&e[i]&&e[i][0](),e[i]=0},r=this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var a={};function s(e){e.checkVersion("4.0.0-alpha.4"),e.register((async e=>{const{PoissonDiscPlugin:t}=await n.e(879).then(n.bind(n,879));e.addPlugin(new t)}))}return n.r(a),n.d(a,{loadPoissonDiscPlugin:()=>s}),a})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Poisson Disc Plugin v4.0.0-alpha.
|
|
1
|
+
/*! tsParticles Poisson Disc Plugin v4.0.0-alpha.4 by Matteo Bruni */
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { type Container, type IPlugin, type RecursivePartial } from "@tsparticles/engine";
|
|
1
|
+
import { type Container, type IContainerPlugin, type IPlugin, type RecursivePartial } from "@tsparticles/engine";
|
|
2
2
|
import type { IPoissonOptions, PoissonOptions } from "./types.js";
|
|
3
|
-
import { PoissonInstance } from "./PoissonInstance.js";
|
|
4
3
|
export declare class PoissonDiscPlugin implements IPlugin {
|
|
5
4
|
readonly id: string;
|
|
6
5
|
constructor();
|
|
7
|
-
getPlugin(container: Container): Promise<
|
|
8
|
-
loadOptions(options: PoissonOptions, source?: RecursivePartial<IPoissonOptions>): void;
|
|
6
|
+
getPlugin(container: Container): Promise<IContainerPlugin>;
|
|
7
|
+
loadOptions(_container: Container, options: PoissonOptions, source?: RecursivePartial<IPoissonOptions>): void;
|
|
9
8
|
needsPlugin(options?: RecursivePartial<IPoissonOptions>): boolean;
|
|
10
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type IContainerPlugin, type ICoordinates } from "@tsparticles/engine";
|
|
2
2
|
import type { PoissonContainer } from "./types.js";
|
|
3
3
|
import { PoissonDisc } from "./PoissonDisc.js";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class PoissonDiscPluginInstance implements IContainerPlugin {
|
|
5
5
|
poissonDisc?: PoissonDisc;
|
|
6
6
|
redrawTimeout?: number | NodeJS.Timeout;
|
|
7
7
|
private readonly _container;
|
package/umd/PoissonDisc.js
CHANGED
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.PoissonDisc = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const double = 2, doublePI = Math.PI * double;
|
|
15
14
|
class PoissonDisc {
|
|
16
15
|
constructor(size, radius, retries, dimensions, firstPoint) {
|
|
17
16
|
this.size = { ...size };
|
|
@@ -90,7 +89,7 @@
|
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
91
|
_getNewPoint(currentPoint, tries) {
|
|
93
|
-
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * double), offset = {
|
|
92
|
+
const minCoordinate = 0, gridMinValue = 0, maxNeighbourIndex = 1, newAngle = tries * (engine_1.doublePI / this.retries), newDist = this.getRandom(this.radius, this.radius * engine_1.double), offset = {
|
|
94
93
|
x: Math.cos(newAngle) * newDist,
|
|
95
94
|
y: Math.sin(newAngle) * newDist,
|
|
96
95
|
}, newPoint = {
|
package/umd/PoissonDiscPlugin.js
CHANGED
|
@@ -1,25 +1,59 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
+
var ownKeys = function(o) {
|
|
19
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
+
var ar = [];
|
|
21
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
+
return ar;
|
|
23
|
+
};
|
|
24
|
+
return ownKeys(o);
|
|
25
|
+
};
|
|
26
|
+
return function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
1
34
|
(function (factory) {
|
|
2
35
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
36
|
var v = factory(require, exports);
|
|
4
37
|
if (v !== undefined) module.exports = v;
|
|
5
38
|
}
|
|
6
39
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Options/Classes/Poisson.js"
|
|
40
|
+
define(["require", "exports", "./Options/Classes/Poisson.js"], factory);
|
|
8
41
|
}
|
|
9
42
|
})(function (require, exports) {
|
|
10
43
|
"use strict";
|
|
44
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
46
|
exports.PoissonDiscPlugin = void 0;
|
|
13
47
|
const Poisson_js_1 = require("./Options/Classes/Poisson.js");
|
|
14
|
-
const PoissonInstance_js_1 = require("./PoissonInstance.js");
|
|
15
48
|
class PoissonDiscPlugin {
|
|
16
49
|
constructor() {
|
|
17
50
|
this.id = "poisson";
|
|
18
51
|
}
|
|
19
|
-
getPlugin(container) {
|
|
20
|
-
|
|
52
|
+
async getPlugin(container) {
|
|
53
|
+
const { PoissonDiscPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PoissonDiscPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./PoissonDiscPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
|
|
54
|
+
return new PoissonDiscPluginInstance(container);
|
|
21
55
|
}
|
|
22
|
-
loadOptions(options, source) {
|
|
56
|
+
loadOptions(_container, options, source) {
|
|
23
57
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
24
58
|
return;
|
|
25
59
|
}
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.PoissonDiscPluginInstance = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const PoissonDisc_js_1 = require("./PoissonDisc.js");
|
|
15
|
-
class
|
|
15
|
+
class PoissonDiscPluginInstance {
|
|
16
16
|
constructor(container) {
|
|
17
17
|
this._container = container;
|
|
18
18
|
this._currentIndex = 0;
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
exports.
|
|
67
|
+
exports.PoissonDiscPluginInstance = PoissonDiscPluginInstance;
|
|
68
68
|
});
|
package/umd/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
|
|
47
47
|
function loadPoissonDiscPlugin(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-alpha.
|
|
48
|
+
engine.checkVersion("4.0.0-alpha.4");
|
|
49
49
|
engine.register(async (e) => {
|
|
50
50
|
const { PoissonDiscPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./PoissonDiscPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./PoissonDiscPlugin.js"], resolve_1, reject_1); }).then(__importStar));
|
|
51
51
|
e.addPlugin(new PoissonDiscPlugin());
|
package/295.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 295.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[295],{295(i,s,t){t.d(s,{PoissonDiscPlugin:()=>a});var e=t(303);class o{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(i){(0,e.isNull)(i)||(void 0!==i.enable&&(this.enable=i.enable),void 0!==i.dimensions&&(this.dimensions=i.dimensions),void 0!==i.radius&&(this.radius=i.radius),void 0!==i.retries&&(this.retries=i.retries))}}const n=2*Math.PI;class h{constructor(i,s,t,e,o){this.size={...i},this.radius=s,this.retries=t,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=o?{...o}:void 0,this.reset()}addPoint(i){const s={position:{...i},gridPosition:{x:Math.floor(i.x/this.cellSize),y:Math.floor(i.y/this.cellSize)}},t=this.points.length,e=this.grid[s.gridPosition.y];e&&(this.points.push(s),e[s.gridPosition.x]=t,this.active.push(t))}getRandom(i,s){return Math.floor((0,e.getRandom)()*(s-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];const s=this.grid[i];if(s)for(let i=0;i<=this.cols;i++)s[i]=-1}}reset(){if(this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint)this.addPoint(this.firstPoint);else{const i=0;this.addPoint({x:this.getRandom(i,this.size.width),y:this.getRandom(i,this.size.height)})}}async run(){this.reset();for(;this.active.length>0;)await this.steps(1)}async steps(i){for(let s=0;s<i;s++)this.active.length<=0||await this._step()}_getNewPoint(i,s){const t=s*(n/this.retries),o=this.getRandom(this.radius,2*this.radius),h=Math.cos(t)*o,r=Math.sin(t)*o,a={x:Math.floor(i.position.x+h),y:Math.floor(i.position.y+r)},c=Math.floor(a.x/this.cellSize),l=Math.floor(a.y/this.cellSize);if(a.x>0&&a.x<this.size.width&&a.y>0&&a.y<this.size.height){{const i=this.grid[l];if(!i)return;const s=i[c];if(void 0===s)return;if(!(s<0))return;for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){const o={x:c+t,y:l+i};if(o.x>=0&&o.y>=0&&o.x<this.cols&&o.y<this.rows&&(o.x!==c||o.y!==l)&&s>=0){const i=s,t=this.points[i];if(!t)continue;if((0,e.getDistance)(a,t.position)<this.radius)return}}}return a}}async _step(){const i=this.getRandom(0,this.active.length);return new Promise((s=>{let t=!1;for(let s=0;s<this.retries;s++){const e=this.active[i];if(void 0===e)continue;const o=this.points[e];if(!o)continue;const n=this._getNewPoint(o,s);if(n){t=!0,this.addPoint(n);break}}if(!t){const s=1;this.active.splice(i,s)}s()}))}}class r{constructor(i){this._container=i,this._currentIndex=0}async init(){await this._initData()}particlePosition(i){const s=this._container.actualOptions.poisson;if(this.poissonDisc&&s?.enable&&!(this._currentIndex>=this.poissonDisc.points.length))return i??this.poissonDisc.points[this._currentIndex++]?.position}resize(){const i=this._container,s=i.actualOptions.poisson;if(!s?.enable)return;this.redrawTimeout&&clearTimeout(this.redrawTimeout);this.redrawTimeout=setTimeout((()=>{(async()=>{await this._initData(),await i.particles.redraw()})()}),250)}stop(){delete this.poissonDisc}async _initData(){const i=this._container,s=i.actualOptions.poisson,t=i.actualOptions.particles,o=i.canvas.size,n=i.retina.pixelRatio;if(!s?.enable)return;this._currentIndex=0,this.poissonDisc=new h(o,s.radius?s.radius*n:Math.max((0,e.getRangeMax)(t.size.value)*n,Math.sqrt(o.width*o.height/t.number.value)),s.retries,s.dimensions);s.steps>0?await this.poissonDisc.steps(s.steps):await this.poissonDisc.run()}}class a{constructor(){this.id="poisson"}getPlugin(i){return Promise.resolve(new r(i))}loadOptions(i,s){if(!this.needsPlugin(i)&&!this.needsPlugin(s))return;let t=i.poisson;void 0===t?.load&&(i.poisson=t=new o),t.load(s?.poisson)}needsPlugin(i){return i?.poisson?.enable??!1}}}}]);
|
package/295.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Poisson Disc Plugin v4.0.0-alpha.2 by Matteo Bruni */
|