@tsparticles/plugin-emitters 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/{803.min.js → 100.min.js} +1 -1
- package/106.min.js +1 -0
- package/443.min.js +1 -0
- package/475.min.js +1 -0
- package/{588.min.js → 515.min.js} +1 -1
- package/746.min.js +1 -0
- package/{526.min.js → 812.min.js} +1 -1
- package/903.min.js +1 -0
- package/README.md +27 -0
- package/browser/EmitterInstance.js +39 -43
- package/browser/EmittersInstancesManager.js +4 -4
- package/browser/addEmittersShapesManager.js +7 -0
- package/browser/ensureEmittersPluginLoaded.js +5 -0
- package/browser/getEmittersInstancesManager.js +15 -0
- package/browser/index.js +5 -24
- package/browser/interaction.js +18 -0
- package/browser/plugin.js +14 -0
- package/cjs/EmitterInstance.js +39 -43
- package/cjs/EmittersInstancesManager.js +4 -4
- package/cjs/addEmittersShapesManager.js +7 -0
- package/cjs/ensureEmittersPluginLoaded.js +5 -0
- package/cjs/getEmittersInstancesManager.js +15 -0
- package/cjs/index.js +5 -24
- package/cjs/interaction.js +18 -0
- package/cjs/plugin.js +14 -0
- package/dist_browser_EmitterInstance_js.js +2 -2
- package/dist_browser_EmittersInstancesManager_js.js +2 -2
- package/dist_browser_EmittersInteractor_js.js +1 -1
- package/dist_browser_EmittersPluginInstance_js.js +1 -1
- package/dist_browser_EmittersPlugin_js.js +1 -1
- package/dist_browser_ShapeManager_js.js +1 -1
- package/dist_browser_addEmittersShapesManager_js.js +30 -0
- package/dist_browser_getEmittersInstancesManager_js.js +30 -0
- package/esm/EmitterInstance.js +39 -43
- package/esm/EmittersInstancesManager.js +4 -4
- package/esm/addEmittersShapesManager.js +7 -0
- package/esm/ensureEmittersPluginLoaded.js +5 -0
- package/esm/getEmittersInstancesManager.js +15 -0
- package/esm/index.js +5 -24
- package/esm/interaction.js +18 -0
- package/esm/plugin.js +14 -0
- package/package.json +24 -6
- package/report.html +84 -29
- package/tsparticles.plugin.emitters.js +32 -2
- package/tsparticles.plugin.emitters.min.js +2 -2
- package/types/EmitterInstance.d.ts +5 -5
- package/types/EmittersEngine.d.ts +5 -2
- package/types/EmittersInstancesManager.d.ts +3 -3
- package/types/addEmittersShapesManager.d.ts +2 -0
- package/types/ensureEmittersPluginLoaded.d.ts +2 -0
- package/types/getEmittersInstancesManager.d.ts +3 -0
- package/types/index.d.ts +1 -1
- package/types/interaction.d.ts +9 -0
- package/types/plugin.d.ts +9 -0
- package/772.min.js +0 -1
- package/784.min.js +0 -1
- package/795.min.js +0 -1
- package/umd/EmitterContainer.js +0 -12
- package/umd/EmitterInstance.js +0 -366
- package/umd/EmitterShapeBase.js +0 -30
- package/umd/EmittersEngine.js +0 -12
- package/umd/EmittersInstancesManager.js +0 -119
- package/umd/EmittersInteractor.js +0 -130
- package/umd/EmittersPlugin.js +0 -80
- package/umd/EmittersPluginInstance.js +0 -58
- package/umd/Enums/EmitterClickMode.js +0 -17
- package/umd/IEmitterShape.js +0 -12
- package/umd/IEmitterShapeGenerator.js +0 -12
- package/umd/IRandomPositionData.js +0 -12
- package/umd/Options/Classes/Emitter.js +0 -93
- package/umd/Options/Classes/EmitterLife.js +0 -41
- package/umd/Options/Classes/EmitterRate.js +0 -34
- package/umd/Options/Classes/EmitterShape.js +0 -38
- package/umd/Options/Classes/EmitterShapeReplace.js +0 -34
- package/umd/Options/Classes/EmitterSize.js +0 -39
- package/umd/Options/Classes/EmitterSpawn.js +0 -32
- package/umd/Options/Interfaces/IEmitter.js +0 -12
- package/umd/Options/Interfaces/IEmitterLife.js +0 -12
- package/umd/Options/Interfaces/IEmitterRate.js +0 -12
- package/umd/Options/Interfaces/IEmitterShape.js +0 -12
- package/umd/Options/Interfaces/IEmitterShapeReplace.js +0 -12
- package/umd/Options/Interfaces/IEmitterSize.js +0 -12
- package/umd/Options/Interfaces/IEmitterSpawn.js +0 -12
- package/umd/ShapeManager.js +0 -28
- package/umd/constants.js +0 -17
- package/umd/index.js +0 -79
- package/umd/types.js +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[100],{100(t,a,e){e.d(a,{EmittersPluginInstance:()=>n});var i=e(303);class n{container;_instancesManager;constructor(t,a){this.container=a,this._instancesManager=t,this._instancesManager.initContainer(a)}async init(){let t=this.container.actualOptions.emitters;if((0,i.isArray)(t))for(let a of t)await this._instancesManager.addEmitter(this.container,a);else await this._instancesManager.addEmitter(this.container,t)}pause(){for(let t of this._instancesManager.getArray(this.container))t.pause()}play(){for(let t of this._instancesManager.getArray(this.container))t.play()}resize(){for(let t of this._instancesManager.getArray(this.container))t.resize()}stop(){this._instancesManager.clear(this.container)}update(t){this._instancesManager.getArray(this.container).forEach(a=>{a.update(t)})}}}}]);
|
package/106.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[106],{106(e,t,a){async function r(e){let{ShapeManager:t}=await a.e(443).then(a.bind(a,443)),r=e.pluginManager;r.emitterShapeManager??=new t,r.addEmitterShapeGenerator??=(e,t)=>{r.emitterShapeManager?.addShapeGenerator(e,t)}}a.r(t),a.d(t,{addEmittersShapesManager:()=>r})}}]);
|
package/443.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[443],{443(e,t,r){r.d(t,{ShapeManager:()=>s});let a=new Map;class s{addShapeGenerator(e,t){this.getShapeGenerator(e)||a.set(e,t)}getShapeGenerator(e){return a.get(e)}getSupportedShapeGenerators(){return a.keys()}}}}]);
|
package/475.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[475],{475(t,i,e){e.d(i,{EmittersInstancesManager:()=>a});var s=e(303),o=e(442);class a{_containerArrays;_pluginManager;constructor(t){this._containerArrays=new Map,this._pluginManager=t}async addEmitter(t,i,s){let a=new o.v;a.load(i);let{EmitterInstance:l}=await e.e(746).then(e.bind(e,746)),r=new l(this._pluginManager,t,i=>{this.removeEmitter(t,i)},a,s);return await r.init(),this.getArray(t).push(r),r}clear(t){this.initContainer(t),this._containerArrays.set(t,[])}getArray(t){this.initContainer(t);let i=this._containerArrays.get(t);return i||(i=[],this._containerArrays.set(t,i)),i}initContainer(t){this._containerArrays.has(t)||(this._containerArrays.set(t,[]),t.getEmitter=i=>{let e=this.getArray(t);return void 0===i||(0,s.isNumber)(i)?e[i??0]:e.find(t=>t.name===i)},t.addEmitter=async(i,e)=>this.addEmitter(t,i,e),t.removeEmitter=i=>{let e=t.getEmitter?.(i);e&&this.removeEmitter(t,e)},t.playEmitter=i=>{let e=t.getEmitter?.(i);e&&e.externalPlay()},t.pauseEmitter=i=>{let e=t.getEmitter?.(i);e&&e.externalPause()})}removeEmitter(t,i){let e=this.getArray(t).indexOf(i);e>=0&&this.getArray(t).splice(e,1)}}},442(t,i,e){e.d(i,{v:()=>d});var s=e(303);class o{count;delay;duration;wait;constructor(){this.wait=!1}load(t){(0,s.isNull)(t)||(void 0!==t.count&&(this.count=t.count),void 0!==t.delay&&(this.delay=(0,s.setRangeValue)(t.delay)),void 0!==t.duration&&(this.duration=(0,s.setRangeValue)(t.duration)),void 0!==t.wait&&(this.wait=t.wait))}}class a{delay;quantity;constructor(){this.quantity=1,this.delay=.1}load(t){(0,s.isNull)(t)||(void 0!==t.quantity&&(this.quantity=(0,s.setRangeValue)(t.quantity)),void 0!==t.delay&&(this.delay=(0,s.setRangeValue)(t.delay)))}}class l{color;opacity;constructor(){this.color=!1,this.opacity=!1}load(t){(0,s.isNull)(t)||(void 0!==t.color&&(this.color=t.color),void 0!==t.opacity&&(this.opacity=t.opacity))}}class r{options;replace;type;constructor(){this.options={},this.replace=new l,this.type="square"}load(t){(0,s.isNull)(t)||(void 0!==t.options&&(this.options=(0,s.deepExtend)({},t.options??{})),this.replace.load(t.replace),void 0!==t.type&&(this.type=t.type))}}var n=e(354);class h{fill;stroke;load(t){!(0,s.isNull)(t)&&(t.fill&&(this.fill??=new s.Fill,this.fill.load(t.fill)),t.stroke&&(this.stroke??=new s.Stroke,this.stroke.load(t.stroke)))}}class d{autoPlay;direction;domId;fill;life;name;particles;position;rate;shape;size;spawn;spawnFillColor;spawnStrokeColor;startCount;constructor(){this.autoPlay=!0,this.fill=!0,this.life=new o,this.rate=new a,this.shape=new r,this.spawn=new h,this.startCount=0}load(t){(0,s.isNull)(t)||(void 0!==t.autoPlay&&(this.autoPlay=t.autoPlay),void 0!==t.size&&(this.size??=new n.G,this.size.load(t.size)),void 0!==t.direction&&(this.direction=t.direction),this.domId=t.domId,void 0!==t.fill&&(this.fill=t.fill),this.life.load(t.life),this.name=t.name,this.particles=(0,s.executeOnSingleOrMultiple)(t.particles,t=>(0,s.deepExtend)({},t)),this.rate.load(t.rate),this.shape.load(t.shape),this.spawn.load(t.spawn),void 0!==t.position&&(this.position={},void 0!==t.position.x&&(this.position.x=(0,s.setRangeValue)(t.position.x)),void 0!==t.position.y&&(this.position.y=(0,s.setRangeValue)(t.position.y))),void 0!==t.spawnFillColor&&(this.spawnFillColor??=new s.AnimatableColor,this.spawnFillColor.load(t.spawnFillColor)),void 0!==t.spawnStrokeColor&&(this.spawnStrokeColor??=new s.AnimatableColor,this.spawnStrokeColor.load(t.spawnStrokeColor)),void 0!==t.startCount&&(this.startCount=t.startCount))}}},354(t,i,e){e.d(i,{G:()=>o});var s=e(303);class o{height;mode;width;constructor(){this.mode=s.PixelMode.percent,this.height=0,this.width=0}load(t){(0,s.isNull)(t)||(void 0!==t.mode&&(this.mode=t.mode),void 0!==t.height&&(this.height=t.height),void 0!==t.width&&(this.width=t.width))}}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[515],{515(t,i,s){s.r(i),s.d(i,{EmittersPlugin:()=>l});var o=s(303),e=s(442);class l{id="emitters";_instancesManager;constructor(t){this._instancesManager=t}async getPlugin(t){let{EmittersPluginInstance:i}=await s.e(100).then(s.bind(s,100));return new i(this._instancesManager,t)}loadOptions(t,i,s){(this.needsPlugin(i)||this.needsPlugin(s))&&s?.emitters&&(i.emitters=(0,o.executeOnSingleOrMultiple)(s.emitters,t=>{let i=new e.v;return i.load(t),i}))}needsPlugin(t){if(!t)return!1;let i=t.emitters;return(0,o.isArray)(i)&&!!i.length||void 0!==i}}},442(t,i,s){s.d(i,{v:()=>h});var o=s(303);class e{count;delay;duration;wait;constructor(){this.wait=!1}load(t){(0,o.isNull)(t)||(void 0!==t.count&&(this.count=t.count),void 0!==t.delay&&(this.delay=(0,o.setRangeValue)(t.delay)),void 0!==t.duration&&(this.duration=(0,o.setRangeValue)(t.duration)),void 0!==t.wait&&(this.wait=t.wait))}}class l{delay;quantity;constructor(){this.quantity=1,this.delay=.1}load(t){(0,o.isNull)(t)||(void 0!==t.quantity&&(this.quantity=(0,o.setRangeValue)(t.quantity)),void 0!==t.delay&&(this.delay=(0,o.setRangeValue)(t.delay)))}}class a{color;opacity;constructor(){this.color=!1,this.opacity=!1}load(t){(0,o.isNull)(t)||(void 0!==t.color&&(this.color=t.color),void 0!==t.opacity&&(this.opacity=t.opacity))}}class n{options;replace;type;constructor(){this.options={},this.replace=new a,this.type="square"}load(t){(0,o.isNull)(t)||(void 0!==t.options&&(this.options=(0,o.deepExtend)({},t.options??{})),this.replace.load(t.replace),void 0!==t.type&&(this.type=t.type))}}var r=s(354);class d{fill;stroke;load(t){!(0,o.isNull)(t)&&(t.fill&&(this.fill??=new o.Fill,this.fill.load(t.fill)),t.stroke&&(this.stroke??=new o.Stroke,this.stroke.load(t.stroke)))}}class h{autoPlay;direction;domId;fill;life;name;particles;position;rate;shape;size;spawn;spawnFillColor;spawnStrokeColor;startCount;constructor(){this.autoPlay=!0,this.fill=!0,this.life=new e,this.rate=new l,this.shape=new n,this.spawn=new d,this.startCount=0}load(t){(0,o.isNull)(t)||(void 0!==t.autoPlay&&(this.autoPlay=t.autoPlay),void 0!==t.size&&(this.size??=new r.G,this.size.load(t.size)),void 0!==t.direction&&(this.direction=t.direction),this.domId=t.domId,void 0!==t.fill&&(this.fill=t.fill),this.life.load(t.life),this.name=t.name,this.particles=(0,o.executeOnSingleOrMultiple)(t.particles,t=>(0,o.deepExtend)({},t)),this.rate.load(t.rate),this.shape.load(t.shape),this.spawn.load(t.spawn),void 0!==t.position&&(this.position={},void 0!==t.position.x&&(this.position.x=(0,o.setRangeValue)(t.position.x)),void 0!==t.position.y&&(this.position.y=(0,o.setRangeValue)(t.position.y))),void 0!==t.spawnFillColor&&(this.spawnFillColor??=new o.AnimatableColor,this.spawnFillColor.load(t.spawnFillColor)),void 0!==t.spawnStrokeColor&&(this.spawnStrokeColor??=new o.AnimatableColor,this.spawnStrokeColor.load(t.spawnStrokeColor)),void 0!==t.startCount&&(this.startCount=t.startCount))}}},354(t,i,s){s.d(i,{G:()=>e});var o=s(303);class e{height;mode;width;constructor(){this.mode=o.PixelMode.percent,this.height=0,this.width=0}load(t){(0,o.isNull)(t)||(void 0!==t.mode&&(this.mode=t.mode),void 0!==t.height&&(this.height=t.height),void 0!==t.width&&(this.width=t.width))}}}}]);
|
package/746.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[746],{746(t,i,e){e.d(i,{EmitterInstance:()=>l});var s=e(303),o=e(442),a=e(354);let n=1;function r(t,i,e,o){(t.paint??=new s.Paint).fill={color:s.AnimatableColor.create(void 0,{value:i}),enable:o,opacity:e}}class l{fill;name;options;position;size;spawnFillColor;spawnFillEnabled;spawnFillOpacity;spawnStrokeColor;spawnStrokeOpacity;spawnStrokeWidth;_container;_currentDuration;_currentEmitDelay;_currentSpawnDelay;_duration;_emitDelay;_firstSpawn;_immortal;_initialPosition;_lifeCount;_mutationObserver;_particlesOptions;_paused;_pluginManager;_removeCallback;_resizeObserver;_shape;_size;_spawnDelay;_startParticlesAdded;constructor(t,i,e,a,n){this._pluginManager=t,this._container=i,this._removeCallback=e,this._currentDuration=0,this._currentEmitDelay=0,this._currentSpawnDelay=0,this._initialPosition=n,a instanceof o.v?this.options=a:(this.options=new o.v,this.options.load(a)),this._spawnDelay=i.retina.reduceFactor?(0,s.getRangeValue)(this.options.life.delay??0)*s.millisecondsToSeconds/i.retina.reduceFactor:1/0,this.position=this._initialPosition??this._calcPosition(),this.name=this.options.name,this.fill=this.options.fill,this._firstSpawn=!this.options.life.wait,this._startParticlesAdded=!1;const r=(0,s.deepExtend)({},this.options.particles);if(r.move??={},r.move.direction??=this.options.direction,this.options.spawn.fill?.color&&(this.spawnFillColor=(0,s.rangeColorToHsl)(this._pluginManager,this.options.spawn.fill.color)),this.options.spawn.stroke?.color&&(this.spawnStrokeColor=(0,s.rangeColorToHsl)(this._pluginManager,this.options.spawn.stroke.color)),this._paused=!this.options.autoPlay,this._particlesOptions=r,this._size=this._calcSize(),this.size=(0,s.getSize)(this._size,this._container.canvas.size),this._lifeCount=this.options.life.count??-1,this._immortal=this._lifeCount<=0,this.options.domId){const t=(0,s.safeDocument)().getElementById(this.options.domId);t&&(this._mutationObserver=new MutationObserver(()=>{this.resize()}),this._resizeObserver=new ResizeObserver(()=>{this.resize()}),this._mutationObserver.observe(t,{attributes:!0,attributeFilter:["style","width","height"]}),this._resizeObserver.observe(t))}const l=this.options.shape,h=this._pluginManager.emitterShapeManager?.getShapeGenerator(l.type);h&&(this._shape=h.generate(this._container,this.position,this.size,this.fill,l.options)),this._container.dispatchEvent("emitterCreated",{emitter:this}),this.play()}externalPause(){this._paused=!0,this.pause()}externalPlay(){this._paused=!1,this.play()}async init(){await this._shape?.init()}pause(){this._paused||delete this._emitDelay}play(){if(this._paused||!((this._lifeCount>0||this._immortal||!this.options.life.count)&&(this._firstSpawn||this._currentSpawnDelay>=(this._spawnDelay??0))))return;let t=this._container;if(void 0===this._emitDelay){let i=(0,s.getRangeValue)(this.options.rate.delay);this._emitDelay=t.retina.reduceFactor?i*s.millisecondsToSeconds/t.retina.reduceFactor:1/0}(this._lifeCount>0||this._immortal)&&this._prepareToDie()}resize(){let t=this._initialPosition,i=this._container;this.position=t&&(0,s.isPointInside)(t,i.canvas.size,s.Vector.origin)?t:this._calcPosition(),this._size=this._calcSize(),this.size=(0,s.getSize)(this._size,i.canvas.size),this._shape?.resize(this.position,this.size)}update(t){if(this._paused)return;let i=this._container;this._firstSpawn&&(this._firstSpawn=!1,this._currentSpawnDelay=this._spawnDelay??0,this._currentEmitDelay=this._emitDelay??0),this._startParticlesAdded||(this._startParticlesAdded=!0,this._emitParticles(this.options.startCount)),void 0!==this._duration&&(this._currentDuration+=t.value,this._currentDuration>=this._duration&&(this.pause(),void 0!==this._spawnDelay&&delete this._spawnDelay,!this._immortal&&this._lifeCount--,this._lifeCount>0||this._immortal?(this.position=this._calcPosition(),this._shape?.resize(this.position,this.size),this._spawnDelay=i.retina.reduceFactor?(0,s.getRangeValue)(this.options.life.delay??0)*s.millisecondsToSeconds/i.retina.reduceFactor:1/0):this._destroy(),this._currentDuration-=this._duration,delete this._duration)),void 0!==this._spawnDelay&&(this._currentSpawnDelay+=t.value,this._currentSpawnDelay>=this._spawnDelay&&(this._container.dispatchEvent("emitterPlay"),this.play(),this._currentSpawnDelay-=this._spawnDelay,delete this._spawnDelay)),void 0!==this._emitDelay&&(this._currentEmitDelay+=t.value,this._currentEmitDelay>=this._emitDelay&&(this._emit(),this._currentEmitDelay-=this._emitDelay))}_calcPosition(){let t=this._container;if(this.options.domId){let i=(0,s.safeDocument)().getElementById(this.options.domId);if(i){let e=i.getBoundingClientRect(),o=t.retina.pixelRatio;return{x:(e.x+e.width*s.half)*o,y:(e.y+e.height*s.half)*o}}}return(0,s.calcPositionOrRandomFromSizeRanged)({size:t.canvas.size,position:this.options.position})}_calcSize(){let t,i=this._container;if(this.options.domId){let t=(0,s.safeDocument)().getElementById(this.options.domId);if(t){let e=t.getBoundingClientRect();return{width:e.width*i.retina.pixelRatio,height:e.height*i.retina.pixelRatio,mode:s.PixelMode.precise}}}return this.options.size??((t=new a.G).load({height:0,mode:s.PixelMode.percent,width:0}),t)}_destroy=()=>{this._mutationObserver?.disconnect(),this._mutationObserver=void 0,this._resizeObserver?.disconnect(),this._resizeObserver=void 0,this._removeCallback(this),this._container.dispatchEvent("emitterDestroyed",{emitter:this})};_emit(){if(this._paused)return;let t=(0,s.getRangeValue)(this.options.rate.quantity);this._emitParticles(t)}_emitParticles(t){let i=(0,s.itemFromSingleOrMultiple)(this._particlesOptions)??{},e=this.options.spawn.fill?.color.animation,o=this.options.spawn.fill?.enable??!!this.options.spawn.fill?.color,a=this.options.spawn.fill?.opacity===void 0?s.defaultOpacity:(0,s.getRangeValue)(this.options.spawn.fill.opacity),n=this.options.spawn.stroke?.color?.animation,l=this.options.spawn.stroke?.opacity===void 0?s.defaultOpacity:(0,s.getRangeValue)(this.options.spawn.stroke.opacity),h=this.options.spawn.stroke?.width===void 0?1:(0,s.getRangeValue)(this.options.spawn.stroke.width),p=this._container.retina.reduceFactor,c=!!e,_=!!n,d=!!this._shape,u=c||_,m=u||d,w=u?{h:s.hMax,s:s.sMax,l:s.lMax}:null,y=this.options.shape;for(let c=0;c<t*p;c++){let t=m?(0,s.deepExtend)({},i):i;if(this.spawnFillOpacity=a,this.spawnFillEnabled=o,this.spawnStrokeOpacity=l,this.spawnStrokeWidth=h,this.spawnFillColor&&(e&&w&&(this.spawnFillColor.h=this._setColorAnimation(e.h,this.spawnFillColor.h,w.h,3.6),this.spawnFillColor.s=this._setColorAnimation(e.s,this.spawnFillColor.s,w.s),this.spawnFillColor.l=this._setColorAnimation(e.l,this.spawnFillColor.l,w.l)),r(t,this.spawnFillColor,this.spawnFillOpacity,this.spawnFillEnabled)),this.spawnStrokeColor){var f,g,v;n&&w&&(this.spawnStrokeColor.h=this._setColorAnimation(n.h,this.spawnStrokeColor.h,w.h,3.6),this.spawnStrokeColor.s=this._setColorAnimation(n.s,this.spawnStrokeColor.s,w.s),this.spawnStrokeColor.l=this._setColorAnimation(n.l,this.spawnStrokeColor.l,w.l)),f=this.spawnStrokeColor,g=this.spawnStrokeOpacity,v=this.spawnStrokeWidth,(t.paint??=new s.Paint).stroke={color:s.AnimatableColor.create(void 0,{value:f}),opacity:g,width:v}}let p=this.position;if(this._shape){let i=this._shape.randomPosition();if(i){p=i.position;let e=y.replace;e.color&&i.color&&r(t,i.color,e.opacity?i.opacity??s.defaultOpacity:s.defaultOpacity,!0)}else p=null}p&&this._container.particles.addParticle(p,t)}}_prepareToDie=()=>{if(this._paused)return;let t=void 0!==this.options.life.duration?(0,s.getRangeValue)(this.options.life.duration):void 0;(this._lifeCount>0||this._immortal)&&void 0!==t&&t>0&&(this._duration=t*s.millisecondsToSeconds)};_setColorAnimation=(t,i,e,o=n)=>{let a=this._container;if(!t.enable)return i;let r=(0,s.randomInRangeValue)(t.offset),l=(0,s.getRangeValue)(this.options.rate.delay),h=a.retina.reduceFactor?l*s.millisecondsToSeconds/a.retina.reduceFactor:1/0;return(i+(0,s.getRangeValue)(t.speed)*a.fpsLimit/h+r*o)%e}}}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[812],{812(t,e,i){i.d(e,{EmittersInteractor:()=>r});var s=i(702),a=i(303),o=i(442);let l={count:1,enable:!0},n="emitters";class r extends s.ExternalInteractorBase{handleClickMode;maxDistance;_instancesManager;constructor(t,e){super(e),this._instancesManager=t,this.maxDistance=0,this.handleClickMode=(t,e)=>{let i,s=this.container.actualOptions.interactivity.modes.emitters;if(!s||t!==n)return;if((0,a.isArray)(s.value)){let t=s.value.length;if(t>0&&s.random.enable){i=[];let e=new Set;for(let o=0;o<s.random.count;o++){let l=(0,a.arrayRandomIndex)(s.value);if(e.has(l)&&e.size<t){o--;continue}e.add(l);let n=(0,a.itemFromArray)(s.value,l);n&&i.push(n)}}else i=s.value}else i=s.value;let o=i,l=e.mouse.clickPosition;(0,a.executeOnSingleOrMultiple)(o,async t=>{await this._instancesManager.addEmitter(this.container,t,l)})}}clear(){}init(){}interact(t,e){for(let t of this._instancesManager.getArray(this.container))t.update(e)}isEnabled(t,e){let i=this.container.actualOptions,s=t.mouse,o=(e?.interactivity??i.interactivity).events;return!!s.clickPosition&&!!o.onClick.enable&&(0,a.isInArray)(n,o.onClick.mode)}loadModeOptions(t,...e){for(let i of(t.emitters={random:l,value:[]},e))if(i?.emitters)if((0,a.isArray)(i.emitters))for(let e of i.emitters){let i=new o.v;i.load(e),t.emitters.value.push(i)}else if("value"in i.emitters){let e=i.emitters;if(t.emitters.random.enable=e.random?.enable??t.emitters.random.enable,t.emitters.random.count=e.random?.count??t.emitters.random.count,(0,a.isArray)(e.value))for(let i of e.value){let e=new o.v;e.load(i),t.emitters.value.push(e)}else{let i=new o.v;i.load(e.value),t.emitters.value.push(i)}}else{let e=new o.v;e.load(i.emitters),t.emitters.value.push(e)}}removeEmitter(t){let e=this._instancesManager.getArray(this.container).indexOf(t);e>=0&&this._instancesManager.getArray(this.container).splice(e,1)}reset(){}}},442(t,e,i){i.d(e,{v:()=>h});var s=i(303);class a{count;delay;duration;wait;constructor(){this.wait=!1}load(t){(0,s.isNull)(t)||(void 0!==t.count&&(this.count=t.count),void 0!==t.delay&&(this.delay=(0,s.setRangeValue)(t.delay)),void 0!==t.duration&&(this.duration=(0,s.setRangeValue)(t.duration)),void 0!==t.wait&&(this.wait=t.wait))}}class o{delay;quantity;constructor(){this.quantity=1,this.delay=.1}load(t){(0,s.isNull)(t)||(void 0!==t.quantity&&(this.quantity=(0,s.setRangeValue)(t.quantity)),void 0!==t.delay&&(this.delay=(0,s.setRangeValue)(t.delay)))}}class l{color;opacity;constructor(){this.color=!1,this.opacity=!1}load(t){(0,s.isNull)(t)||(void 0!==t.color&&(this.color=t.color),void 0!==t.opacity&&(this.opacity=t.opacity))}}class n{options;replace;type;constructor(){this.options={},this.replace=new l,this.type="square"}load(t){(0,s.isNull)(t)||(void 0!==t.options&&(this.options=(0,s.deepExtend)({},t.options??{})),this.replace.load(t.replace),void 0!==t.type&&(this.type=t.type))}}var r=i(354);class d{fill;stroke;load(t){!(0,s.isNull)(t)&&(t.fill&&(this.fill??=new s.Fill,this.fill.load(t.fill)),t.stroke&&(this.stroke??=new s.Stroke,this.stroke.load(t.stroke)))}}class h{autoPlay;direction;domId;fill;life;name;particles;position;rate;shape;size;spawn;spawnFillColor;spawnStrokeColor;startCount;constructor(){this.autoPlay=!0,this.fill=!0,this.life=new a,this.rate=new o,this.shape=new n,this.spawn=new d,this.startCount=0}load(t){(0,s.isNull)(t)||(void 0!==t.autoPlay&&(this.autoPlay=t.autoPlay),void 0!==t.size&&(this.size??=new r.G,this.size.load(t.size)),void 0!==t.direction&&(this.direction=t.direction),this.domId=t.domId,void 0!==t.fill&&(this.fill=t.fill),this.life.load(t.life),this.name=t.name,this.particles=(0,s.executeOnSingleOrMultiple)(t.particles,t=>(0,s.deepExtend)({},t)),this.rate.load(t.rate),this.shape.load(t.shape),this.spawn.load(t.spawn),void 0!==t.position&&(this.position={},void 0!==t.position.x&&(this.position.x=(0,s.setRangeValue)(t.position.x)),void 0!==t.position.y&&(this.position.y=(0,s.setRangeValue)(t.position.y))),void 0!==t.spawnFillColor&&(this.spawnFillColor??=new s.AnimatableColor,this.spawnFillColor.load(t.spawnFillColor)),void 0!==t.spawnStrokeColor&&(this.spawnStrokeColor??=new s.AnimatableColor,this.spawnStrokeColor.load(t.spawnStrokeColor)),void 0!==t.startCount&&(this.startCount=t.startCount))}}},354(t,e,i){i.d(e,{G:()=>a});var s=i(303);class a{height;mode;width;constructor(){this.mode=s.PixelMode.percent,this.height=0,this.width=0}load(t){(0,s.isNull)(t)||(void 0!==t.mode&&(this.mode=t.mode),void 0!==t.height&&(this.height=t.height),void 0!==t.width&&(this.width=t.width))}}}}]);
|
package/903.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).push([[903],{903(e,t,n){n.r(t),n.d(t,{getEmittersInstancesManager:()=>i});let s=new WeakMap;function i(e){let t=e.pluginManager,i=s.get(t);return i||(i=n.e(475).then(n.bind(n,475)).then(({EmittersInstancesManager:e})=>new e(t)).catch(e=>{throw s.delete(t),e}),s.set(t,i)),i}}}]);
|
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/tsparticles/tsparticles) plugin for particles emitters.
|
|
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
|
|
@@ -77,3 +83,24 @@ import { loadEmittersPlugin } from "@tsparticles/plugin-emitters";
|
|
|
77
83
|
await loadEmittersPlugin(tsParticles);
|
|
78
84
|
})();
|
|
79
85
|
```
|
|
86
|
+
|
|
87
|
+
## Option mapping
|
|
88
|
+
|
|
89
|
+
- Primary options key: `emitters`
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
{
|
|
93
|
+
"emitters": {}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Common pitfalls
|
|
98
|
+
|
|
99
|
+
- Calling `tsParticles.load(...)` before `loadInteractivityPlugin(...)`
|
|
100
|
+
- Verify required peer packages before enabling advanced options
|
|
101
|
+
- Change one option group at a time to isolate regressions quickly
|
|
102
|
+
|
|
103
|
+
## Related docs
|
|
104
|
+
|
|
105
|
+
- All packages catalog: <https://github.com/tsparticles/tsparticles>
|
|
106
|
+
- Main docs: <https://particles.js.org/docs/>
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import { AnimatableColor,
|
|
1
|
+
import { AnimatableColor, Paint, PixelMode, Vector, calcPositionOrRandomFromSizeRanged, deepExtend, defaultOpacity, getRangeValue, getSize, hMax, half, isPointInside, itemFromSingleOrMultiple, lMax, millisecondsToSeconds, randomInRangeValue, rangeColorToHsl, sMax, safeDocument, } from "@tsparticles/engine";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
3
|
import { EmitterSize } from "./Options/Classes/EmitterSize.js";
|
|
4
4
|
const defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1, colorFactor = 3.6, defaultStrokeWidth = 1;
|
|
5
5
|
function setParticlesOptionsFillColor(particlesOptions, color, opacity, enable) {
|
|
6
|
-
particlesOptions.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const paint = (particlesOptions.paint ??= new Paint());
|
|
7
|
+
paint.fill = {
|
|
8
|
+
color: AnimatableColor.create(undefined, { value: color }),
|
|
9
|
+
enable,
|
|
10
|
+
opacity,
|
|
11
|
+
};
|
|
10
12
|
}
|
|
11
13
|
function setParticlesOptionsStrokeColor(particlesOptions, color, opacity, width) {
|
|
12
|
-
particlesOptions.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
const paint = (particlesOptions.paint ??= new Paint());
|
|
15
|
+
paint.stroke = {
|
|
16
|
+
color: AnimatableColor.create(undefined, { value: color }),
|
|
17
|
+
opacity,
|
|
18
|
+
width,
|
|
19
|
+
};
|
|
16
20
|
}
|
|
17
21
|
export class EmitterInstance {
|
|
18
|
-
container;
|
|
19
|
-
removeCallback;
|
|
20
22
|
fill;
|
|
21
23
|
name;
|
|
22
24
|
options;
|
|
@@ -28,12 +30,12 @@ export class EmitterInstance {
|
|
|
28
30
|
spawnStrokeColor;
|
|
29
31
|
spawnStrokeOpacity;
|
|
30
32
|
spawnStrokeWidth;
|
|
33
|
+
_container;
|
|
31
34
|
_currentDuration;
|
|
32
35
|
_currentEmitDelay;
|
|
33
36
|
_currentSpawnDelay;
|
|
34
37
|
_duration;
|
|
35
38
|
_emitDelay;
|
|
36
|
-
_engine;
|
|
37
39
|
_firstSpawn;
|
|
38
40
|
_immortal;
|
|
39
41
|
_initialPosition;
|
|
@@ -41,15 +43,17 @@ export class EmitterInstance {
|
|
|
41
43
|
_mutationObserver;
|
|
42
44
|
_particlesOptions;
|
|
43
45
|
_paused;
|
|
46
|
+
_pluginManager;
|
|
47
|
+
_removeCallback;
|
|
44
48
|
_resizeObserver;
|
|
45
49
|
_shape;
|
|
46
50
|
_size;
|
|
47
51
|
_spawnDelay;
|
|
48
52
|
_startParticlesAdded;
|
|
49
|
-
constructor(
|
|
50
|
-
this.
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
+
constructor(pluginManager, container, removeCallback, options, position) {
|
|
54
|
+
this._pluginManager = pluginManager;
|
|
55
|
+
this._container = container;
|
|
56
|
+
this._removeCallback = removeCallback;
|
|
53
57
|
this._currentDuration = 0;
|
|
54
58
|
this._currentEmitDelay = 0;
|
|
55
59
|
this._currentSpawnDelay = 0;
|
|
@@ -74,15 +78,15 @@ export class EmitterInstance {
|
|
|
74
78
|
particlesOptions.move ??= {};
|
|
75
79
|
particlesOptions.move.direction ??= this.options.direction;
|
|
76
80
|
if (this.options.spawn.fill?.color) {
|
|
77
|
-
this.spawnFillColor = rangeColorToHsl(this.
|
|
81
|
+
this.spawnFillColor = rangeColorToHsl(this._pluginManager, this.options.spawn.fill.color);
|
|
78
82
|
}
|
|
79
83
|
if (this.options.spawn.stroke?.color) {
|
|
80
|
-
this.spawnStrokeColor = rangeColorToHsl(this.
|
|
84
|
+
this.spawnStrokeColor = rangeColorToHsl(this._pluginManager, this.options.spawn.stroke.color);
|
|
81
85
|
}
|
|
82
86
|
this._paused = !this.options.autoPlay;
|
|
83
87
|
this._particlesOptions = particlesOptions;
|
|
84
88
|
this._size = this._calcSize();
|
|
85
|
-
this.size = getSize(this._size, this.
|
|
89
|
+
this.size = getSize(this._size, this._container.canvas.size);
|
|
86
90
|
this._lifeCount = this.options.life.count ?? defaultLifeCount;
|
|
87
91
|
this._immortal = this._lifeCount <= minLifeCount;
|
|
88
92
|
if (this.options.domId) {
|
|
@@ -101,15 +105,12 @@ export class EmitterInstance {
|
|
|
101
105
|
this._resizeObserver.observe(element);
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
const shapeOptions = this.options.shape, shapeGenerator = this.
|
|
108
|
+
const shapeOptions = this.options.shape, shapeGenerator = this._pluginManager.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
|
|
105
109
|
if (shapeGenerator) {
|
|
106
|
-
this._shape = shapeGenerator.generate(this.
|
|
110
|
+
this._shape = shapeGenerator.generate(this._container, this.position, this.size, this.fill, shapeOptions.options);
|
|
107
111
|
}
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
data: {
|
|
111
|
-
emitter: this,
|
|
112
|
-
},
|
|
112
|
+
this._container.dispatchEvent("emitterCreated", {
|
|
113
|
+
emitter: this,
|
|
113
114
|
});
|
|
114
115
|
this.play();
|
|
115
116
|
}
|
|
@@ -138,7 +139,7 @@ export class EmitterInstance {
|
|
|
138
139
|
(this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
|
|
139
140
|
return;
|
|
140
141
|
}
|
|
141
|
-
const container = this.
|
|
142
|
+
const container = this._container;
|
|
142
143
|
if (this._emitDelay === undefined) {
|
|
143
144
|
const delay = getRangeValue(this.options.rate.delay);
|
|
144
145
|
this._emitDelay = container.retina.reduceFactor
|
|
@@ -150,7 +151,7 @@ export class EmitterInstance {
|
|
|
150
151
|
}
|
|
151
152
|
}
|
|
152
153
|
resize() {
|
|
153
|
-
const initialPosition = this._initialPosition, container = this.
|
|
154
|
+
const initialPosition = this._initialPosition, container = this._container;
|
|
154
155
|
this.position =
|
|
155
156
|
initialPosition && isPointInside(initialPosition, container.canvas.size, Vector.origin)
|
|
156
157
|
? initialPosition
|
|
@@ -163,7 +164,7 @@ export class EmitterInstance {
|
|
|
163
164
|
if (this._paused) {
|
|
164
165
|
return;
|
|
165
166
|
}
|
|
166
|
-
const container = this.
|
|
167
|
+
const container = this._container;
|
|
167
168
|
if (this._firstSpawn) {
|
|
168
169
|
this._firstSpawn = false;
|
|
169
170
|
this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
|
|
@@ -201,9 +202,7 @@ export class EmitterInstance {
|
|
|
201
202
|
if (this._spawnDelay !== undefined) {
|
|
202
203
|
this._currentSpawnDelay += delta.value;
|
|
203
204
|
if (this._currentSpawnDelay >= this._spawnDelay) {
|
|
204
|
-
this.
|
|
205
|
-
container: this.container,
|
|
206
|
-
});
|
|
205
|
+
this._container.dispatchEvent("emitterPlay");
|
|
207
206
|
this.play();
|
|
208
207
|
this._currentSpawnDelay -= this._spawnDelay;
|
|
209
208
|
delete this._spawnDelay;
|
|
@@ -218,7 +217,7 @@ export class EmitterInstance {
|
|
|
218
217
|
}
|
|
219
218
|
}
|
|
220
219
|
_calcPosition() {
|
|
221
|
-
const container = this.
|
|
220
|
+
const container = this._container;
|
|
222
221
|
if (this.options.domId) {
|
|
223
222
|
const element = safeDocument().getElementById(this.options.domId);
|
|
224
223
|
if (element) {
|
|
@@ -235,7 +234,7 @@ export class EmitterInstance {
|
|
|
235
234
|
});
|
|
236
235
|
}
|
|
237
236
|
_calcSize() {
|
|
238
|
-
const container = this.
|
|
237
|
+
const container = this._container;
|
|
239
238
|
if (this.options.domId) {
|
|
240
239
|
const element = safeDocument().getElementById(this.options.domId);
|
|
241
240
|
if (element) {
|
|
@@ -263,12 +262,9 @@ export class EmitterInstance {
|
|
|
263
262
|
this._mutationObserver = undefined;
|
|
264
263
|
this._resizeObserver?.disconnect();
|
|
265
264
|
this._resizeObserver = undefined;
|
|
266
|
-
this.
|
|
267
|
-
this.
|
|
268
|
-
|
|
269
|
-
data: {
|
|
270
|
-
emitter: this,
|
|
271
|
-
},
|
|
265
|
+
this._removeCallback(this);
|
|
266
|
+
this._container.dispatchEvent("emitterDestroyed", {
|
|
267
|
+
emitter: this,
|
|
272
268
|
});
|
|
273
269
|
};
|
|
274
270
|
_emit() {
|
|
@@ -286,7 +282,7 @@ export class EmitterInstance {
|
|
|
286
282
|
? defaultOpacity
|
|
287
283
|
: getRangeValue(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
|
|
288
284
|
? defaultStrokeWidth
|
|
289
|
-
: getRangeValue(this.options.spawn.stroke.width), reduceFactor = this.
|
|
285
|
+
: getRangeValue(this.options.spawn.stroke.width), reduceFactor = this._container.retina.reduceFactor, needsFillColorAnimation = !!fillHslAnimation, needsStrokeColorAnimation = !!strokeHslAnimation, needsShapeData = !!this._shape, needsColorAnimation = needsFillColorAnimation || needsStrokeColorAnimation, needsCopy = needsColorAnimation || needsShapeData, maxValues = needsColorAnimation ? { h: hMax, s: sMax, l: lMax } : null, shapeOptions = this.options.shape;
|
|
290
286
|
for (let i = 0; i < quantity * reduceFactor; i++) {
|
|
291
287
|
const particlesOptions = needsCopy
|
|
292
288
|
? deepExtend({}, singleParticlesOptions)
|
|
@@ -326,7 +322,7 @@ export class EmitterInstance {
|
|
|
326
322
|
}
|
|
327
323
|
}
|
|
328
324
|
if (position) {
|
|
329
|
-
this.
|
|
325
|
+
this._container.particles.addParticle(position, particlesOptions);
|
|
330
326
|
}
|
|
331
327
|
}
|
|
332
328
|
}
|
|
@@ -340,7 +336,7 @@ export class EmitterInstance {
|
|
|
340
336
|
}
|
|
341
337
|
};
|
|
342
338
|
_setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
|
|
343
|
-
const container = this.
|
|
339
|
+
const container = this._container;
|
|
344
340
|
if (!animation.enable) {
|
|
345
341
|
return initValue;
|
|
346
342
|
}
|
|
@@ -3,15 +3,15 @@ import { Emitter } from "./Options/Classes/Emitter.js";
|
|
|
3
3
|
const defaultIndex = 0;
|
|
4
4
|
export class EmittersInstancesManager {
|
|
5
5
|
_containerArrays;
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
6
|
+
_pluginManager;
|
|
7
|
+
constructor(pluginManager) {
|
|
8
8
|
this._containerArrays = new Map();
|
|
9
|
-
this.
|
|
9
|
+
this._pluginManager = pluginManager;
|
|
10
10
|
}
|
|
11
11
|
async addEmitter(container, options, position) {
|
|
12
12
|
const emitterOptions = new Emitter();
|
|
13
13
|
emitterOptions.load(options);
|
|
14
|
-
const { EmitterInstance } = await import("./EmitterInstance.js"), emitter = new EmitterInstance(this.
|
|
14
|
+
const { EmitterInstance } = await import("./EmitterInstance.js"), emitter = new EmitterInstance(this._pluginManager, container, (emitter) => {
|
|
15
15
|
this.removeEmitter(container, emitter);
|
|
16
16
|
}, emitterOptions, position);
|
|
17
17
|
await emitter.init();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export async function addEmittersShapesManager(e) {
|
|
2
|
+
const { ShapeManager } = await import("./ShapeManager.js"), pluginManager = e.pluginManager;
|
|
3
|
+
pluginManager.emitterShapeManager ??= new ShapeManager();
|
|
4
|
+
pluginManager.addEmitterShapeGenerator ??= (name, generator) => {
|
|
5
|
+
pluginManager.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const instancesManagers = new WeakMap();
|
|
2
|
+
export function getEmittersInstancesManager(e) {
|
|
3
|
+
const pluginManager = e.pluginManager;
|
|
4
|
+
let manager = instancesManagers.get(pluginManager);
|
|
5
|
+
if (!manager) {
|
|
6
|
+
manager = import("./EmittersInstancesManager.js")
|
|
7
|
+
.then(({ EmittersInstancesManager }) => new EmittersInstancesManager(pluginManager))
|
|
8
|
+
.catch((error) => {
|
|
9
|
+
instancesManagers.delete(pluginManager);
|
|
10
|
+
throw error;
|
|
11
|
+
});
|
|
12
|
+
instancesManagers.set(pluginManager, manager);
|
|
13
|
+
}
|
|
14
|
+
return manager;
|
|
15
|
+
}
|
package/browser/index.js
CHANGED
|
@@ -1,28 +1,9 @@
|
|
|
1
|
+
import { loadEmittersInteraction } from "./interaction.js";
|
|
2
|
+
import { loadEmittersPluginSimple } from "./plugin.js";
|
|
1
3
|
export async function loadEmittersPlugin(engine) {
|
|
2
|
-
engine
|
|
3
|
-
await engine
|
|
4
|
-
const [{ ensureInteractivityPluginLoaded }, { ShapeManager }, { EmittersInstancesManager }, { EmittersPlugin },] = await Promise.all([
|
|
5
|
-
import("@tsparticles/plugin-interactivity"),
|
|
6
|
-
import("./ShapeManager.js"),
|
|
7
|
-
import("./EmittersInstancesManager.js"),
|
|
8
|
-
import("./EmittersPlugin.js"),
|
|
9
|
-
]), instancesManager = new EmittersInstancesManager(e);
|
|
10
|
-
ensureInteractivityPluginLoaded(e);
|
|
11
|
-
e.emitterShapeManager ??= new ShapeManager();
|
|
12
|
-
e.addEmitterShapeGenerator ??= (name, generator) => {
|
|
13
|
-
e.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
14
|
-
};
|
|
15
|
-
e.addPlugin(new EmittersPlugin(instancesManager));
|
|
16
|
-
e.addInteractor?.("externalEmitters", async (container) => {
|
|
17
|
-
const { EmittersInteractor } = await import("./EmittersInteractor.js");
|
|
18
|
-
return new EmittersInteractor(instancesManager, container);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export function ensureEmittersPluginLoaded(e) {
|
|
23
|
-
if (!e.addEmitterShapeGenerator) {
|
|
24
|
-
throw new Error("tsParticles Emitters Plugin is not loaded");
|
|
25
|
-
}
|
|
4
|
+
await loadEmittersPluginSimple(engine);
|
|
5
|
+
await loadEmittersInteraction(engine);
|
|
26
6
|
}
|
|
7
|
+
export * from "./ensureEmittersPluginLoaded.js";
|
|
27
8
|
export * from "./EmitterShapeBase.js";
|
|
28
9
|
export * from "./Enums/EmitterClickMode.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export async function loadEmittersInteraction(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
|
+
const [{ ensureInteractivityPluginLoaded }, { addEmittersShapesManager }, { getEmittersInstancesManager },] = await Promise.all([
|
|
5
|
+
import("@tsparticles/plugin-interactivity"),
|
|
6
|
+
import("./addEmittersShapesManager.js"),
|
|
7
|
+
import("./getEmittersInstancesManager.js"),
|
|
8
|
+
]), instancesManager = await getEmittersInstancesManager(e);
|
|
9
|
+
ensureInteractivityPluginLoaded(e);
|
|
10
|
+
await addEmittersShapesManager(e);
|
|
11
|
+
e.pluginManager.addInteractor?.("externalEmitters", async (container) => {
|
|
12
|
+
const { EmittersInteractor } = await import("./EmittersInteractor.js");
|
|
13
|
+
return new EmittersInteractor(instancesManager, container);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export * from "./EmitterShapeBase.js";
|
|
18
|
+
export * from "./Enums/EmitterClickMode.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export async function loadEmittersPluginSimple(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.10");
|
|
3
|
+
await engine.pluginManager.register(async (e) => {
|
|
4
|
+
const [{ addEmittersShapesManager }, { getEmittersInstancesManager }, { EmittersPlugin },] = await Promise.all([
|
|
5
|
+
import("./addEmittersShapesManager.js"),
|
|
6
|
+
import("./getEmittersInstancesManager.js"),
|
|
7
|
+
import("./EmittersPlugin.js"),
|
|
8
|
+
]), instancesManager = await getEmittersInstancesManager(e);
|
|
9
|
+
await addEmittersShapesManager(e);
|
|
10
|
+
e.pluginManager.addPlugin(new EmittersPlugin(instancesManager));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export * from "./EmitterShapeBase.js";
|
|
14
|
+
export * from "./Enums/EmitterClickMode.js";
|