@tsparticles/plugin-emitters 4.0.0-alpha.8 → 4.0.0-beta.0
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/526.min.js +1 -0
- package/588.min.js +1 -0
- package/772.min.js +1 -0
- package/784.min.js +1 -0
- package/795.min.js +1 -0
- package/803.min.js +1 -0
- package/README.md +5 -0
- package/browser/EmitterInstance.js +109 -65
- package/browser/EmitterShapeBase.js +4 -0
- package/browser/EmittersInstancesManager.js +2 -0
- package/browser/EmittersInteractor.js +5 -1
- package/browser/EmittersPlugin.js +2 -1
- package/browser/EmittersPluginInstance.js +2 -0
- package/browser/Options/Classes/Emitter.js +25 -3
- package/browser/Options/Classes/EmitterLife.js +4 -0
- package/browser/Options/Classes/EmitterRate.js +2 -0
- package/browser/Options/Classes/EmitterShape.js +3 -0
- package/browser/Options/Classes/EmitterShapeReplace.js +2 -0
- package/browser/Options/Classes/EmitterSize.js +3 -0
- package/browser/Options/Classes/EmitterSpawn.js +18 -0
- package/browser/Options/Interfaces/IEmitterSpawn.js +1 -0
- package/browser/index.js +13 -3
- package/cjs/EmitterInstance.js +109 -65
- package/cjs/EmitterShapeBase.js +4 -0
- package/cjs/EmittersInstancesManager.js +2 -0
- package/cjs/EmittersInteractor.js +5 -1
- package/cjs/EmittersPlugin.js +2 -1
- package/cjs/EmittersPluginInstance.js +2 -0
- package/cjs/Options/Classes/Emitter.js +25 -3
- package/cjs/Options/Classes/EmitterLife.js +4 -0
- package/cjs/Options/Classes/EmitterRate.js +2 -0
- package/cjs/Options/Classes/EmitterShape.js +3 -0
- package/cjs/Options/Classes/EmitterShapeReplace.js +2 -0
- package/cjs/Options/Classes/EmitterSize.js +3 -0
- package/cjs/Options/Classes/EmitterSpawn.js +18 -0
- package/cjs/Options/Interfaces/IEmitterSpawn.js +1 -0
- package/cjs/index.js +13 -3
- package/dist_browser_EmitterInstance_js.js +2 -2
- package/dist_browser_EmittersInstancesManager_js.js +18 -8
- package/dist_browser_EmittersInteractor_js.js +19 -9
- package/dist_browser_EmittersPluginInstance_js.js +2 -2
- package/dist_browser_EmittersPlugin_js.js +18 -8
- package/dist_browser_ShapeManager_js.js +2 -2
- package/esm/EmitterInstance.js +109 -65
- package/esm/EmitterShapeBase.js +4 -0
- package/esm/EmittersInstancesManager.js +2 -0
- package/esm/EmittersInteractor.js +5 -1
- package/esm/EmittersPlugin.js +2 -1
- package/esm/EmittersPluginInstance.js +2 -0
- package/esm/Options/Classes/Emitter.js +25 -3
- package/esm/Options/Classes/EmitterLife.js +4 -0
- package/esm/Options/Classes/EmitterRate.js +2 -0
- package/esm/Options/Classes/EmitterShape.js +3 -0
- package/esm/Options/Classes/EmitterShapeReplace.js +2 -0
- package/esm/Options/Classes/EmitterSize.js +3 -0
- package/esm/Options/Classes/EmitterSpawn.js +18 -0
- package/esm/Options/Interfaces/IEmitterSpawn.js +1 -0
- package/esm/index.js +13 -3
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.plugin.emitters.js +44 -32
- package/tsparticles.plugin.emitters.min.js +2 -2
- package/types/EmitterInstance.d.ts +6 -1
- package/types/EmittersInteractor.d.ts +1 -0
- package/types/EmittersPlugin.d.ts +1 -1
- package/types/IEmitterShapeGenerator.d.ts +2 -2
- package/types/Options/Classes/Emitter.d.ts +4 -1
- package/types/Options/Classes/EmitterSpawn.d.ts +7 -0
- package/types/Options/Interfaces/IEmitter.d.ts +4 -1
- package/types/Options/Interfaces/IEmitterSpawn.d.ts +5 -0
- package/types/index.d.ts +1 -0
- package/umd/EmitterInstance.js +108 -64
- package/umd/EmitterShapeBase.js +4 -0
- package/umd/EmittersInstancesManager.js +2 -0
- package/umd/EmittersInteractor.js +5 -1
- package/umd/EmittersPlugin.js +2 -1
- package/umd/EmittersPluginInstance.js +2 -0
- package/umd/Options/Classes/Emitter.js +26 -4
- package/umd/Options/Classes/EmitterLife.js +4 -0
- package/umd/Options/Classes/EmitterRate.js +2 -0
- package/umd/Options/Classes/EmitterShape.js +3 -0
- package/umd/Options/Classes/EmitterShapeReplace.js +2 -0
- package/umd/Options/Classes/EmitterSize.js +3 -0
- package/umd/Options/Classes/EmitterSpawn.js +32 -0
- package/umd/Options/Interfaces/IEmitterSpawn.js +12 -0
- package/umd/index.js +14 -3
- package/129.min.js +0 -2
- package/129.min.js.LICENSE.txt +0 -1
- package/246.min.js +0 -2
- package/246.min.js.LICENSE.txt +0 -1
- package/330.min.js +0 -2
- package/330.min.js.LICENSE.txt +0 -1
- package/490.min.js +0 -2
- package/490.min.js.LICENSE.txt +0 -1
- package/849.min.js +0 -2
- package/849.min.js.LICENSE.txt +0 -1
- package/940.min.js +0 -2
- package/940.min.js.LICENSE.txt +0 -1
- package/tsparticles.plugin.emitters.min.js.LICENSE.txt +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/plugin-interactivity","@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/plugin-interactivity"),require("@tsparticles/engine")):t(e.window,e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,(e,t)=>(()=>{"use strict";var r,i,o,n,a={303(e){e.exports=t},702(t){t.exports=e}},s={};function l(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return a[e](r,r.exports,l),r.exports}l.m=a,p=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,l.t=function(e,t){if(1&t&&(e=this(e)),8&t||"object"==typeof e&&e&&(4&t&&e.__esModule||16&t&&"function"==typeof e.then))return e;var r=Object.create(null);l.r(r);var i={};c=c||[null,p({}),p([]),p(p)];for(var o=2&t&&e;("object"==typeof o||"function"==typeof o)&&!~c.indexOf(o);o=p(o))Object.getOwnPropertyNames(o).forEach(t=>i[t]=()=>e[t]);return i.default=()=>e,l.d(r,i),r},l.d=(e,t)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,r)=>(l.f[r](e,t),t),[])),l.u=e=>""+e+".min.js",l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u={},l.l=(e,t,r,i)=>{if(u[e])return void u[e].push(t);if(void 0!==r)for(var o,n,a=document.getElementsByTagName("script"),s=0;s<a.length;s++){var c=a[s];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/plugin-emitters:"+r){o=c;break}}o||(n=!0,(o=document.createElement("script")).charset="utf-8",l.nc&&o.setAttribute("nonce",l.nc),o.setAttribute("data-webpack","@tsparticles/plugin-emitters:"+r),o.src=e),u[e]=[t];var p=(t,r)=>{o.onerror=o.onload=null,clearTimeout(d);var i=u[e];if(delete u[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach(e=>e(r)),t)return t(r)},d=setTimeout(p.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=p.bind(null,o.onerror),o.onload=p.bind(null,o.onload),n&&document.head.appendChild(o)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.g.importScripts&&(d=l.g.location+"");var c,p,u,d,f=l.g.document;if(!d&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(d=f.currentScript.src),!d)){var h=f.getElementsByTagName("script");if(h.length)for(var m=h.length-1;m>-1&&(!d||!/^http(s?):/.test(d));)d=h[m--].src}if(!d)throw Error("Automatic publicPath is not supported in this browser");l.p=d=d.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),r={833:0},l.f.j=(e,t)=>{var i=l.o(r,e)?r[e]:void 0;if(0!==i)if(i)t.push(i[2]);else{var o=new Promise((t,o)=>i=r[e]=[t,o]);t.push(i[2]=o);var n=l.p+l.u(e),a=Error();l.l(n,t=>{if(l.o(r,e)&&(0!==(i=r[e])&&(r[e]=void 0),i)){var o=t&&("load"===t.type?"missing":t.type),n=t&&t.target&&t.target.src;a.message="Loading chunk "+e+` failed.
|
|
2
|
+
(`+o+": "+n+")",a.name="ChunkLoadError",a.type=o,a.request=n,i[1](a)}},"chunk-"+e,e)}},i=(e,t)=>{var i,o,[n,a,s]=t,c=0;if(n.some(e=>0!==r[e])){for(i in a)l.o(a,i)&&(l.m[i]=a[i]);s&&s(l)}for(e&&e(t);c<n.length;c++)o=n[c],l.o(r,o)&&r[o]&&r[o][0](),r[o]=0},(o=this.webpackChunk_tsparticles_plugin_emitters=this.webpackChunk_tsparticles_plugin_emitters||[]).forEach(i.bind(null,0)),o.push=i.bind(null,o.push.bind(o));var b={};l.r(b),l.d(b,{EmitterClickMode:()=>n,EmitterShapeBase:()=>g,ensureEmittersPluginLoaded:()=>v,loadEmittersPlugin:()=>y});class g{fill;options;position;size;constructor(e,t,r,i){this.position=e,this.size=t,this.fill=r,this.options=i}resize(e,t){this.position=e,this.size=t}}async function y(e){e.checkVersion("4.0.0-beta.0"),await e.register(async e=>{let[{ensureInteractivityPluginLoaded:t},{ShapeManager:r},{EmittersInstancesManager:i},{EmittersPlugin:o}]=await Promise.all([Promise.resolve().then(l.t.bind(l,702,19)),l.e(772).then(l.bind(l,772)),l.e(784).then(l.bind(l,784)),l.e(588).then(l.bind(l,588))]),n=new i(e);t(e),e.emitterShapeManager??=new r,e.addEmitterShapeGenerator??=(t,r)=>{e.emitterShapeManager?.addShapeGenerator(t,r)},e.addPlugin(new o(n)),e.addInteractor?.("externalEmitters",async e=>{let{EmittersInteractor:t}=await l.e(526).then(l.bind(l,526));return new t(n,e)})})}function v(e){if(!e.addEmitterShapeGenerator)throw Error("tsParticles Emitters Plugin is not loaded")}return(n||(n={})).emitter="emitter",b})());
|
|
@@ -10,7 +10,12 @@ export declare class EmitterInstance {
|
|
|
10
10
|
options: Emitter;
|
|
11
11
|
position: ICoordinates;
|
|
12
12
|
size: IDimension;
|
|
13
|
-
|
|
13
|
+
spawnFillColor?: IHsl;
|
|
14
|
+
spawnFillEnabled?: boolean;
|
|
15
|
+
spawnFillOpacity?: number;
|
|
16
|
+
spawnStrokeColor?: IHsl;
|
|
17
|
+
spawnStrokeOpacity?: number;
|
|
18
|
+
spawnStrokeWidth?: number;
|
|
14
19
|
private _currentDuration;
|
|
15
20
|
private _currentEmitDelay;
|
|
16
21
|
private _currentSpawnDelay;
|
|
@@ -6,6 +6,7 @@ import type { EmitterInstance } from "./EmitterInstance.js";
|
|
|
6
6
|
import type { EmittersInstancesManager } from "./EmittersInstancesManager.js";
|
|
7
7
|
export declare class EmittersInteractor extends ExternalInteractorBase<EmitterContainer> {
|
|
8
8
|
handleClickMode: (mode: string, interactivityData: IInteractivityData) => void;
|
|
9
|
+
readonly maxDistance: number;
|
|
9
10
|
private readonly _instancesManager;
|
|
10
11
|
constructor(instancesManager: EmittersInstancesManager, container: EmitterContainer);
|
|
11
12
|
clear(): void;
|
|
@@ -3,7 +3,7 @@ import type { EmitterOptions, IEmitterOptions } from "./types.js";
|
|
|
3
3
|
import type { EmitterContainer } from "./EmitterContainer.js";
|
|
4
4
|
import type { EmittersInstancesManager } from "./EmittersInstancesManager.js";
|
|
5
5
|
export declare class EmittersPlugin implements IPlugin {
|
|
6
|
-
readonly id
|
|
6
|
+
readonly id = "emitters";
|
|
7
7
|
private readonly _instancesManager;
|
|
8
8
|
constructor(instancesManager: EmittersInstancesManager);
|
|
9
9
|
getPlugin(container: EmitterContainer): Promise<IContainerPlugin>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICoordinates, IDimension } from "@tsparticles/engine";
|
|
1
|
+
import type { Container, ICoordinates, IDimension } from "@tsparticles/engine";
|
|
2
2
|
import type { IEmitterShape } from "./IEmitterShape.js";
|
|
3
3
|
export interface IEmitterShapeGenerator<TOptions = unknown> {
|
|
4
|
-
generate(position: ICoordinates, size: IDimension, fill: boolean, options: TOptions): IEmitterShape;
|
|
4
|
+
generate(container: Container, position: ICoordinates, size: IDimension, fill: boolean, options: TOptions): IEmitterShape;
|
|
5
5
|
}
|
|
@@ -3,6 +3,7 @@ import { EmitterLife } from "./EmitterLife.js";
|
|
|
3
3
|
import { EmitterRate } from "./EmitterRate.js";
|
|
4
4
|
import { EmitterShape } from "./EmitterShape.js";
|
|
5
5
|
import { EmitterSize } from "./EmitterSize.js";
|
|
6
|
+
import { EmitterSpawn } from "./EmitterSpawn.js";
|
|
6
7
|
import type { IEmitter } from "../Interfaces/IEmitter.js";
|
|
7
8
|
export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
|
|
8
9
|
autoPlay: boolean;
|
|
@@ -16,7 +17,9 @@ export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
|
|
|
16
17
|
rate: EmitterRate;
|
|
17
18
|
shape: EmitterShape;
|
|
18
19
|
size?: EmitterSize;
|
|
19
|
-
|
|
20
|
+
spawn: EmitterSpawn;
|
|
21
|
+
spawnFillColor?: AnimatableColor;
|
|
22
|
+
spawnStrokeColor?: AnimatableColor;
|
|
20
23
|
startCount: number;
|
|
21
24
|
constructor();
|
|
22
25
|
load(data?: RecursivePartial<IEmitter>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Fill, type IOptionLoader, type RecursivePartial, Stroke } from "@tsparticles/engine";
|
|
2
|
+
import type { IEmitterSpawn } from "../Interfaces/IEmitterSpawn.js";
|
|
3
|
+
export declare class EmitterSpawn implements IEmitterSpawn, IOptionLoader<IEmitterSpawn> {
|
|
4
|
+
fill?: Fill;
|
|
5
|
+
stroke?: Stroke;
|
|
6
|
+
load(data?: RecursivePartial<IEmitterSpawn>): void;
|
|
7
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { IEmitterLife } from "./IEmitterLife.js";
|
|
|
3
3
|
import type { IEmitterRate } from "./IEmitterRate.js";
|
|
4
4
|
import type { IEmitterShape } from "./IEmitterShape.js";
|
|
5
5
|
import type { IEmitterSize } from "./IEmitterSize.js";
|
|
6
|
+
import type { IEmitterSpawn } from "./IEmitterSpawn.js";
|
|
6
7
|
export interface IEmitter {
|
|
7
8
|
autoPlay: boolean;
|
|
8
9
|
direction?: MoveDirection | keyof typeof MoveDirection | MoveDirectionAlt | number;
|
|
@@ -15,6 +16,8 @@ export interface IEmitter {
|
|
|
15
16
|
rate: IEmitterRate;
|
|
16
17
|
shape: IEmitterShape;
|
|
17
18
|
size?: IEmitterSize;
|
|
18
|
-
|
|
19
|
+
spawn: IEmitterSpawn;
|
|
20
|
+
spawnFillColor?: IAnimatableColor;
|
|
21
|
+
spawnStrokeColor?: IAnimatableColor;
|
|
19
22
|
startCount: number;
|
|
20
23
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EmittersEngine } from "./EmittersEngine.js";
|
|
2
2
|
export declare function loadEmittersPlugin(engine: EmittersEngine): Promise<void>;
|
|
3
|
+
export declare function ensureEmittersPluginLoaded(e: EmittersEngine): void;
|
|
3
4
|
export type * from "./EmitterContainer.js";
|
|
4
5
|
export * from "./EmitterShapeBase.js";
|
|
5
6
|
export type * from "./EmittersEngine.js";
|
package/umd/EmitterInstance.js
CHANGED
|
@@ -13,53 +13,54 @@
|
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
15
15
|
const EmitterSize_js_1 = require("./Options/Classes/EmitterSize.js");
|
|
16
|
-
const defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1, colorFactor = 3.6;
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
16
|
+
const defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1, colorFactor = 3.6, defaultStrokeWidth = 1;
|
|
17
|
+
function setParticlesOptionsFillColor(particlesOptions, color, opacity, enable) {
|
|
18
|
+
particlesOptions.fill = new engine_1.Fill();
|
|
19
|
+
particlesOptions.fill.color = engine_1.AnimatableColor.create(undefined, { value: color });
|
|
20
|
+
particlesOptions.fill.enable = enable;
|
|
21
|
+
particlesOptions.fill.opacity = opacity;
|
|
22
|
+
}
|
|
23
|
+
function setParticlesOptionsStrokeColor(particlesOptions, color, opacity, width) {
|
|
24
|
+
particlesOptions.stroke = new engine_1.Stroke();
|
|
25
|
+
particlesOptions.stroke.color = engine_1.AnimatableColor.create(undefined, { value: color });
|
|
26
|
+
particlesOptions.stroke.opacity = opacity;
|
|
27
|
+
particlesOptions.stroke.width = width;
|
|
26
28
|
}
|
|
27
29
|
class EmitterInstance {
|
|
30
|
+
container;
|
|
31
|
+
removeCallback;
|
|
32
|
+
fill;
|
|
33
|
+
name;
|
|
34
|
+
options;
|
|
35
|
+
position;
|
|
36
|
+
size;
|
|
37
|
+
spawnFillColor;
|
|
38
|
+
spawnFillEnabled;
|
|
39
|
+
spawnFillOpacity;
|
|
40
|
+
spawnStrokeColor;
|
|
41
|
+
spawnStrokeOpacity;
|
|
42
|
+
spawnStrokeWidth;
|
|
43
|
+
_currentDuration;
|
|
44
|
+
_currentEmitDelay;
|
|
45
|
+
_currentSpawnDelay;
|
|
46
|
+
_duration;
|
|
47
|
+
_emitDelay;
|
|
48
|
+
_engine;
|
|
49
|
+
_firstSpawn;
|
|
50
|
+
_immortal;
|
|
51
|
+
_initialPosition;
|
|
52
|
+
_lifeCount;
|
|
53
|
+
_mutationObserver;
|
|
54
|
+
_particlesOptions;
|
|
55
|
+
_paused;
|
|
56
|
+
_resizeObserver;
|
|
57
|
+
_shape;
|
|
58
|
+
_size;
|
|
59
|
+
_spawnDelay;
|
|
60
|
+
_startParticlesAdded;
|
|
28
61
|
constructor(engine, container, removeCallback, options, position) {
|
|
29
62
|
this.container = container;
|
|
30
63
|
this.removeCallback = removeCallback;
|
|
31
|
-
this._destroy = () => {
|
|
32
|
-
this._mutationObserver?.disconnect();
|
|
33
|
-
this._mutationObserver = undefined;
|
|
34
|
-
this._resizeObserver?.disconnect();
|
|
35
|
-
this._resizeObserver = undefined;
|
|
36
|
-
this.removeCallback(this);
|
|
37
|
-
this._engine.dispatchEvent("emitterDestroyed", {
|
|
38
|
-
container: this.container,
|
|
39
|
-
data: {
|
|
40
|
-
emitter: this,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
this._prepareToDie = () => {
|
|
45
|
-
if (this._paused) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const duration = this.options.life.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
|
|
49
|
-
if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
|
|
50
|
-
this._duration = duration * engine_1.millisecondsToSeconds;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
this._setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
|
|
54
|
-
const container = this.container;
|
|
55
|
-
if (!animation.enable) {
|
|
56
|
-
return initValue;
|
|
57
|
-
}
|
|
58
|
-
const colorOffset = (0, engine_1.randomInRangeValue)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = container.retina.reduceFactor
|
|
59
|
-
? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
|
|
60
|
-
: Infinity, colorSpeed = (0, engine_1.getRangeValue)(animation.speed);
|
|
61
|
-
return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
|
|
62
|
-
};
|
|
63
64
|
this._engine = engine;
|
|
64
65
|
this._currentDuration = 0;
|
|
65
66
|
this._currentEmitDelay = 0;
|
|
@@ -84,8 +85,11 @@
|
|
|
84
85
|
const particlesOptions = (0, engine_1.deepExtend)({}, this.options.particles);
|
|
85
86
|
particlesOptions.move ??= {};
|
|
86
87
|
particlesOptions.move.direction ??= this.options.direction;
|
|
87
|
-
if (this.options.
|
|
88
|
-
this.
|
|
88
|
+
if (this.options.spawn.fill?.color) {
|
|
89
|
+
this.spawnFillColor = (0, engine_1.rangeColorToHsl)(this._engine, this.options.spawn.fill.color);
|
|
90
|
+
}
|
|
91
|
+
if (this.options.spawn.stroke?.color) {
|
|
92
|
+
this.spawnStrokeColor = (0, engine_1.rangeColorToHsl)(this._engine, this.options.spawn.stroke.color);
|
|
89
93
|
}
|
|
90
94
|
this._paused = !this.options.autoPlay;
|
|
91
95
|
this._particlesOptions = particlesOptions;
|
|
@@ -111,7 +115,7 @@
|
|
|
111
115
|
}
|
|
112
116
|
const shapeOptions = this.options.shape, shapeGenerator = this._engine.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
|
|
113
117
|
if (shapeGenerator) {
|
|
114
|
-
this._shape = shapeGenerator.generate(this.position, this.size, this.fill, shapeOptions.options);
|
|
118
|
+
this._shape = shapeGenerator.generate(this.container, this.position, this.size, this.fill, shapeOptions.options);
|
|
115
119
|
}
|
|
116
120
|
this._engine.dispatchEvent("emitterCreated", {
|
|
117
121
|
container,
|
|
@@ -213,7 +217,7 @@
|
|
|
213
217
|
container: this.container,
|
|
214
218
|
});
|
|
215
219
|
this.play();
|
|
216
|
-
this._currentSpawnDelay -= this.
|
|
220
|
+
this._currentSpawnDelay -= this._spawnDelay;
|
|
217
221
|
delete this._spawnDelay;
|
|
218
222
|
}
|
|
219
223
|
}
|
|
@@ -266,6 +270,19 @@
|
|
|
266
270
|
return size;
|
|
267
271
|
})());
|
|
268
272
|
}
|
|
273
|
+
_destroy = () => {
|
|
274
|
+
this._mutationObserver?.disconnect();
|
|
275
|
+
this._mutationObserver = undefined;
|
|
276
|
+
this._resizeObserver?.disconnect();
|
|
277
|
+
this._resizeObserver = undefined;
|
|
278
|
+
this.removeCallback(this);
|
|
279
|
+
this._engine.dispatchEvent("emitterDestroyed", {
|
|
280
|
+
container: this.container,
|
|
281
|
+
data: {
|
|
282
|
+
emitter: this,
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
};
|
|
269
286
|
_emit() {
|
|
270
287
|
if (this._paused) {
|
|
271
288
|
return;
|
|
@@ -275,18 +292,36 @@
|
|
|
275
292
|
}
|
|
276
293
|
_emitParticles(quantity) {
|
|
277
294
|
const singleParticlesOptions = ((0, engine_1.itemFromSingleOrMultiple)(this._particlesOptions) ??
|
|
278
|
-
{}),
|
|
295
|
+
{}), fillHslAnimation = this.options.spawn.fill?.color.animation, fillEnabled = this.options.spawn.fill?.enable ?? !!this.options.spawn.fill?.color, fillOpacity = this.options.spawn.fill?.opacity === undefined
|
|
296
|
+
? engine_1.defaultOpacity
|
|
297
|
+
: (0, engine_1.getRangeValue)(this.options.spawn.fill.opacity), strokeHslAnimation = this.options.spawn.stroke?.color?.animation, strokeOpacity = this.options.spawn.stroke?.opacity === undefined
|
|
298
|
+
? engine_1.defaultOpacity
|
|
299
|
+
: (0, engine_1.getRangeValue)(this.options.spawn.stroke.opacity), strokeWidth = this.options.spawn.stroke?.width === undefined
|
|
300
|
+
? defaultStrokeWidth
|
|
301
|
+
: (0, engine_1.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: engine_1.hMax, s: engine_1.sMax, l: engine_1.lMax } : null, shapeOptions = this.options.shape;
|
|
279
302
|
for (let i = 0; i < quantity * reduceFactor; i++) {
|
|
280
303
|
const particlesOptions = needsCopy
|
|
281
304
|
? (0, engine_1.deepExtend)({}, singleParticlesOptions)
|
|
282
305
|
: singleParticlesOptions;
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
306
|
+
this.spawnFillOpacity = fillOpacity;
|
|
307
|
+
this.spawnFillEnabled = fillEnabled;
|
|
308
|
+
this.spawnStrokeOpacity = strokeOpacity;
|
|
309
|
+
this.spawnStrokeWidth = strokeWidth;
|
|
310
|
+
if (this.spawnFillColor) {
|
|
311
|
+
if (fillHslAnimation && maxValues) {
|
|
312
|
+
this.spawnFillColor.h = this._setColorAnimation(fillHslAnimation.h, this.spawnFillColor.h, maxValues.h, colorFactor);
|
|
313
|
+
this.spawnFillColor.s = this._setColorAnimation(fillHslAnimation.s, this.spawnFillColor.s, maxValues.s);
|
|
314
|
+
this.spawnFillColor.l = this._setColorAnimation(fillHslAnimation.l, this.spawnFillColor.l, maxValues.l);
|
|
315
|
+
}
|
|
316
|
+
setParticlesOptionsFillColor(particlesOptions, this.spawnFillColor, this.spawnFillOpacity, this.spawnFillEnabled);
|
|
317
|
+
}
|
|
318
|
+
if (this.spawnStrokeColor) {
|
|
319
|
+
if (strokeHslAnimation && maxValues) {
|
|
320
|
+
this.spawnStrokeColor.h = this._setColorAnimation(strokeHslAnimation.h, this.spawnStrokeColor.h, maxValues.h, colorFactor);
|
|
321
|
+
this.spawnStrokeColor.s = this._setColorAnimation(strokeHslAnimation.s, this.spawnStrokeColor.s, maxValues.s);
|
|
322
|
+
this.spawnStrokeColor.l = this._setColorAnimation(strokeHslAnimation.l, this.spawnStrokeColor.l, maxValues.l);
|
|
288
323
|
}
|
|
289
|
-
|
|
324
|
+
setParticlesOptionsStrokeColor(particlesOptions, this.spawnStrokeColor, this.spawnStrokeOpacity, this.spawnStrokeWidth);
|
|
290
325
|
}
|
|
291
326
|
let position = this.position;
|
|
292
327
|
if (this._shape) {
|
|
@@ -295,17 +330,7 @@
|
|
|
295
330
|
position = shapePosData.position;
|
|
296
331
|
const replaceData = shapeOptions.replace;
|
|
297
332
|
if (replaceData.color && shapePosData.color) {
|
|
298
|
-
|
|
299
|
-
}
|
|
300
|
-
if (replaceData.opacity) {
|
|
301
|
-
if (particlesOptions.opacity) {
|
|
302
|
-
particlesOptions.opacity.value = shapePosData.opacity;
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
particlesOptions.opacity = {
|
|
306
|
-
value: shapePosData.opacity,
|
|
307
|
-
};
|
|
308
|
-
}
|
|
333
|
+
setParticlesOptionsFillColor(particlesOptions, shapePosData.color, replaceData.opacity ? (shapePosData.opacity ?? engine_1.defaultOpacity) : engine_1.defaultOpacity, true);
|
|
309
334
|
}
|
|
310
335
|
}
|
|
311
336
|
else {
|
|
@@ -317,6 +342,25 @@
|
|
|
317
342
|
}
|
|
318
343
|
}
|
|
319
344
|
}
|
|
345
|
+
_prepareToDie = () => {
|
|
346
|
+
if (this._paused) {
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const duration = this.options.life.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
|
|
350
|
+
if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
|
|
351
|
+
this._duration = duration * engine_1.millisecondsToSeconds;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
_setColorAnimation = (animation, initValue, maxValue, factor = defaultColorAnimationFactor) => {
|
|
355
|
+
const container = this.container;
|
|
356
|
+
if (!animation.enable) {
|
|
357
|
+
return initValue;
|
|
358
|
+
}
|
|
359
|
+
const colorOffset = (0, engine_1.randomInRangeValue)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = container.retina.reduceFactor
|
|
360
|
+
? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
|
|
361
|
+
: Infinity, colorSpeed = (0, engine_1.getRangeValue)(animation.speed);
|
|
362
|
+
return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
|
|
363
|
+
};
|
|
320
364
|
}
|
|
321
365
|
exports.EmitterInstance = EmitterInstance;
|
|
322
366
|
});
|
package/umd/EmitterShapeBase.js
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EmitterShapeBase = void 0;
|
|
13
13
|
class EmitterShapeBase {
|
|
14
|
+
fill;
|
|
15
|
+
options;
|
|
16
|
+
position;
|
|
17
|
+
size;
|
|
14
18
|
constructor(position, size, fill, options) {
|
|
15
19
|
this.position = position;
|
|
16
20
|
this.size = size;
|
|
@@ -48,6 +48,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
48
48
|
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
49
49
|
const defaultIndex = 0;
|
|
50
50
|
class EmittersInstancesManager {
|
|
51
|
+
_containerArrays;
|
|
52
|
+
_engine;
|
|
51
53
|
constructor(engine) {
|
|
52
54
|
this._containerArrays = new Map();
|
|
53
55
|
this._engine = engine;
|
|
@@ -16,9 +16,13 @@
|
|
|
16
16
|
const constants_js_1 = require("./constants.js");
|
|
17
17
|
const emittersMode = "emitters";
|
|
18
18
|
class EmittersInteractor extends plugin_interactivity_1.ExternalInteractorBase {
|
|
19
|
+
handleClickMode;
|
|
20
|
+
maxDistance;
|
|
21
|
+
_instancesManager;
|
|
19
22
|
constructor(instancesManager, container) {
|
|
20
23
|
super(container);
|
|
21
24
|
this._instancesManager = instancesManager;
|
|
25
|
+
this.maxDistance = 0;
|
|
22
26
|
this.handleClickMode = (mode, interactivityData) => {
|
|
23
27
|
const container = this.container, options = container.actualOptions, modeEmitters = options.interactivity.modes.emitters;
|
|
24
28
|
if (!modeEmitters || mode !== emittersMode) {
|
|
@@ -89,7 +93,7 @@
|
|
|
89
93
|
options.emitters.value.push(tmp);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
|
-
else if (
|
|
96
|
+
else if ("value" in source.emitters) {
|
|
93
97
|
const emitterModeOptions = source.emitters;
|
|
94
98
|
options.emitters.random.enable = emitterModeOptions.random?.enable ?? options.emitters.random.enable;
|
|
95
99
|
options.emitters.random.count = emitterModeOptions.random?.count ?? options.emitters.random.count;
|
package/umd/EmittersPlugin.js
CHANGED
|
@@ -47,9 +47,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
47
47
|
const engine_1 = require("@tsparticles/engine");
|
|
48
48
|
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
49
49
|
class EmittersPlugin {
|
|
50
|
+
id = "emitters";
|
|
51
|
+
_instancesManager;
|
|
50
52
|
constructor(instancesManager) {
|
|
51
53
|
this._instancesManager = instancesManager;
|
|
52
|
-
this.id = "emitters";
|
|
53
54
|
}
|
|
54
55
|
async getPlugin(container) {
|
|
55
56
|
const { EmittersPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmittersPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./EmittersPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
exports.EmittersPluginInstance = void 0;
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
class EmittersPluginInstance {
|
|
15
|
+
container;
|
|
16
|
+
_instancesManager;
|
|
15
17
|
constructor(instancesManager, container) {
|
|
16
18
|
this.container = container;
|
|
17
19
|
this._instancesManager = instancesManager;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine", "./EmitterLife.js", "./EmitterRate.js", "./EmitterShape.js", "./EmitterSize.js"], factory);
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine", "./EmitterLife.js", "./EmitterRate.js", "./EmitterShape.js", "./EmitterSize.js", "./EmitterSpawn.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
@@ -15,13 +15,30 @@
|
|
|
15
15
|
const EmitterRate_js_1 = require("./EmitterRate.js");
|
|
16
16
|
const EmitterShape_js_1 = require("./EmitterShape.js");
|
|
17
17
|
const EmitterSize_js_1 = require("./EmitterSize.js");
|
|
18
|
+
const EmitterSpawn_js_1 = require("./EmitterSpawn.js");
|
|
18
19
|
class Emitter {
|
|
20
|
+
autoPlay;
|
|
21
|
+
direction;
|
|
22
|
+
domId;
|
|
23
|
+
fill;
|
|
24
|
+
life;
|
|
25
|
+
name;
|
|
26
|
+
particles;
|
|
27
|
+
position;
|
|
28
|
+
rate;
|
|
29
|
+
shape;
|
|
30
|
+
size;
|
|
31
|
+
spawn;
|
|
32
|
+
spawnFillColor;
|
|
33
|
+
spawnStrokeColor;
|
|
34
|
+
startCount;
|
|
19
35
|
constructor() {
|
|
20
36
|
this.autoPlay = true;
|
|
21
37
|
this.fill = true;
|
|
22
38
|
this.life = new EmitterLife_js_1.EmitterLife();
|
|
23
39
|
this.rate = new EmitterRate_js_1.EmitterRate();
|
|
24
40
|
this.shape = new EmitterShape_js_1.EmitterShape();
|
|
41
|
+
this.spawn = new EmitterSpawn_js_1.EmitterSpawn();
|
|
25
42
|
this.startCount = 0;
|
|
26
43
|
}
|
|
27
44
|
load(data) {
|
|
@@ -49,6 +66,7 @@
|
|
|
49
66
|
});
|
|
50
67
|
this.rate.load(data.rate);
|
|
51
68
|
this.shape.load(data.shape);
|
|
69
|
+
this.spawn.load(data.spawn);
|
|
52
70
|
if (data.position !== undefined) {
|
|
53
71
|
this.position = {};
|
|
54
72
|
if (data.position.x !== undefined) {
|
|
@@ -58,9 +76,13 @@
|
|
|
58
76
|
this.position.y = (0, engine_1.setRangeValue)(data.position.y);
|
|
59
77
|
}
|
|
60
78
|
}
|
|
61
|
-
if (data.
|
|
62
|
-
this.
|
|
63
|
-
this.
|
|
79
|
+
if (data.spawnFillColor !== undefined) {
|
|
80
|
+
this.spawnFillColor ??= new engine_1.AnimatableColor();
|
|
81
|
+
this.spawnFillColor.load(data.spawnFillColor);
|
|
82
|
+
}
|
|
83
|
+
if (data.spawnStrokeColor !== undefined) {
|
|
84
|
+
this.spawnStrokeColor ??= new engine_1.AnimatableColor();
|
|
85
|
+
this.spawnStrokeColor.load(data.spawnStrokeColor);
|
|
64
86
|
}
|
|
65
87
|
if (data.startCount !== undefined) {
|
|
66
88
|
this.startCount = data.startCount;
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const EmitterShapeReplace_js_1 = require("./EmitterShapeReplace.js");
|
|
15
15
|
class EmitterShape {
|
|
16
|
+
options;
|
|
17
|
+
replace;
|
|
18
|
+
type;
|
|
16
19
|
constructor() {
|
|
17
20
|
this.options = {};
|
|
18
21
|
this.replace = new EmitterShapeReplace_js_1.EmitterShapeReplace();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EmitterSpawn = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
class EmitterSpawn {
|
|
15
|
+
fill;
|
|
16
|
+
stroke;
|
|
17
|
+
load(data) {
|
|
18
|
+
if ((0, engine_1.isNull)(data)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (data.fill) {
|
|
22
|
+
this.fill ??= new engine_1.Fill();
|
|
23
|
+
this.fill.load(data.fill);
|
|
24
|
+
}
|
|
25
|
+
if (data.stroke) {
|
|
26
|
+
this.stroke ??= new engine_1.Stroke();
|
|
27
|
+
this.stroke.load(data.stroke);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.EmitterSpawn = EmitterSpawn;
|
|
32
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|