@tsparticles/plugin-poisson-disc 4.0.0-beta.0 → 4.0.0-beta.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/284.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[284],{284(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([[960],{960(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(56).then(t.bind(t,56));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()}}}}]);
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[324],{324(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(284).then(t.bind(t,284));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()}}}}]);
@@ -1 +1 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[964],{964(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(960).then(e.bind(e,960));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}}}}]);
1
+ "use strict";(this.webpackChunk_tsparticles_plugin_poisson_disc=this.webpackChunk_tsparticles_plugin_poisson_disc||[]).push([[898],{898(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(324).then(e.bind(e,324));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/browser/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export async function loadPoissonDiscPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.1");
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.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.1");
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
  }
@@ -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-beta.0
7
+ * v4.0.0-beta.1
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -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-beta.0
7
+ * v4.0.0-beta.1
8
8
  */
9
9
  "use strict";
10
10
  /*
@@ -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-beta.0
7
+ * v4.0.0-beta.1
8
8
  */
9
9
  "use strict";
10
10
  /*
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export async function loadPoissonDiscPlugin(engine) {
2
- engine.checkVersion("4.0.0-beta.0");
3
- await engine.register(async (e) => {
2
+ engine.checkVersion("4.0.0-beta.1");
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.0",
3
+ "version": "4.0.0-beta.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": "4.0.0-beta.0"
88
+ "@tsparticles/engine": "4.0.0-beta.1"
89
89
  },
90
90
  "publishConfig": {
91
91
  "access": "public"