@tsparticles/plugin-poisson-disc 4.0.0-beta.0 → 4.0.0-beta.10
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/{964.min.js → 117.min.js} +1 -1
- package/253.min.js +1 -0
- package/{960.min.js → 429.min.js} +1 -1
- package/README.md +22 -0
- package/browser/index.js +3 -3
- package/cjs/index.js +3 -3
- package/dist_browser_PoissonDiscPluginInstance_js.js +1 -1
- package/dist_browser_PoissonDiscPlugin_js.js +1 -1
- package/dist_browser_PoissonDisc_js.js +1 -1
- package/esm/index.js +3 -3
- package/package.json +4 -5
- package/report.html +84 -29
- package/tsparticles.plugin.poisson.js +2 -2
- package/tsparticles.plugin.poisson.min.js +2 -2
- package/types/PoissonDiscPluginInstance.d.ts +1 -1
- package/56.min.js +0 -1
- package/umd/Interfaces/IPoissonPoint.js +0 -12
- package/umd/Options/Classes/Poisson.js +0 -46
- package/umd/Options/Interfaces/IPoisson.js +0 -12
- package/umd/PoissonDisc.js +0 -190
- package/umd/PoissonDiscPlugin.js +0 -69
- package/umd/PoissonDiscPluginInstance.js +0 -109
- package/umd/index.js +0 -54
- package/umd/types.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[117],{117(s,i,e){e.d(i,{PoissonDiscPlugin:()=>o});var n=e(303);class t{dimensions;enable;radius;retries;steps;constructor(){this.enable=!1,this.dimensions=2,this.radius=0,this.retries=30,this.steps=0}load(s){(0,n.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 o{id="poisson";async getPlugin(s){let{PoissonDiscPluginInstance:i}=await e.e(429).then(e.bind(e,429));return new i(s)}loadOptions(s,i,e){if(!this.needsPlugin(i)&&!this.needsPlugin(e))return;let n=i.poisson;n?.load===void 0&&(i.poisson=n=new t),n.load(e?.poisson)}needsPlugin(s){return s?.poisson?.enable??!1}}}}]);
|
package/253.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[253],{253(i,t,s){s.d(t,{PoissonDisc:()=>h});var e=s(303);class h{active;cellSize;cols;dimensions;firstPoint;grid;points;radius;retries;rows;size;constructor(i,t,s,e,h){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=h?{...h}:void 0,this.reset()}addPoint(i){let 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]=[];let t=this.grid[i];if(t)for(let i=0;i<=this.cols;i++)t[i]=-1}}reset(){this.points=[],this.active=[],this.grid=[],this.initialiseGrid(),this.firstPoint?this.addPoint(this.firstPoint):this.addPoint({x:this.getRandom(0,this.size.width),y:this.getRandom(0,this.size.height)})}async run(){this.reset();let i=0;for(;this.active.length>0;)this.steps(1),++i%100==0&&await new Promise(i=>setTimeout(i))}steps(i){for(let t=0;t<i;t++)this.active.length<=0||this._step()}_getNewPoint(i,t){let s=t*(e.doublePI/this.retries),h=this.getRandom(this.radius,this.radius*e.double),o={x:Math.cos(s)*h,y:Math.sin(s)*h},r={x:Math.floor(i.position.x+o.x),y:Math.floor(i.position.y+o.y)},n={x:Math.floor(r.x/this.cellSize),y:Math.floor(r.y/this.cellSize)};if(r.x<=0||r.x>=this.size.width||r.y<=0||r.y>=this.size.height)return;let l=this.grid[n.y];if(!l)return;let a=l[n.x];if(void 0!==a&&!(a>=0)){for(let i=-1;i<=1;i++)for(let t=-1;t<=1;t++){if(!i&&!t)continue;let s={x:n.x+t,y:n.y+i};if(s.x<0||s.y<0||s.x>=this.cols||s.y>=this.rows)continue;let h=this.grid[s.y]?.[s.x];if(void 0===h||h<0)continue;let o=this.points[h];if(o&&(0,e.getDistance)(r,o.position)<this.radius)return}return r}}_step(){let i=this.getRandom(0,this.active.length),t=!1;for(let s=0;s<this.retries;s++){let e=this.active[i];if(void 0===e)continue;let h=this.points[e];if(!h)continue;let o=this._getNewPoint(h,s);if(o){t=!0,this.addPoint(o);break}}t||this.active.splice(i,1)}}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[429],{429(i,s,t){t.d(s,{PoissonDiscPluginInstance:()=>n});var e=t(303);class n{poissonDisc;redrawTimeout;_container;_currentIndex;constructor(i){this._container=i,this._currentIndex=0}async init(){await this._initData()}particlePosition(i){let 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(){let i=this._container,s=i.actualOptions.poisson;s?.enable&&(this.redrawTimeout&&clearTimeout(this.redrawTimeout),this.redrawTimeout=setTimeout(()=>{(async()=>{this._container.destroyed||(await this._initData(),await i.particles.redraw())})()},250))}stop(){delete this.poissonDisc}async _initData(){let i=this._container,s=i.actualOptions.poisson,n=i.actualOptions.particles,a=i.canvas.size,o=i.retina.pixelRatio;if(!s?.enable)return;this._currentIndex=0;let{PoissonDisc:r}=await t.e(253).then(t.bind(t,253));this.poissonDisc=new r(a,s.radius?s.radius*o:Math.max((0,e.getRangeMax)(n.size.value)*o,Math.sqrt(a.width*a.height/n.number.value)),s.retries,s.dimensions),s.steps>0?this.poissonDisc.steps(s.steps):await this.poissonDisc.run()}}}}]);
|
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/tsparticles/tsparticles) plugin for particles poisson disc effect.
|
|
10
10
|
|
|
11
|
+
## Quick checklist
|
|
12
|
+
|
|
13
|
+
1. Install `@tsparticles/engine` (or use the CDN bundle below)
|
|
14
|
+
2. Call the package loader function(s) before `tsParticles.load(...)`
|
|
15
|
+
3. Apply the package options in your `tsParticles.load(...)` config
|
|
16
|
+
|
|
11
17
|
## How to use it
|
|
12
18
|
|
|
13
19
|
### CDN / Vanilla JS / jQuery
|
|
@@ -72,3 +78,19 @@ import { loadPoissonDiscPlugin } from "@tsparticles/plugin-poisson";
|
|
|
72
78
|
await loadPoissonDiscPlugin(tsParticles);
|
|
73
79
|
})();
|
|
74
80
|
```
|
|
81
|
+
|
|
82
|
+
## Option mapping
|
|
83
|
+
|
|
84
|
+
- This package primarily extends runtime behavior or rendering and may not expose a single dedicated root options key.
|
|
85
|
+
- Use the usage example in this README and combine with the nearest options section in the docs.
|
|
86
|
+
|
|
87
|
+
## Common pitfalls
|
|
88
|
+
|
|
89
|
+
- Calling `tsParticles.load(...)` before `loadPoissonDiscPlugin(...)`
|
|
90
|
+
- Verify required peer packages before enabling advanced options
|
|
91
|
+
- Change one option group at a time to isolate regressions quickly
|
|
92
|
+
|
|
93
|
+
## Related docs
|
|
94
|
+
|
|
95
|
+
- All packages catalog: <https://github.com/tsparticles/tsparticles>
|
|
96
|
+
- Main docs: <https://particles.js.org/docs/>
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(async (e) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
|
-
e.addPlugin(new PoissonDiscPlugin());
|
|
5
|
+
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
6
6
|
});
|
|
7
7
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(async (e) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
|
-
e.addPlugin(new PoissonDiscPlugin());
|
|
5
|
+
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
6
6
|
});
|
|
7
7
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export async function loadPoissonDiscPlugin(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(async (e) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
4
|
const { PoissonDiscPlugin } = await import("./PoissonDiscPlugin.js");
|
|
5
|
-
e.addPlugin(new PoissonDiscPlugin());
|
|
5
|
+
e.pluginManager.addPlugin(new PoissonDiscPlugin());
|
|
6
6
|
});
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-poisson-disc",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"description": "tsParticles poisson disc plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -79,13 +79,12 @@
|
|
|
79
79
|
"browser": "./browser/index.js",
|
|
80
80
|
"import": "./esm/index.js",
|
|
81
81
|
"require": "./cjs/index.js",
|
|
82
|
-
"
|
|
83
|
-
"default": "./cjs/index.js"
|
|
82
|
+
"default": "./esm/index.js"
|
|
84
83
|
},
|
|
85
84
|
"./package.json": "./package.json"
|
|
86
85
|
},
|
|
87
|
-
"
|
|
88
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
86
|
+
"peerDependencies": {
|
|
87
|
+
"@tsparticles/engine": "4.0.0-beta.10"
|
|
89
88
|
},
|
|
90
89
|
"publishConfig": {
|
|
91
90
|
"access": "public"
|