@tsparticles/interaction-light 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/481.min.js +1 -0
- package/621.min.js +1 -0
- package/README.md +60 -0
- package/browser/ExternalLighter.js +7 -7
- package/browser/ParticlesLighter.js +6 -6
- package/browser/Utils.js +1 -1
- package/browser/index.js +6 -6
- package/cjs/ExternalLighter.js +7 -7
- package/cjs/ParticlesLighter.js +6 -6
- package/cjs/Utils.js +1 -1
- package/cjs/index.js +6 -6
- package/dist_browser_ExternalLighter_js.js +2 -2
- package/dist_browser_ParticlesLighter_js.js +2 -2
- package/esm/ExternalLighter.js +7 -7
- package/esm/ParticlesLighter.js +6 -6
- package/esm/Utils.js +1 -1
- package/esm/index.js +6 -6
- package/package.json +5 -6
- package/report.html +84 -29
- package/tsparticles.interaction.light.js +2 -2
- package/tsparticles.interaction.light.min.js +2 -2
- package/types/ExternalLighter.d.ts +3 -3
- package/types/ParticlesLighter.d.ts +3 -3
- package/types/Utils.d.ts +3 -3
- package/396.min.js +0 -1
- package/830.min.js +0 -1
- package/umd/ExternalLighter.js +0 -66
- package/umd/Options/Classes/Light.js +0 -32
- package/umd/Options/Classes/LightArea.js +0 -33
- package/umd/Options/Classes/LightGradient.js +0 -32
- package/umd/Options/Classes/LightOptions.js +0 -12
- package/umd/Options/Classes/LightShadow.js +0 -33
- package/umd/Options/Interfaces/ILight.js +0 -12
- package/umd/Options/Interfaces/ILightArea.js +0 -12
- package/umd/Options/Interfaces/ILightGradient.js +0 -12
- package/umd/Options/Interfaces/ILightShadow.js +0 -12
- package/umd/ParticlesLighter.js +0 -57
- package/umd/Types.js +0 -12
- package/umd/Utils.js +0 -79
- package/umd/index.js +0 -69
package/481.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_light=this.webpackChunk_tsparticles_interaction_light||[]).push([[481],{481(t,e,i){i.d(e,{ParticlesLighter:()=>o});var a=i(702),r=i(303),n=i(206);class o extends a.ParticlesInteractorBase{maxDistance;_pluginManager;constructor(t,e){super(e),this._pluginManager=t,this.maxDistance=0}clear(){}init(){}interact(t,e){let i=this.container,a=i.actualOptions;if(!a.interactivity?.events.onHover.enable||"pointermove"!==e.status)return;let r=e.mouse.position;r&&i.canvas.render.draw(e=>{(0,n.No)(i,e,t,r)})}isEnabled(t,e){let i=t.interactivity,a=e.mouse,o=i.events;if(!(o.onHover.enable&&a.position))return!1;let l=(0,r.isInArray)(n.EF,o.onHover.mode);if(l&&i.modes.light){let e=i.modes.light.shadow;t.lightShadow=(0,r.rangeColorToRgb)(this._pluginManager,e.color)}return l}reset(){}}},206(t,e,i){i.d(e,{EF:()=>o,No:()=>s,tM:()=>l});var a=i(303);let r=Math.PI*a.half,n=Math.PI*a.quarter,o="light";function l(t,e,i){let r=t.actualOptions.interactivity?.modes.light?.area;if(!r)return;e.beginPath(),e.arc(i.x,i.y,r.radius,0,a.doublePI);let n=e.createRadialGradient(i.x,i.y,0,i.x,i.y,r.radius),o=t.canvas.mouseLight;o?.start&&o.stop&&(n.addColorStop(0,(0,a.getStyleFromRgb)(o.start,t.hdr)),n.addColorStop(1,(0,a.getStyleFromRgb)(o.stop,t.hdr)),e.fillStyle=n,e.fill())}function s(t,e,i,o){let l=i.getPosition(),s=t.actualOptions.interactivity?.modes.light?.shadow;if(!s)return;let h=i.lightShadow;if(!h)return;let d=i.getRadius(),c=i.sides,u=a.doublePI/c,g=-i.rotation+n,y=[];for(let t=0;t<c;t++)y.push({x:l.x+d*Math.sin(g+u*t)*1,y:l.y+d*Math.cos(g+u*t)*1});let p=[],f=s.length;for(let t of y){let e=Math.atan2(o.y-t.y,o.x-t.x),i={x:t.x+f*Math.sin(-e-r),y:t.y+f*Math.cos(-e-r)};p.push({end:i,start:t})}let x=(0,a.getStyleFromRgb)(h,t.hdr),m=p.length-1;for(let t=m,i=0;t>=0;i=t--){e.beginPath();let a=p[t],r=p[i];a&&r&&(e.moveTo(a.start.x,a.start.y),e.lineTo(r.start.x,r.start.y),e.lineTo(r.end.x,r.end.y),e.lineTo(a.end.x,a.end.y),e.fillStyle=x,e.fill())}}}}]);
|
package/621.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_interaction_light=this.webpackChunk_tsparticles_interaction_light||[]).push([[621],{621(t,e,a){a.d(e,{ExternalLighter:()=>l});var i=a(702),r=a(303),n=a(206),o=a(913);class l extends i.ExternalInteractorBase{maxDistance=0;_pluginManager;constructor(t,e){super(e),this._pluginManager=t}clear(){}init(){}interact(t){let e=this.container,a=e.actualOptions;if(!a.interactivity?.events.onHover.enable||"pointermove"!==t.status)return;let i=t.mouse.position;i&&e.canvas.render.draw(t=>{(0,n.tM)(e,t,i)})}isEnabled(t,e){let a=this.container,i=t.mouse,o=e?.interactivity??a.actualOptions.interactivity,l=o?.events;if(!(l?.onHover.enable&&i.position))return!1;let s=(0,r.isInArray)(n.EF,l.onHover.mode);if(s&&o?.modes.light){let t=o.modes.light.area.gradient;a.canvas.mouseLight={start:(0,r.rangeColorToRgb)(this._pluginManager,t.start),stop:(0,r.rangeColorToRgb)(this._pluginManager,t.stop)}}return s}loadModeOptions(t,...e){for(let a of(t.light??=new o.v,e))t.light.load(a?.light)}reset(){}}},206(t,e,a){a.d(e,{EF:()=>o,No:()=>s,tM:()=>l});var i=a(303);let r=Math.PI*i.half,n=Math.PI*i.quarter,o="light";function l(t,e,a){let r=t.actualOptions.interactivity?.modes.light?.area;if(!r)return;e.beginPath(),e.arc(a.x,a.y,r.radius,0,i.doublePI);let n=e.createRadialGradient(a.x,a.y,0,a.x,a.y,r.radius),o=t.canvas.mouseLight;o?.start&&o.stop&&(n.addColorStop(0,(0,i.getStyleFromRgb)(o.start,t.hdr)),n.addColorStop(1,(0,i.getStyleFromRgb)(o.stop,t.hdr)),e.fillStyle=n,e.fill())}function s(t,e,a,o){let l=a.getPosition(),s=t.actualOptions.interactivity?.modes.light?.shadow;if(!s)return;let h=a.lightShadow;if(!h)return;let g=a.getRadius(),d=a.sides,u=i.doublePI/d,c=-a.rotation+n,p=[];for(let t=0;t<d;t++)p.push({x:l.x+g*Math.sin(c+u*t)*1,y:l.y+g*Math.cos(c+u*t)*1});let y=[],f=s.length;for(let t of p){let e=Math.atan2(o.y-t.y,o.x-t.x),a={x:t.x+f*Math.sin(-e-r),y:t.y+f*Math.cos(-e-r)};y.push({end:a,start:t})}let v=(0,i.getStyleFromRgb)(h,t.hdr),x=y.length-1;for(let t=x,a=0;t>=0;a=t--){e.beginPath();let i=y[t],r=y[a];i&&r&&(e.moveTo(i.start.x,i.start.y),e.lineTo(r.start.x,r.start.y),e.lineTo(r.end.x,r.end.y),e.lineTo(i.end.x,i.end.y),e.fillStyle=v,e.fill())}}}}]);
|
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/tsparticles/tsparticles) interaction plugin for light effect.
|
|
10
10
|
|
|
11
|
+
## Quick checklist
|
|
12
|
+
|
|
13
|
+
1. Install `@tsparticles/engine` (or use the CDN bundle below)
|
|
14
|
+
2. Call `loadInteractivityPlugin(tsParticles)` and `loadLightInteraction(tsParticles)` before `tsParticles.load(...)`
|
|
15
|
+
3. Enable `"light"` in interactivity events and configure `interactivity.modes.light`
|
|
16
|
+
|
|
11
17
|
## How to use it
|
|
12
18
|
|
|
13
19
|
### CDN / Vanilla JS / jQuery
|
|
@@ -77,3 +83,57 @@ import { loadLightInteraction } from "@tsparticles/interaction-light";
|
|
|
77
83
|
await loadLightInteraction(tsParticles);
|
|
78
84
|
})();
|
|
79
85
|
```
|
|
86
|
+
|
|
87
|
+
## Option mapping
|
|
88
|
+
|
|
89
|
+
- Event mode key: `interactivity.events.onHover.mode` or `interactivity.events.onClick.mode` with value `"light"`
|
|
90
|
+
- Mode options key: `interactivity.modes.light`
|
|
91
|
+
|
|
92
|
+
### `interactivity.modes.light` properties
|
|
93
|
+
|
|
94
|
+
| Key | Type | Default | Notes |
|
|
95
|
+
| --------------------- | -------- | ----------- | ------------------------ |
|
|
96
|
+
| `area.radius` | `number` | `1000` | Light interaction radius |
|
|
97
|
+
| `area.gradient.start` | `color` | | Gradient start color |
|
|
98
|
+
| `area.gradient.stop` | `color` | | Gradient stop color |
|
|
99
|
+
| `shadow.color` | `color` | `"#000000"` | Shadow/tint color |
|
|
100
|
+
| `shadow.length` | `number` | `2000` | Shadow projection length |
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"interactivity": {
|
|
105
|
+
"events": {
|
|
106
|
+
"onHover": {
|
|
107
|
+
"enable": true,
|
|
108
|
+
"mode": "light"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"modes": {
|
|
112
|
+
"light": {
|
|
113
|
+
"area": {
|
|
114
|
+
"radius": 700,
|
|
115
|
+
"gradient": {
|
|
116
|
+
"start": "#ffffff",
|
|
117
|
+
"stop": "#000000"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"shadow": {
|
|
121
|
+
"color": "#000000",
|
|
122
|
+
"length": 1400
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Common pitfalls
|
|
131
|
+
|
|
132
|
+
- Calling `tsParticles.load(...)` before both `loadInteractivityPlugin(...)` and `loadLightInteraction(...)`
|
|
133
|
+
- Verify required peer packages before enabling advanced options
|
|
134
|
+
- Change one option group at a time to isolate regressions quickly
|
|
135
|
+
|
|
136
|
+
## Related docs
|
|
137
|
+
|
|
138
|
+
- All packages catalog: <https://github.com/tsparticles/tsparticles>
|
|
139
|
+
- Main docs: <https://particles.js.org/docs/>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
2
1
|
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
3
3
|
import { drawLight, lightMode } from "./Utils.js";
|
|
4
4
|
import { Light } from "./Options/Classes/Light.js";
|
|
5
5
|
export class ExternalLighter extends ExternalInteractorBase {
|
|
6
6
|
maxDistance = 0;
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
7
|
+
_pluginManager;
|
|
8
|
+
constructor(pluginManager, container) {
|
|
9
9
|
super(container);
|
|
10
|
-
this.
|
|
10
|
+
this._pluginManager = pluginManager;
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
13
13
|
}
|
|
@@ -22,7 +22,7 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
22
22
|
if (!mousePos) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
container.canvas.draw(ctx => {
|
|
25
|
+
container.canvas.render.draw(ctx => {
|
|
26
26
|
drawLight(container, ctx, mousePos);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -35,8 +35,8 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
35
35
|
if (res && interactivity?.modes.light) {
|
|
36
36
|
const lightGradient = interactivity.modes.light.area.gradient;
|
|
37
37
|
container.canvas.mouseLight = {
|
|
38
|
-
start: rangeColorToRgb(this.
|
|
39
|
-
stop: rangeColorToRgb(this.
|
|
38
|
+
start: rangeColorToRgb(this._pluginManager, lightGradient.start),
|
|
39
|
+
stop: rangeColorToRgb(this._pluginManager, lightGradient.stop),
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
return res;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
2
1
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
3
3
|
import { drawParticleShadow, lightMode } from "./Utils.js";
|
|
4
4
|
export class ParticlesLighter extends ParticlesInteractorBase {
|
|
5
5
|
maxDistance;
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
6
|
+
_pluginManager;
|
|
7
|
+
constructor(pluginManager, container) {
|
|
8
8
|
super(container);
|
|
9
|
-
this.
|
|
9
|
+
this._pluginManager = pluginManager;
|
|
10
10
|
this.maxDistance = 0;
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
@@ -22,7 +22,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
22
22
|
if (!mousePos) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
container.canvas.draw(ctx => {
|
|
25
|
+
container.canvas.render.draw(ctx => {
|
|
26
26
|
drawParticleShadow(container, ctx, particle, mousePos);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -34,7 +34,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
34
34
|
const res = isInArray(lightMode, events.onHover.mode);
|
|
35
35
|
if (res && interactivity.modes.light) {
|
|
36
36
|
const shadowOptions = interactivity.modes.light.shadow;
|
|
37
|
-
particle.lightShadow = rangeColorToRgb(this.
|
|
37
|
+
particle.lightShadow = rangeColorToRgb(this._pluginManager, shadowOptions.color);
|
|
38
38
|
}
|
|
39
39
|
return res;
|
|
40
40
|
}
|
package/browser/Utils.js
CHANGED
package/browser/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export async function loadLightInteraction(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 { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
6
|
-
e.addInteractor?.("externalLight", async (container) => {
|
|
6
|
+
e.pluginManager.addInteractor?.("externalLight", async (container) => {
|
|
7
7
|
const { ExternalLighter } = await import("./ExternalLighter.js");
|
|
8
|
-
return new ExternalLighter(
|
|
8
|
+
return new ExternalLighter(e.pluginManager, container);
|
|
9
9
|
});
|
|
10
|
-
e.addInteractor?.("particlesLight", async (container) => {
|
|
10
|
+
e.pluginManager.addInteractor?.("particlesLight", async (container) => {
|
|
11
11
|
const { ParticlesLighter } = await import("./ParticlesLighter.js");
|
|
12
|
-
return new ParticlesLighter(
|
|
12
|
+
return new ParticlesLighter(e.pluginManager, container);
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
}
|
package/cjs/ExternalLighter.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
2
1
|
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
3
3
|
import { drawLight, lightMode } from "./Utils.js";
|
|
4
4
|
import { Light } from "./Options/Classes/Light.js";
|
|
5
5
|
export class ExternalLighter extends ExternalInteractorBase {
|
|
6
6
|
maxDistance = 0;
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
7
|
+
_pluginManager;
|
|
8
|
+
constructor(pluginManager, container) {
|
|
9
9
|
super(container);
|
|
10
|
-
this.
|
|
10
|
+
this._pluginManager = pluginManager;
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
13
13
|
}
|
|
@@ -22,7 +22,7 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
22
22
|
if (!mousePos) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
container.canvas.draw(ctx => {
|
|
25
|
+
container.canvas.render.draw(ctx => {
|
|
26
26
|
drawLight(container, ctx, mousePos);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -35,8 +35,8 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
35
35
|
if (res && interactivity?.modes.light) {
|
|
36
36
|
const lightGradient = interactivity.modes.light.area.gradient;
|
|
37
37
|
container.canvas.mouseLight = {
|
|
38
|
-
start: rangeColorToRgb(this.
|
|
39
|
-
stop: rangeColorToRgb(this.
|
|
38
|
+
start: rangeColorToRgb(this._pluginManager, lightGradient.start),
|
|
39
|
+
stop: rangeColorToRgb(this._pluginManager, lightGradient.stop),
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
return res;
|
package/cjs/ParticlesLighter.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
2
1
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
3
3
|
import { drawParticleShadow, lightMode } from "./Utils.js";
|
|
4
4
|
export class ParticlesLighter extends ParticlesInteractorBase {
|
|
5
5
|
maxDistance;
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
6
|
+
_pluginManager;
|
|
7
|
+
constructor(pluginManager, container) {
|
|
8
8
|
super(container);
|
|
9
|
-
this.
|
|
9
|
+
this._pluginManager = pluginManager;
|
|
10
10
|
this.maxDistance = 0;
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
@@ -22,7 +22,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
22
22
|
if (!mousePos) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
container.canvas.draw(ctx => {
|
|
25
|
+
container.canvas.render.draw(ctx => {
|
|
26
26
|
drawParticleShadow(container, ctx, particle, mousePos);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -34,7 +34,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
34
34
|
const res = isInArray(lightMode, events.onHover.mode);
|
|
35
35
|
if (res && interactivity.modes.light) {
|
|
36
36
|
const shadowOptions = interactivity.modes.light.shadow;
|
|
37
|
-
particle.lightShadow = rangeColorToRgb(this.
|
|
37
|
+
particle.lightShadow = rangeColorToRgb(this._pluginManager, shadowOptions.color);
|
|
38
38
|
}
|
|
39
39
|
return res;
|
|
40
40
|
}
|
package/cjs/Utils.js
CHANGED
package/cjs/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export async function loadLightInteraction(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 { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
6
|
-
e.addInteractor?.("externalLight", async (container) => {
|
|
6
|
+
e.pluginManager.addInteractor?.("externalLight", async (container) => {
|
|
7
7
|
const { ExternalLighter } = await import("./ExternalLighter.js");
|
|
8
|
-
return new ExternalLighter(
|
|
8
|
+
return new ExternalLighter(e.pluginManager, container);
|
|
9
9
|
});
|
|
10
|
-
e.addInteractor?.("particlesLight", async (container) => {
|
|
10
|
+
e.pluginManager.addInteractor?.("particlesLight", async (container) => {
|
|
11
11
|
const { ParticlesLighter } = await import("./ParticlesLighter.js");
|
|
12
|
-
return new ParticlesLighter(
|
|
12
|
+
return new ParticlesLighter(e.pluginManager, container);
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -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.
|
|
7
|
+
* v4.0.0-beta.10
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\*****************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExternalLighter: () => (/* binding */ ExternalLighter)\n/* harmony export */ });\n/* harmony import */ var
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ExternalLighter: () => (/* binding */ ExternalLighter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n/* harmony import */ var _Options_Classes_Light_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Options/Classes/Light.js */ \"./dist/browser/Options/Classes/Light.js\");\n\n\n\n\nclass ExternalLighter extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.ExternalInteractorBase {\n maxDistance = 0;\n _pluginManager;\n constructor(pluginManager, container){\n super(container);\n this._pluginManager = pluginManager;\n }\n clear() {}\n init() {}\n interact(interactivityData) {\n const container = this.container, options = container.actualOptions, interactivity = interactivityData;\n if (!options.interactivity?.events.onHover.enable || interactivity.status !== \"pointermove\") {\n return;\n }\n const mousePos = interactivity.mouse.position;\n if (!mousePos) {\n return;\n }\n container.canvas.render.draw((ctx)=>{\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.drawLight)(container, ctx, mousePos);\n });\n }\n isEnabled(interactivityData, particle) {\n const container = this.container, mouse = interactivityData.mouse, interactivity = particle?.interactivity ?? container.actualOptions.interactivity, events = interactivity?.events;\n if (!(events?.onHover.enable && mouse.position)) {\n return false;\n }\n const res = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isInArray)(_Utils_js__WEBPACK_IMPORTED_MODULE_2__.lightMode, events.onHover.mode);\n if (res && interactivity?.modes.light) {\n const lightGradient = interactivity.modes.light.area.gradient;\n container.canvas.mouseLight = {\n start: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.rangeColorToRgb)(this._pluginManager, lightGradient.start),\n stop: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.rangeColorToRgb)(this._pluginManager, lightGradient.stop)\n };\n }\n return res;\n }\n loadModeOptions(options, ...sources) {\n options.light ??= new _Options_Classes_Light_js__WEBPACK_IMPORTED_MODULE_3__.Light();\n for (const source of sources){\n options.light.load(source?.light);\n }\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-light/./dist/browser/ExternalLighter.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -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.
|
|
7
|
+
* v4.0.0-beta.10
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\******************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesLighter: () => (/* binding */ ParticlesLighter)\n/* harmony export */ });\n/* harmony import */ var
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ ParticlesLighter: () => (/* binding */ ParticlesLighter)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\nclass ParticlesLighter extends _tsparticles_plugin_interactivity__WEBPACK_IMPORTED_MODULE_0__.ParticlesInteractorBase {\n maxDistance;\n _pluginManager;\n constructor(pluginManager, container){\n super(container);\n this._pluginManager = pluginManager;\n this.maxDistance = 0;\n }\n clear() {}\n init() {}\n interact(particle, interactivityData) {\n const container = this.container, options = container.actualOptions;\n if (!options.interactivity?.events.onHover.enable || interactivityData.status !== \"pointermove\") {\n return;\n }\n const mousePos = interactivityData.mouse.position;\n if (!mousePos) {\n return;\n }\n container.canvas.render.draw((ctx)=>{\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_2__.drawParticleShadow)(container, ctx, particle, mousePos);\n });\n }\n isEnabled(particle, interactivityData) {\n const interactivity = particle.interactivity, mouse = interactivityData.mouse, events = interactivity.events;\n if (!(events.onHover.enable && mouse.position)) {\n return false;\n }\n const res = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.isInArray)(_Utils_js__WEBPACK_IMPORTED_MODULE_2__.lightMode, events.onHover.mode);\n if (res && interactivity.modes.light) {\n const shadowOptions = interactivity.modes.light.shadow;\n particle.lightShadow = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_1__.rangeColorToRgb)(this._pluginManager, shadowOptions.color);\n }\n return res;\n }\n reset() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-light/./dist/browser/ParticlesLighter.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
package/esm/ExternalLighter.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
2
1
|
import { ExternalInteractorBase, } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
3
3
|
import { drawLight, lightMode } from "./Utils.js";
|
|
4
4
|
import { Light } from "./Options/Classes/Light.js";
|
|
5
5
|
export class ExternalLighter extends ExternalInteractorBase {
|
|
6
6
|
maxDistance = 0;
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
7
|
+
_pluginManager;
|
|
8
|
+
constructor(pluginManager, container) {
|
|
9
9
|
super(container);
|
|
10
|
-
this.
|
|
10
|
+
this._pluginManager = pluginManager;
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
13
13
|
}
|
|
@@ -22,7 +22,7 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
22
22
|
if (!mousePos) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
container.canvas.draw(ctx => {
|
|
25
|
+
container.canvas.render.draw(ctx => {
|
|
26
26
|
drawLight(container, ctx, mousePos);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -35,8 +35,8 @@ export class ExternalLighter extends ExternalInteractorBase {
|
|
|
35
35
|
if (res && interactivity?.modes.light) {
|
|
36
36
|
const lightGradient = interactivity.modes.light.area.gradient;
|
|
37
37
|
container.canvas.mouseLight = {
|
|
38
|
-
start: rangeColorToRgb(this.
|
|
39
|
-
stop: rangeColorToRgb(this.
|
|
38
|
+
start: rangeColorToRgb(this._pluginManager, lightGradient.start),
|
|
39
|
+
stop: rangeColorToRgb(this._pluginManager, lightGradient.stop),
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
42
|
return res;
|
package/esm/ParticlesLighter.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
2
1
|
import { ParticlesInteractorBase } from "@tsparticles/plugin-interactivity";
|
|
2
|
+
import { isInArray, rangeColorToRgb } from "@tsparticles/engine";
|
|
3
3
|
import { drawParticleShadow, lightMode } from "./Utils.js";
|
|
4
4
|
export class ParticlesLighter extends ParticlesInteractorBase {
|
|
5
5
|
maxDistance;
|
|
6
|
-
|
|
7
|
-
constructor(
|
|
6
|
+
_pluginManager;
|
|
7
|
+
constructor(pluginManager, container) {
|
|
8
8
|
super(container);
|
|
9
|
-
this.
|
|
9
|
+
this._pluginManager = pluginManager;
|
|
10
10
|
this.maxDistance = 0;
|
|
11
11
|
}
|
|
12
12
|
clear() {
|
|
@@ -22,7 +22,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
22
22
|
if (!mousePos) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
container.canvas.draw(ctx => {
|
|
25
|
+
container.canvas.render.draw(ctx => {
|
|
26
26
|
drawParticleShadow(container, ctx, particle, mousePos);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
@@ -34,7 +34,7 @@ export class ParticlesLighter extends ParticlesInteractorBase {
|
|
|
34
34
|
const res = isInArray(lightMode, events.onHover.mode);
|
|
35
35
|
if (res && interactivity.modes.light) {
|
|
36
36
|
const shadowOptions = interactivity.modes.light.shadow;
|
|
37
|
-
particle.lightShadow = rangeColorToRgb(this.
|
|
37
|
+
particle.lightShadow = rangeColorToRgb(this._pluginManager, shadowOptions.color);
|
|
38
38
|
}
|
|
39
39
|
return res;
|
|
40
40
|
}
|
package/esm/Utils.js
CHANGED
package/esm/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export async function loadLightInteraction(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 { ensureInteractivityPluginLoaded } = await import("@tsparticles/plugin-interactivity");
|
|
5
5
|
ensureInteractivityPluginLoaded(e);
|
|
6
|
-
e.addInteractor?.("externalLight", async (container) => {
|
|
6
|
+
e.pluginManager.addInteractor?.("externalLight", async (container) => {
|
|
7
7
|
const { ExternalLighter } = await import("./ExternalLighter.js");
|
|
8
|
-
return new ExternalLighter(
|
|
8
|
+
return new ExternalLighter(e.pluginManager, container);
|
|
9
9
|
});
|
|
10
|
-
e.addInteractor?.("particlesLight", async (container) => {
|
|
10
|
+
e.pluginManager.addInteractor?.("particlesLight", async (container) => {
|
|
11
11
|
const { ParticlesLighter } = await import("./ParticlesLighter.js");
|
|
12
|
-
return new ParticlesLighter(
|
|
12
|
+
return new ParticlesLighter(e.pluginManager, container);
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/interaction-light",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"description": "tsParticles Light interaction",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -95,14 +95,13 @@
|
|
|
95
95
|
"browser": "./browser/index.js",
|
|
96
96
|
"import": "./esm/index.js",
|
|
97
97
|
"require": "./cjs/index.js",
|
|
98
|
-
"
|
|
99
|
-
"default": "./cjs/index.js"
|
|
98
|
+
"default": "./esm/index.js"
|
|
100
99
|
},
|
|
101
100
|
"./package.json": "./package.json"
|
|
102
101
|
},
|
|
103
|
-
"
|
|
104
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
105
|
-
"@tsparticles/plugin-interactivity": "4.0.0-beta.
|
|
102
|
+
"peerDependencies": {
|
|
103
|
+
"@tsparticles/engine": "4.0.0-beta.10",
|
|
104
|
+
"@tsparticles/plugin-interactivity": "4.0.0-beta.10"
|
|
106
105
|
},
|
|
107
106
|
"publishConfig": {
|
|
108
107
|
"access": "public"
|