@tsparticles/plugin-poisson-disc 3.8.1 → 3.9.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/PoissonInstance.js +1 -1
- package/browser/index.js +1 -1
- package/cjs/PoissonInstance.js +1 -1
- package/cjs/index.js +1 -1
- package/esm/PoissonInstance.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.plugin.poisson.js +6 -6
- package/tsparticles.plugin.poisson.min.js +1 -1
- package/tsparticles.plugin.poisson.min.js.LICENSE.txt +1 -1
- package/types/PoissonInstance.d.ts +1 -1
- package/umd/PoissonInstance.js +1 -1
- package/umd/index.js +1 -1
|
@@ -25,7 +25,7 @@ export class PoissonInstance {
|
|
|
25
25
|
clearTimeout(this.redrawTimeout);
|
|
26
26
|
}
|
|
27
27
|
const timeout = 250;
|
|
28
|
-
this.redrawTimeout =
|
|
28
|
+
this.redrawTimeout = setTimeout(() => {
|
|
29
29
|
void (async () => {
|
|
30
30
|
await this._initData();
|
|
31
31
|
await container.particles.redraw();
|
package/browser/index.js
CHANGED
package/cjs/PoissonInstance.js
CHANGED
|
@@ -28,7 +28,7 @@ class PoissonInstance {
|
|
|
28
28
|
clearTimeout(this.redrawTimeout);
|
|
29
29
|
}
|
|
30
30
|
const timeout = 250;
|
|
31
|
-
this.redrawTimeout =
|
|
31
|
+
this.redrawTimeout = setTimeout(() => {
|
|
32
32
|
void (async () => {
|
|
33
33
|
await this._initData();
|
|
34
34
|
await container.particles.redraw();
|
package/cjs/index.js
CHANGED
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
|
|
4
4
|
const PoissonDiscPlugin_js_1 = require("./PoissonDiscPlugin.js");
|
|
5
5
|
async function loadPoissonDiscPlugin(engine, refresh = true) {
|
|
6
|
-
engine.checkVersion("3.
|
|
6
|
+
engine.checkVersion("3.9.1");
|
|
7
7
|
await engine.addPlugin(new PoissonDiscPlugin_js_1.PoissonDiscPlugin(engine), refresh);
|
|
8
8
|
}
|
package/esm/PoissonInstance.js
CHANGED
|
@@ -25,7 +25,7 @@ export class PoissonInstance {
|
|
|
25
25
|
clearTimeout(this.redrawTimeout);
|
|
26
26
|
}
|
|
27
27
|
const timeout = 250;
|
|
28
|
-
this.redrawTimeout =
|
|
28
|
+
this.redrawTimeout = setTimeout(() => {
|
|
29
29
|
void (async () => {
|
|
30
30
|
await this._initData();
|
|
31
31
|
await container.particles.redraw();
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-poisson-disc",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
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": "3.
|
|
88
|
+
"@tsparticles/engine": "3.9.1"
|
|
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 [3 Aug 2025 at 23:37]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD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cAaTEShgrG+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
|
-
* v3.
|
|
7
|
+
* v3.9.1
|
|
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_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 */ Poisson: () => (/* binding */ Poisson)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass Poisson {\n constructor() {\n this.enable = false;\n this.dimensions = 2;\n this.radius = 0;\n this.retries = 30;\n this.steps = 0;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.dimensions !== undefined) {\n this.dimensions = data.dimensions;\n }\n if (data.radius !== undefined) {\n this.radius = data.radius;\n }\n if (data.retries !== undefined) {\n this.retries = data.retries;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/Options/Classes/Poisson.js
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Poisson: () => (/* binding */ Poisson)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n\nclass Poisson {\n constructor() {\n this.enable = false;\n this.dimensions = 2;\n this.radius = 0;\n this.retries = 30;\n this.steps = 0;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.dimensions !== undefined) {\n this.dimensions = data.dimensions;\n }\n if (data.radius !== undefined) {\n this.radius = data.radius;\n }\n if (data.retries !== undefined) {\n this.retries = data.retries;\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/Options/Classes/Poisson.js?\n}");
|
|
38
38
|
|
|
39
39
|
/***/ }),
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
44
44
|
\*************************************/
|
|
45
45
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
46
46
|
|
|
47
|
-
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/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\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 this.points.push(point);\n this.grid[point.gridPosition.y][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 for (let x = 0; x <= this.cols; x++) {\n this.grid[y][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 if (this.grid[newGridCoords.y][newGridCoords.x] < 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 (this.grid[neighbourGrid.y][neighbourGrid.x] >= gridMinValue) {\n const neighbourIndex = this.grid[neighbourGrid.y][neighbourGrid.x],\n neighbour = this.points[neighbourIndex],\n 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 newPoint = this._getNewPoint(this.points[this.active[randomActive]], 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
|
|
47
|
+
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/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\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 this.points.push(point);\n this.grid[point.gridPosition.y][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 for (let x = 0; x <= this.cols; x++) {\n this.grid[y][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 if (this.grid[newGridCoords.y][newGridCoords.x] < 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 (this.grid[neighbourGrid.y][neighbourGrid.x] >= gridMinValue) {\n const neighbourIndex = this.grid[neighbourGrid.y][neighbourGrid.x],\n neighbour = this.points[neighbourIndex],\n 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 newPoint = this._getNewPoint(this.points[this.active[randomActive]], 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}");
|
|
48
48
|
|
|
49
49
|
/***/ }),
|
|
50
50
|
|
|
@@ -54,7 +54,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
54
54
|
\*******************************************/
|
|
55
55
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
56
56
|
|
|
57
|
-
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/* harmony import */ var _PoissonInstance_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PoissonInstance.js */ \"./dist/browser/PoissonInstance.js\");\n\n\nclass PoissonDiscPlugin {\n constructor(engine) {\n this.id = \"poisson\";\n this._engine = engine;\n }\n getPlugin(container) {\n return Promise.resolve(new _PoissonInstance_js__WEBPACK_IMPORTED_MODULE_1__.PoissonInstance(container, this._engine));\n }\n loadOptions(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
|
|
57
|
+
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/* harmony import */ var _PoissonInstance_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PoissonInstance.js */ \"./dist/browser/PoissonInstance.js\");\n\n\nclass PoissonDiscPlugin {\n constructor(engine) {\n this.id = \"poisson\";\n this._engine = engine;\n }\n getPlugin(container) {\n return Promise.resolve(new _PoissonInstance_js__WEBPACK_IMPORTED_MODULE_1__.PoissonInstance(container, this._engine));\n }\n loadOptions(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}");
|
|
58
58
|
|
|
59
59
|
/***/ }),
|
|
60
60
|
|
|
@@ -64,7 +64,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
64
64
|
\*****************************************/
|
|
65
65
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
66
66
|
|
|
67
|
-
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\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, engine) {\n this._container = container;\n this._engine = engine;\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 =
|
|
67
|
+
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 _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\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, engine) {\n this._container = container;\n this._engine = engine;\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}");
|
|
68
68
|
|
|
69
69
|
/***/ }),
|
|
70
70
|
|
|
@@ -74,7 +74,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
74
74
|
\*******************************/
|
|
75
75
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
76
76
|
|
|
77
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPoissonDiscPlugin: () => (/* binding */ loadPoissonDiscPlugin)\n/* harmony export */ });\n/* harmony import */ var _PoissonDiscPlugin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PoissonDiscPlugin.js */ \"./dist/browser/PoissonDiscPlugin.js\");\n\nasync function loadPoissonDiscPlugin(engine, refresh = true) {\n engine.checkVersion(\"3.
|
|
77
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadPoissonDiscPlugin: () => (/* binding */ loadPoissonDiscPlugin)\n/* harmony export */ });\n/* harmony import */ var _PoissonDiscPlugin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./PoissonDiscPlugin.js */ \"./dist/browser/PoissonDiscPlugin.js\");\n\nasync function loadPoissonDiscPlugin(engine, refresh = true) {\n engine.checkVersion(\"3.9.1\");\n await engine.addPlugin(new _PoissonDiscPlugin_js__WEBPACK_IMPORTED_MODULE_0__.PoissonDiscPlugin(engine), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-poisson-disc/./dist/browser/index.js?\n}");
|
|
78
78
|
|
|
79
79
|
/***/ }),
|
|
80
80
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.plugin.poisson.min.js.LICENSE.txt */
|
|
2
|
-
!function(i,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 s="object"==typeof exports?t(require("@tsparticles/engine")):t(i.window);for(var e in s)("object"==typeof exports?exports:i)[e]=s[e]}}(this,(i=>(()=>{var t={303:t=>{t.exports=i}},s={};function e(i){var o=s[i];if(void 0!==o)return o.exports;var n=s[i]={exports:{}};return t[i](n,n.exports,e),n.exports}e.d=(i,t)=>{for(var s in t)e.o(t,s)&&!e.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:t[s]})},e.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),e.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var o={};e.r(o),e.d(o,{loadPoissonDiscPlugin:()=>d});var n=e(303);class r{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(i){(0,n.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 a=2*Math.PI;class h{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;this.points.push(t),this.grid[t.gridPosition.y][t.gridPosition.x]=s,this.active.push(s)}getRandom(i,t){return Math.floor((0,n.getRandom)()*(t-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];for(let t=0;t<=this.cols;t++)this.grid[i][t]=-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*(a/this.retries),e=this.getRandom(this.radius,2*this.radius),o=Math.cos(s)*e,r=Math.sin(s)*e,h={x:Math.floor(i.position.x+o),y:Math.floor(i.position.y+r)},l=Math.floor(h.x/this.cellSize),c=Math.floor(h.y/this.cellSize);if(h.x>0&&h.x<this.size.width&&h.y>0&&h.y<this.size.height&&this.grid[c][l]<0){for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){const s={x:l+t,y:c+i};if(s.x>=0&&s.y>=0&&s.x<this.cols&&s.y<this.rows&&(s.x!==l||s.y!==c)&&this.grid[s.y][s.x]>=0){const i=this.grid[s.y][s.x],t=this.points[i];if((0,n.getDistance)(h,t.position)<this.radius)return}}return h}}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._getNewPoint(this.points[this.active[i]],t);if(e){s=!0,this.addPoint(e);break}}if(!s){const t=1;this.active.splice(i,t)}t()}))}}class l{constructor(i,t){this._container=i,this._engine=t,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=
|
|
2
|
+
!function(i,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 s="object"==typeof exports?t(require("@tsparticles/engine")):t(i.window);for(var e in s)("object"==typeof exports?exports:i)[e]=s[e]}}(this,(i=>(()=>{var t={303:t=>{t.exports=i}},s={};function e(i){var o=s[i];if(void 0!==o)return o.exports;var n=s[i]={exports:{}};return t[i](n,n.exports,e),n.exports}e.d=(i,t)=>{for(var s in t)e.o(t,s)&&!e.o(i,s)&&Object.defineProperty(i,s,{enumerable:!0,get:t[s]})},e.o=(i,t)=>Object.prototype.hasOwnProperty.call(i,t),e.r=i=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(i,"__esModule",{value:!0})};var o={};e.r(o),e.d(o,{loadPoissonDiscPlugin:()=>d});var n=e(303);class r{constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(i){(0,n.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 a=2*Math.PI;class h{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;this.points.push(t),this.grid[t.gridPosition.y][t.gridPosition.x]=s,this.active.push(s)}getRandom(i,t){return Math.floor((0,n.getRandom)()*(t-i))+i}initialiseGrid(){for(let i=0;i<=this.rows;i++){this.grid[i]=[];for(let t=0;t<=this.cols;t++)this.grid[i][t]=-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*(a/this.retries),e=this.getRandom(this.radius,2*this.radius),o=Math.cos(s)*e,r=Math.sin(s)*e,h={x:Math.floor(i.position.x+o),y:Math.floor(i.position.y+r)},l=Math.floor(h.x/this.cellSize),c=Math.floor(h.y/this.cellSize);if(h.x>0&&h.x<this.size.width&&h.y>0&&h.y<this.size.height&&this.grid[c][l]<0){for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){const s={x:l+t,y:c+i};if(s.x>=0&&s.y>=0&&s.x<this.cols&&s.y<this.rows&&(s.x!==l||s.y!==c)&&this.grid[s.y][s.x]>=0){const i=this.grid[s.y][s.x],t=this.points[i];if((0,n.getDistance)(h,t.position)<this.radius)return}}return h}}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._getNewPoint(this.points[this.active[i]],t);if(e){s=!0,this.addPoint(e);break}}if(!s){const t=1;this.active.splice(i,t)}t()}))}}class l{constructor(i,t){this._container=i,this._engine=t,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,e=i.canvas.size,o=i.retina.pixelRatio;if(!t?.enable)return;this._currentIndex=0,this.poissonDisc=new h(e,t.radius?t.radius*o:Math.max((0,n.getRangeMax)(s.size.value)*o,Math.sqrt(e.width*e.height/s.number.value)),t.retries,t.dimensions);t.steps>0?await this.poissonDisc.steps(t.steps):await this.poissonDisc.run()}}class c{constructor(i){this.id="poisson",this._engine=i}getPlugin(i){return Promise.resolve(new l(i,this._engine))}loadOptions(i,t){if(!this.needsPlugin(i)&&!this.needsPlugin(t))return;let s=i.poisson;void 0===s?.load&&(i.poisson=s=new r),s.load(t?.poisson)}needsPlugin(i){return i?.poisson?.enable??!1}}async function d(i,t=!0){i.checkVersion("3.9.1"),await i.addPlugin(new c(i),t)}return o})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Poisson Disc Plugin v3.
|
|
1
|
+
/*! tsParticles Poisson Disc Plugin v3.9.1 by Matteo Bruni */
|
|
@@ -3,7 +3,7 @@ import type { PoissonContainer } from "./types.js";
|
|
|
3
3
|
import { PoissonDisc } from "./PoissonDisc.js";
|
|
4
4
|
export declare class PoissonInstance implements IContainerPlugin {
|
|
5
5
|
poissonDisc?: PoissonDisc;
|
|
6
|
-
redrawTimeout?: number;
|
|
6
|
+
redrawTimeout?: number | NodeJS.Timeout;
|
|
7
7
|
private readonly _container;
|
|
8
8
|
private _currentIndex;
|
|
9
9
|
private readonly _engine;
|
package/umd/PoissonInstance.js
CHANGED
package/umd/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports.loadPoissonDiscPlugin = loadPoissonDiscPlugin;
|
|
13
13
|
const PoissonDiscPlugin_js_1 = require("./PoissonDiscPlugin.js");
|
|
14
14
|
async function loadPoissonDiscPlugin(engine, refresh = true) {
|
|
15
|
-
engine.checkVersion("3.
|
|
15
|
+
engine.checkVersion("3.9.1");
|
|
16
16
|
await engine.addPlugin(new PoissonDiscPlugin_js_1.PoissonDiscPlugin(engine), refresh);
|
|
17
17
|
}
|
|
18
18
|
});
|