@tsparticles/updater-orbit 3.9.1 → 4.0.0-alpha.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/604.min.js +2 -0
- package/604.min.js.LICENSE.txt +1 -0
- package/browser/OrbitUpdater.js +5 -9
- package/browser/Utils.js +2 -2
- package/browser/index.js +8 -6
- package/cjs/Enums.js +2 -5
- package/cjs/Options/Classes/Orbit.js +10 -14
- package/cjs/Options/Classes/OrbitRotation.js +3 -7
- package/cjs/Options/Interfaces/IOrbit.js +1 -2
- package/cjs/OrbitUpdater.js +20 -28
- package/cjs/Types.js +1 -2
- package/cjs/Utils.js +5 -8
- package/cjs/index.js +8 -9
- package/dist_browser_OrbitUpdater_js.js +70 -0
- package/esm/OrbitUpdater.js +5 -9
- package/esm/Utils.js +2 -2
- package/esm/index.js +8 -6
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.updater.orbit.js +209 -70
- package/tsparticles.updater.orbit.min.js +1 -1
- package/tsparticles.updater.orbit.min.js.LICENSE.txt +1 -1
- package/types/OrbitUpdater.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/umd/OrbitUpdater.js +7 -11
- package/umd/Utils.js +2 -2
- package/umd/index.js +43 -7
package/604.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see 604.min.js.LICENSE.txt */
|
|
2
|
+
(this.webpackChunk_tsparticles_updater_orbit=this.webpackChunk_tsparticles_updater_orbit||[]).push([[604],{604(t,i,o){o.d(i,{OrbitUpdater:()=>d});var a,e=o(303);class n extends e.ValueWithRandom{constructor(){super(),this.value=45}load(t){(0,e.isNull)(t)||super.load(t)}}class r{constructor(){this.animation=new e.AnimationOptions,this.enable=!1,this.opacity=1,this.rotation=new n,this.width=1}load(t){(0,e.isNull)(t)||(this.animation.load(t.animation),this.rotation.load(t.rotation),void 0!==t.enable&&(this.enable=t.enable),void 0!==t.opacity&&(this.opacity=(0,e.setRangeValue)(t.opacity)),void 0!==t.width&&(this.width=(0,e.setRangeValue)(t.width)),void 0!==t.radius&&(this.radius=(0,e.setRangeValue)(t.radius)),void 0!==t.color&&(this.color=e.OptionsColor.create(this.color,t.color)))}}!function(t){t.front="front",t.back="back"}(a||(a={}));const s=Math.PI*e.half,l=Math.PI+s;class d{constructor(t,i){this._engine=t,this._container=i}afterDraw(t){const i=t.options.orbit;i?.enable&&this.drawOrbit(t,a.front)}beforeDraw(t){const i=t.options.orbit;i?.enable&&this.drawOrbit(t,a.back)}drawOrbit(t,i){const o=this._container;let n,r;switch(i){case a.back:n=s,r=l;break;case a.front:n=l,r=s;break;default:n=0,r=e.doublePI}o.canvas.draw((i=>{!function(t,i,o,a,n,r,s,l,d){if(r<=0)return;const b=i.getPosition(),{container:c}=i;o&&(t.strokeStyle=(0,e.getStyleFromHsl)(o,c.hdr,n)),t.lineWidth=r;const u=(0,e.degToRad)(s);t.beginPath(),t.ellipse(b.x,b.y,.5*a,2*a,u,l,d),t.stroke()}(i,t,t.orbitColor??t.getFillColor(),t.retina.orbitRadius??o.retina.orbitRadius??t.getRadius(),t.orbitOpacity??e.defaultOpacity,t.orbitWidth??1,(t.orbitRotation??0)*o.retina.pixelRatio,n,r)}))}init(t){const i=this._container,o=t.options.orbit;o?.enable&&(t.orbitRotation=(0,e.getRangeValue)(o.rotation.value),t.orbitColor=(0,e.rangeColorToHsl)(this._engine,o.color),t.retina.orbitRadius=void 0!==o.radius?(0,e.getRangeValue)(o.radius)*i.retina.pixelRatio:void 0,i.retina.orbitRadius=t.retina.orbitRadius,t.orbitAnimationSpeed=o.animation.enable?(0,e.getRangeValue)(o.animation.speed):0,t.orbitWidth=(0,e.getRangeValue)(o.width),t.orbitOpacity=(0,e.getRangeValue)(o.opacity))}isEnabled(t){const i=t.options.orbit?.animation;return!t.destroyed&&!t.spawning&&!!i?.enable}loadOptions(t,...i){t.orbit??=new r;for(const o of i)t.orbit.load(o?.orbit)}update(t,i){this.isEnabled(t)&&(t.orbitRotation??=0,t.orbitRotation+=(t.orbitAnimationSpeed??0/e.doublePI)*i.factor)}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Orbit Updater v4.0.0-alpha.0 by Matteo Bruni */
|
package/browser/OrbitUpdater.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getRangeValue, rangeColorToHsl, } from "@tsparticles/engine";
|
|
1
|
+
import { defaultOpacity, doublePI, getRangeValue, half, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
2
|
import { Orbit } from "./Options/Classes/Orbit.js";
|
|
3
3
|
import { OrbitType } from "./Enums.js";
|
|
4
4
|
import { drawEllipse } from "./Utils.js";
|
|
5
|
-
const
|
|
5
|
+
const defaultOrbitSpeed = 0, halfPI = Math.PI * half, piAndAHalf = Math.PI + halfPI, startAngle = 0, defaultWidth = 1, defaultRotation = 0;
|
|
6
6
|
export class OrbitUpdater {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(engine, container) {
|
|
8
8
|
this._engine = engine;
|
|
9
9
|
this._container = container;
|
|
10
10
|
}
|
|
@@ -63,9 +63,7 @@ export class OrbitUpdater {
|
|
|
63
63
|
return !particle.destroyed && !particle.spawning && !!orbitAnimations?.enable;
|
|
64
64
|
}
|
|
65
65
|
loadOptions(options, ...sources) {
|
|
66
|
-
|
|
67
|
-
options.orbit = new Orbit();
|
|
68
|
-
}
|
|
66
|
+
options.orbit ??= new Orbit();
|
|
69
67
|
for (const source of sources) {
|
|
70
68
|
options.orbit.load(source?.orbit);
|
|
71
69
|
}
|
|
@@ -74,9 +72,7 @@ export class OrbitUpdater {
|
|
|
74
72
|
if (!this.isEnabled(particle)) {
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
77
|
-
|
|
78
|
-
particle.orbitRotation = defaultRotation;
|
|
79
|
-
}
|
|
75
|
+
particle.orbitRotation ??= defaultRotation;
|
|
80
76
|
particle.orbitRotation += (particle.orbitAnimationSpeed ?? defaultOrbitSpeed / doublePI) * delta.factor;
|
|
81
77
|
}
|
|
82
78
|
}
|
package/browser/Utils.js
CHANGED
|
@@ -4,9 +4,9 @@ export function drawEllipse(context, particle, fillColorValue, radius, opacity,
|
|
|
4
4
|
if (width <= minWidth) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
const pos = particle.getPosition();
|
|
7
|
+
const pos = particle.getPosition(), { container } = particle;
|
|
8
8
|
if (fillColorValue) {
|
|
9
|
-
context.strokeStyle = getStyleFromHsl(fillColorValue, opacity);
|
|
9
|
+
context.strokeStyle = getStyleFromHsl(fillColorValue, container.hdr, opacity);
|
|
10
10
|
}
|
|
11
11
|
context.lineWidth = width;
|
|
12
12
|
const rotationRadian = degToRad(rotation);
|
package/browser/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadOrbitUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("orbit", async (container) => {
|
|
5
|
+
const { OrbitUpdater } = await import("./OrbitUpdater.js");
|
|
6
|
+
return new OrbitUpdater(e, container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/cjs/Enums.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OrbitType = void 0;
|
|
4
|
-
var OrbitType;
|
|
1
|
+
export var OrbitType;
|
|
5
2
|
(function (OrbitType) {
|
|
6
3
|
OrbitType["front"] = "front";
|
|
7
4
|
OrbitType["back"] = "back";
|
|
8
|
-
})(OrbitType || (
|
|
5
|
+
})(OrbitType || (OrbitType = {}));
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const OrbitRotation_js_1 = require("./OrbitRotation.js");
|
|
6
|
-
class Orbit {
|
|
1
|
+
import { AnimationOptions, OptionsColor, isNull, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
+
import { OrbitRotation } from "./OrbitRotation.js";
|
|
3
|
+
export class Orbit {
|
|
7
4
|
constructor() {
|
|
8
|
-
this.animation = new
|
|
5
|
+
this.animation = new AnimationOptions();
|
|
9
6
|
this.enable = false;
|
|
10
7
|
this.opacity = 1;
|
|
11
|
-
this.rotation = new
|
|
8
|
+
this.rotation = new OrbitRotation();
|
|
12
9
|
this.width = 1;
|
|
13
10
|
}
|
|
14
11
|
load(data) {
|
|
15
|
-
if (
|
|
12
|
+
if (isNull(data)) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
15
|
this.animation.load(data.animation);
|
|
@@ -21,17 +18,16 @@ class Orbit {
|
|
|
21
18
|
this.enable = data.enable;
|
|
22
19
|
}
|
|
23
20
|
if (data.opacity !== undefined) {
|
|
24
|
-
this.opacity =
|
|
21
|
+
this.opacity = setRangeValue(data.opacity);
|
|
25
22
|
}
|
|
26
23
|
if (data.width !== undefined) {
|
|
27
|
-
this.width =
|
|
24
|
+
this.width = setRangeValue(data.width);
|
|
28
25
|
}
|
|
29
26
|
if (data.radius !== undefined) {
|
|
30
|
-
this.radius =
|
|
27
|
+
this.radius = setRangeValue(data.radius);
|
|
31
28
|
}
|
|
32
29
|
if (data.color !== undefined) {
|
|
33
|
-
this.color =
|
|
30
|
+
this.color = OptionsColor.create(this.color, data.color);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.Orbit = Orbit;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.OrbitRotation = void 0;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
class OrbitRotation extends engine_1.ValueWithRandom {
|
|
1
|
+
import { ValueWithRandom, isNull } from "@tsparticles/engine";
|
|
2
|
+
export class OrbitRotation extends ValueWithRandom {
|
|
6
3
|
constructor() {
|
|
7
4
|
super();
|
|
8
5
|
this.value = 45;
|
|
9
6
|
}
|
|
10
7
|
load(data) {
|
|
11
|
-
if (
|
|
8
|
+
if (isNull(data)) {
|
|
12
9
|
return;
|
|
13
10
|
}
|
|
14
11
|
super.load(data);
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
exports.OrbitRotation = OrbitRotation;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/OrbitUpdater.js
CHANGED
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const double = 2, half = 0.5, doublePI = Math.PI * double, defaultOrbitSpeed = 0, halfPI = Math.PI * half, piAndAHalf = Math.PI + halfPI, startAngle = 0, defaultOpacity = 1, defaultWidth = 1, defaultRotation = 0;
|
|
9
|
-
class OrbitUpdater {
|
|
10
|
-
constructor(container, engine) {
|
|
1
|
+
import { defaultOpacity, doublePI, getRangeValue, half, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
|
+
import { Orbit } from "./Options/Classes/Orbit.js";
|
|
3
|
+
import { OrbitType } from "./Enums.js";
|
|
4
|
+
import { drawEllipse } from "./Utils.js";
|
|
5
|
+
const defaultOrbitSpeed = 0, halfPI = Math.PI * half, piAndAHalf = Math.PI + halfPI, startAngle = 0, defaultWidth = 1, defaultRotation = 0;
|
|
6
|
+
export class OrbitUpdater {
|
|
7
|
+
constructor(engine, container) {
|
|
11
8
|
this._engine = engine;
|
|
12
9
|
this._container = container;
|
|
13
10
|
}
|
|
14
11
|
afterDraw(particle) {
|
|
15
12
|
const orbitOptions = particle.options.orbit;
|
|
16
13
|
if (orbitOptions?.enable) {
|
|
17
|
-
this.drawOrbit(particle,
|
|
14
|
+
this.drawOrbit(particle, OrbitType.front);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
17
|
beforeDraw(particle) {
|
|
21
18
|
const orbitOptions = particle.options.orbit;
|
|
22
19
|
if (orbitOptions?.enable) {
|
|
23
|
-
this.drawOrbit(particle,
|
|
20
|
+
this.drawOrbit(particle, OrbitType.back);
|
|
24
21
|
}
|
|
25
22
|
}
|
|
26
23
|
drawOrbit(particle, type) {
|
|
27
24
|
const container = this._container;
|
|
28
25
|
let start, end;
|
|
29
26
|
switch (type) {
|
|
30
|
-
case
|
|
27
|
+
case OrbitType.back:
|
|
31
28
|
start = halfPI;
|
|
32
29
|
end = piAndAHalf;
|
|
33
30
|
break;
|
|
34
|
-
case
|
|
31
|
+
case OrbitType.front:
|
|
35
32
|
start = piAndAHalf;
|
|
36
33
|
end = halfPI;
|
|
37
34
|
break;
|
|
@@ -40,7 +37,7 @@ class OrbitUpdater {
|
|
|
40
37
|
end = doublePI;
|
|
41
38
|
}
|
|
42
39
|
container.canvas.draw(ctx => {
|
|
43
|
-
|
|
40
|
+
drawEllipse(ctx, particle, particle.orbitColor ?? particle.getFillColor(), particle.retina.orbitRadius ?? container.retina.orbitRadius ?? particle.getRadius(), particle.orbitOpacity ?? defaultOpacity, particle.orbitWidth ?? defaultWidth, (particle.orbitRotation ?? defaultRotation) * container.retina.pixelRatio, start, end);
|
|
44
41
|
});
|
|
45
42
|
}
|
|
46
43
|
init(particle) {
|
|
@@ -48,27 +45,25 @@ class OrbitUpdater {
|
|
|
48
45
|
if (!orbitOptions?.enable) {
|
|
49
46
|
return;
|
|
50
47
|
}
|
|
51
|
-
particle.orbitRotation =
|
|
52
|
-
particle.orbitColor =
|
|
48
|
+
particle.orbitRotation = getRangeValue(orbitOptions.rotation.value);
|
|
49
|
+
particle.orbitColor = rangeColorToHsl(this._engine, orbitOptions.color);
|
|
53
50
|
particle.retina.orbitRadius =
|
|
54
51
|
orbitOptions.radius !== undefined
|
|
55
|
-
?
|
|
52
|
+
? getRangeValue(orbitOptions.radius) * container.retina.pixelRatio
|
|
56
53
|
: undefined;
|
|
57
54
|
container.retina.orbitRadius = particle.retina.orbitRadius;
|
|
58
55
|
particle.orbitAnimationSpeed = orbitOptions.animation.enable
|
|
59
|
-
?
|
|
56
|
+
? getRangeValue(orbitOptions.animation.speed)
|
|
60
57
|
: defaultOrbitSpeed;
|
|
61
|
-
particle.orbitWidth =
|
|
62
|
-
particle.orbitOpacity =
|
|
58
|
+
particle.orbitWidth = getRangeValue(orbitOptions.width);
|
|
59
|
+
particle.orbitOpacity = getRangeValue(orbitOptions.opacity);
|
|
63
60
|
}
|
|
64
61
|
isEnabled(particle) {
|
|
65
62
|
const orbitAnimations = particle.options.orbit?.animation;
|
|
66
63
|
return !particle.destroyed && !particle.spawning && !!orbitAnimations?.enable;
|
|
67
64
|
}
|
|
68
65
|
loadOptions(options, ...sources) {
|
|
69
|
-
|
|
70
|
-
options.orbit = new Orbit_js_1.Orbit();
|
|
71
|
-
}
|
|
66
|
+
options.orbit ??= new Orbit();
|
|
72
67
|
for (const source of sources) {
|
|
73
68
|
options.orbit.load(source?.orbit);
|
|
74
69
|
}
|
|
@@ -77,10 +72,7 @@ class OrbitUpdater {
|
|
|
77
72
|
if (!this.isEnabled(particle)) {
|
|
78
73
|
return;
|
|
79
74
|
}
|
|
80
|
-
|
|
81
|
-
particle.orbitRotation = defaultRotation;
|
|
82
|
-
}
|
|
75
|
+
particle.orbitRotation ??= defaultRotation;
|
|
83
76
|
particle.orbitRotation += (particle.orbitAnimationSpeed ?? defaultOrbitSpeed / doublePI) * delta.factor;
|
|
84
77
|
}
|
|
85
78
|
}
|
|
86
|
-
exports.OrbitUpdater = OrbitUpdater;
|
package/cjs/Types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/cjs/Utils.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.drawEllipse = drawEllipse;
|
|
4
|
-
const engine_1 = require("@tsparticles/engine");
|
|
1
|
+
import { degToRad, getStyleFromHsl } from "@tsparticles/engine";
|
|
5
2
|
const minWidth = 0, half = 0.5, double = 2;
|
|
6
|
-
function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
|
|
3
|
+
export function drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {
|
|
7
4
|
if (width <= minWidth) {
|
|
8
5
|
return;
|
|
9
6
|
}
|
|
10
|
-
const pos = particle.getPosition();
|
|
7
|
+
const pos = particle.getPosition(), { container } = particle;
|
|
11
8
|
if (fillColorValue) {
|
|
12
|
-
context.strokeStyle = (
|
|
9
|
+
context.strokeStyle = getStyleFromHsl(fillColorValue, container.hdr, opacity);
|
|
13
10
|
}
|
|
14
11
|
context.lineWidth = width;
|
|
15
|
-
const rotationRadian =
|
|
12
|
+
const rotationRadian = degToRad(rotation);
|
|
16
13
|
context.beginPath();
|
|
17
14
|
context.ellipse(pos.x, pos.y, radius * half, radius * double, rotationRadian, start, end);
|
|
18
15
|
context.stroke();
|
package/cjs/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}, refresh);
|
|
1
|
+
export function loadOrbitUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("orbit", async (container) => {
|
|
5
|
+
const { OrbitUpdater } = await import("./OrbitUpdater.js");
|
|
6
|
+
return new OrbitUpdater(e, container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
10
9
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Author : Matteo Bruni
|
|
3
|
+
* MIT license: https://opensource.org/licenses/MIT
|
|
4
|
+
* Demo / Generator : https://particles.js.org/
|
|
5
|
+
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
|
+
* How to use? : Check the GitHub README
|
|
7
|
+
* v4.0.0-alpha.0
|
|
8
|
+
*/
|
|
9
|
+
"use strict";
|
|
10
|
+
/*
|
|
11
|
+
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
12
|
+
* This devtool is neither made for production nor for readable output files.
|
|
13
|
+
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
14
|
+
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
15
|
+
* or disable the default devtool with "devtool: false".
|
|
16
|
+
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
17
|
+
*/
|
|
18
|
+
(this["webpackChunk_tsparticles_updater_orbit"] = this["webpackChunk_tsparticles_updater_orbit"] || []).push([["dist_browser_OrbitUpdater_js"],{
|
|
19
|
+
|
|
20
|
+
/***/ "./dist/browser/Enums.js"
|
|
21
|
+
/*!*******************************!*\
|
|
22
|
+
!*** ./dist/browser/Enums.js ***!
|
|
23
|
+
\*******************************/
|
|
24
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
|
+
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OrbitType: () => (/* binding */ OrbitType)\n/* harmony export */ });\nvar OrbitType;\n(function (OrbitType) {\n OrbitType[\"front\"] = \"front\";\n OrbitType[\"back\"] = \"back\";\n})(OrbitType || (OrbitType = {}));\n\n//# sourceURL=webpack://@tsparticles/updater-orbit/./dist/browser/Enums.js?\n}");
|
|
27
|
+
|
|
28
|
+
/***/ },
|
|
29
|
+
|
|
30
|
+
/***/ "./dist/browser/Options/Classes/Orbit.js"
|
|
31
|
+
/*!***********************************************!*\
|
|
32
|
+
!*** ./dist/browser/Options/Classes/Orbit.js ***!
|
|
33
|
+
\***********************************************/
|
|
34
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
|
|
36
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Orbit: () => (/* binding */ Orbit)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _OrbitRotation_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./OrbitRotation.js */ \"./dist/browser/Options/Classes/OrbitRotation.js\");\n\n\nclass Orbit {\n constructor() {\n this.animation = new _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimationOptions();\n this.enable = false;\n this.opacity = 1;\n this.rotation = new _OrbitRotation_js__WEBPACK_IMPORTED_MODULE_1__.OrbitRotation();\n this.width = 1;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n this.animation.load(data.animation);\n this.rotation.load(data.rotation);\n if (data.enable !== undefined) {\n this.enable = data.enable;\n }\n if (data.opacity !== undefined) {\n this.opacity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.opacity);\n }\n if (data.width !== undefined) {\n this.width = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.width);\n }\n if (data.radius !== undefined) {\n this.radius = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(data.radius);\n }\n if (data.color !== undefined) {\n this.color = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.OptionsColor.create(this.color, data.color);\n }\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-orbit/./dist/browser/Options/Classes/Orbit.js?\n}");
|
|
37
|
+
|
|
38
|
+
/***/ },
|
|
39
|
+
|
|
40
|
+
/***/ "./dist/browser/Options/Classes/OrbitRotation.js"
|
|
41
|
+
/*!*******************************************************!*\
|
|
42
|
+
!*** ./dist/browser/Options/Classes/OrbitRotation.js ***!
|
|
43
|
+
\*******************************************************/
|
|
44
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
45
|
+
|
|
46
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OrbitRotation: () => (/* binding */ OrbitRotation)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nclass OrbitRotation extends _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.ValueWithRandom {\n constructor() {\n super();\n this.value = 45;\n }\n load(data) {\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNull)(data)) {\n return;\n }\n super.load(data);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-orbit/./dist/browser/Options/Classes/OrbitRotation.js?\n}");
|
|
47
|
+
|
|
48
|
+
/***/ },
|
|
49
|
+
|
|
50
|
+
/***/ "./dist/browser/OrbitUpdater.js"
|
|
51
|
+
/*!**************************************!*\
|
|
52
|
+
!*** ./dist/browser/OrbitUpdater.js ***!
|
|
53
|
+
\**************************************/
|
|
54
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
55
|
+
|
|
56
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ OrbitUpdater: () => (/* binding */ OrbitUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Orbit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Orbit.js */ \"./dist/browser/Options/Classes/Orbit.js\");\n/* harmony import */ var _Enums_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Enums.js */ \"./dist/browser/Enums.js\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\n\nconst defaultOrbitSpeed = 0,\n halfPI = Math.PI * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.half,\n piAndAHalf = Math.PI + halfPI,\n startAngle = 0,\n defaultWidth = 1,\n defaultRotation = 0;\nclass OrbitUpdater {\n constructor(engine, container) {\n this._engine = engine;\n this._container = container;\n }\n afterDraw(particle) {\n const orbitOptions = particle.options.orbit;\n if (orbitOptions?.enable) {\n this.drawOrbit(particle, _Enums_js__WEBPACK_IMPORTED_MODULE_2__.OrbitType.front);\n }\n }\n beforeDraw(particle) {\n const orbitOptions = particle.options.orbit;\n if (orbitOptions?.enable) {\n this.drawOrbit(particle, _Enums_js__WEBPACK_IMPORTED_MODULE_2__.OrbitType.back);\n }\n }\n drawOrbit(particle, type) {\n const container = this._container;\n let start, end;\n switch (type) {\n case _Enums_js__WEBPACK_IMPORTED_MODULE_2__.OrbitType.back:\n start = halfPI;\n end = piAndAHalf;\n break;\n case _Enums_js__WEBPACK_IMPORTED_MODULE_2__.OrbitType.front:\n start = piAndAHalf;\n end = halfPI;\n break;\n default:\n start = startAngle;\n end = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI;\n }\n container.canvas.draw(ctx => {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__.drawEllipse)(ctx, particle, particle.orbitColor ?? particle.getFillColor(), particle.retina.orbitRadius ?? container.retina.orbitRadius ?? particle.getRadius(), particle.orbitOpacity ?? _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.defaultOpacity, particle.orbitWidth ?? defaultWidth, (particle.orbitRotation ?? defaultRotation) * container.retina.pixelRatio, start, end);\n });\n }\n init(particle) {\n const container = this._container,\n particlesOptions = particle.options,\n orbitOptions = particlesOptions.orbit;\n if (!orbitOptions?.enable) {\n return;\n }\n particle.orbitRotation = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(orbitOptions.rotation.value);\n particle.orbitColor = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.rangeColorToHsl)(this._engine, orbitOptions.color);\n particle.retina.orbitRadius = orbitOptions.radius !== undefined ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(orbitOptions.radius) * container.retina.pixelRatio : undefined;\n container.retina.orbitRadius = particle.retina.orbitRadius;\n particle.orbitAnimationSpeed = orbitOptions.animation.enable ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(orbitOptions.animation.speed) : defaultOrbitSpeed;\n particle.orbitWidth = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(orbitOptions.width);\n particle.orbitOpacity = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(orbitOptions.opacity);\n }\n isEnabled(particle) {\n const orbitAnimations = particle.options.orbit?.animation;\n return !particle.destroyed && !particle.spawning && !!orbitAnimations?.enable;\n }\n loadOptions(options, ...sources) {\n options.orbit ??= new _Options_Classes_Orbit_js__WEBPACK_IMPORTED_MODULE_1__.Orbit();\n for (const source of sources) {\n options.orbit.load(source?.orbit);\n }\n }\n update(particle, delta) {\n if (!this.isEnabled(particle)) {\n return;\n }\n particle.orbitRotation ??= defaultRotation;\n particle.orbitRotation += (particle.orbitAnimationSpeed ?? defaultOrbitSpeed / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI) * delta.factor;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/updater-orbit/./dist/browser/OrbitUpdater.js?\n}");
|
|
57
|
+
|
|
58
|
+
/***/ },
|
|
59
|
+
|
|
60
|
+
/***/ "./dist/browser/Utils.js"
|
|
61
|
+
/*!*******************************!*\
|
|
62
|
+
!*** ./dist/browser/Utils.js ***!
|
|
63
|
+
\*******************************/
|
|
64
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
65
|
+
|
|
66
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ drawEllipse: () => (/* binding */ drawEllipse)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst minWidth = 0,\n half = 0.5,\n double = 2;\nfunction drawEllipse(context, particle, fillColorValue, radius, opacity, width, rotation, start, end) {\n if (width <= minWidth) {\n return;\n }\n const pos = particle.getPosition(),\n {\n container\n } = particle;\n if (fillColorValue) {\n context.strokeStyle = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getStyleFromHsl)(fillColorValue, container.hdr, opacity);\n }\n context.lineWidth = width;\n const rotationRadian = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.degToRad)(rotation);\n context.beginPath();\n context.ellipse(pos.x, pos.y, radius * half, radius * double, rotationRadian, start, end);\n context.stroke();\n}\n\n//# sourceURL=webpack://@tsparticles/updater-orbit/./dist/browser/Utils.js?\n}");
|
|
67
|
+
|
|
68
|
+
/***/ }
|
|
69
|
+
|
|
70
|
+
}]);
|
package/esm/OrbitUpdater.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { getRangeValue, rangeColorToHsl, } from "@tsparticles/engine";
|
|
1
|
+
import { defaultOpacity, doublePI, getRangeValue, half, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
2
|
import { Orbit } from "./Options/Classes/Orbit.js";
|
|
3
3
|
import { OrbitType } from "./Enums.js";
|
|
4
4
|
import { drawEllipse } from "./Utils.js";
|
|
5
|
-
const
|
|
5
|
+
const defaultOrbitSpeed = 0, halfPI = Math.PI * half, piAndAHalf = Math.PI + halfPI, startAngle = 0, defaultWidth = 1, defaultRotation = 0;
|
|
6
6
|
export class OrbitUpdater {
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(engine, container) {
|
|
8
8
|
this._engine = engine;
|
|
9
9
|
this._container = container;
|
|
10
10
|
}
|
|
@@ -63,9 +63,7 @@ export class OrbitUpdater {
|
|
|
63
63
|
return !particle.destroyed && !particle.spawning && !!orbitAnimations?.enable;
|
|
64
64
|
}
|
|
65
65
|
loadOptions(options, ...sources) {
|
|
66
|
-
|
|
67
|
-
options.orbit = new Orbit();
|
|
68
|
-
}
|
|
66
|
+
options.orbit ??= new Orbit();
|
|
69
67
|
for (const source of sources) {
|
|
70
68
|
options.orbit.load(source?.orbit);
|
|
71
69
|
}
|
|
@@ -74,9 +72,7 @@ export class OrbitUpdater {
|
|
|
74
72
|
if (!this.isEnabled(particle)) {
|
|
75
73
|
return;
|
|
76
74
|
}
|
|
77
|
-
|
|
78
|
-
particle.orbitRotation = defaultRotation;
|
|
79
|
-
}
|
|
75
|
+
particle.orbitRotation ??= defaultRotation;
|
|
80
76
|
particle.orbitRotation += (particle.orbitAnimationSpeed ?? defaultOrbitSpeed / doublePI) * delta.factor;
|
|
81
77
|
}
|
|
82
78
|
}
|
package/esm/Utils.js
CHANGED
|
@@ -4,9 +4,9 @@ export function drawEllipse(context, particle, fillColorValue, radius, opacity,
|
|
|
4
4
|
if (width <= minWidth) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
const pos = particle.getPosition();
|
|
7
|
+
const pos = particle.getPosition(), { container } = particle;
|
|
8
8
|
if (fillColorValue) {
|
|
9
|
-
context.strokeStyle = getStyleFromHsl(fillColorValue, opacity);
|
|
9
|
+
context.strokeStyle = getStyleFromHsl(fillColorValue, container.hdr, opacity);
|
|
10
10
|
}
|
|
11
11
|
context.lineWidth = width;
|
|
12
12
|
const rotationRadian = degToRad(rotation);
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
engine.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export function loadOrbitUpdater(engine) {
|
|
2
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
3
|
+
engine.register(e => {
|
|
4
|
+
e.addParticleUpdater("orbit", async (container) => {
|
|
5
|
+
const { OrbitUpdater } = await import("./OrbitUpdater.js");
|
|
6
|
+
return new OrbitUpdater(e, container);
|
|
7
|
+
});
|
|
8
|
+
});
|
|
7
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-orbit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "tsParticles particles orbit updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -101,9 +101,10 @@
|
|
|
101
101
|
"./package.json": "./package.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@tsparticles/engine": "
|
|
104
|
+
"@tsparticles/engine": "4.0.0-alpha.0"
|
|
105
105
|
},
|
|
106
106
|
"publishConfig": {
|
|
107
107
|
"access": "public"
|
|
108
|
-
}
|
|
108
|
+
},
|
|
109
|
+
"type": "module"
|
|
109
110
|
}
|