@tsparticles/path-branches 4.0.0-beta.0 → 4.0.0-beta.2

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/138.min.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";(this.webpackChunk_tsparticles_path_branches=this.webpackChunk_tsparticles_path_branches||[]).push([[138],{138(e,t,n){n.d(t,{BranchesPathGenerator:()=>s});var i=n(303);n(400);let a={segmentLength:20,branchChance:.2,maxAngle:Math.PI/3,speedVariation:.3,inertia:{enable:!1,factor:.1}};class s{options;_container;_res;constructor(e){this._container=e,this._res=i.Vector.origin,this.options={...a,inertia:{...a.inertia}}}generate(e){let t=this.options;e.branching??={angle:(0,i.getRandom)()*i.doublePI,remaining:t.segmentLength,baseSpeed:e.velocity.length,speed:e.velocity.length};let n=e.branching;if(n.remaining<=0){let e=(0,i.getRandom)()<(t.branchChance??0),s=t.maxAngle??a.maxAngle,o=(2*(0,i.getRandom)()-1)*(e?s:.3*s);n.angle+=o,n.remaining=t.segmentLength;let r=1+(2*(0,i.getRandom)()-1)*(t.speedVariation??0);n.speed=n.baseSpeed*r}n.remaining-=n.speed;let s=Math.cos(n.angle)*n.speed,o=Math.sin(n.angle)*n.speed,r=t.inertia;if(r?.enable){let t=r.factor??.1;e.velocity.x+=(s-e.velocity.x)*t,e.velocity.y+=(o-e.velocity.y)*t,this._res.x=e.velocity.x,this._res.y=e.velocity.y}else e.velocity.x=0,e.velocity.y=0,this._res.x=s,this._res.y=o;return this._res}init(){let e=this._container.actualOptions.particles.move.path.options;this.options.segmentLength=e.segmentLength??this.options.segmentLength,this.options.branchChance=e.branchChance??this.options.branchChance,this.options.maxAngle=e.maxAngle??this.options.maxAngle,this.options.speedVariation=e.speedVariation??this.options.speedVariation;let t=e.inertia;if(t){let e={...a.inertia};e.enable=t.enable??e.enable,e.factor=t.factor??e.factor,this.options.inertia=e}}reset(e){delete e.branching}update(){}}}}]);
@@ -1,4 +1,5 @@
1
1
  import { Vector, doublePI, getRandom } from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
2
3
  const defaultOptions = {
3
4
  segmentLength: 20,
4
5
  branchChance: 0.2,
package/browser/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export const branchingPathName = "branchesPathGenerator";
2
2
  export async function loadBranchesPath(engine) {
3
- engine.checkVersion("4.0.0-beta.0");
4
- await engine.register(async (e) => {
3
+ engine.checkVersion("4.0.0-beta.2");
4
+ await engine.pluginManager.register(async (e) => {
5
5
  const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
6
  ensureBaseMoverLoaded(e);
7
- e.addPathGenerator?.(branchingPathName, async (container) => {
7
+ e.pluginManager.addPathGenerator?.(branchingPathName, async (container) => {
8
8
  const { BranchesPathGenerator } = await import("./BranchesPathGenerator.js");
9
9
  return new BranchesPathGenerator(container);
10
10
  });
@@ -1,4 +1,5 @@
1
1
  import { Vector, doublePI, getRandom } from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
2
3
  const defaultOptions = {
3
4
  segmentLength: 20,
4
5
  branchChance: 0.2,
package/cjs/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export const branchingPathName = "branchesPathGenerator";
2
2
  export async function loadBranchesPath(engine) {
3
- engine.checkVersion("4.0.0-beta.0");
4
- await engine.register(async (e) => {
3
+ engine.checkVersion("4.0.0-beta.2");
4
+ await engine.pluginManager.register(async (e) => {
5
5
  const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
6
  ensureBaseMoverLoaded(e);
7
- e.addPathGenerator?.(branchingPathName, async (container) => {
7
+ e.pluginManager.addPathGenerator?.(branchingPathName, async (container) => {
8
8
  const { BranchesPathGenerator } = await import("./BranchesPathGenerator.js");
9
9
  return new BranchesPathGenerator(container);
10
10
  });
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.0
7
+ * v4.0.0-beta.2
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 */ BranchesPathGenerator: () => (/* binding */ BranchesPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultOptions = {\n segmentLength: 20,\n branchChance: 0.2,\n maxAngle: Math.PI / 3,\n speedVariation: 0.3,\n inertia: {\n enable: false,\n factor: 0.1\n }\n};\nclass BranchesPathGenerator {\n options;\n _container;\n _res;\n constructor(container){\n this._container = container;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this.options = {\n ...defaultOptions,\n inertia: {\n ...defaultOptions.inertia\n }\n };\n }\n generate(p) {\n const opts = this.options;\n p.branching ??= {\n angle: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI,\n remaining: opts.segmentLength,\n baseSpeed: p.velocity.length,\n speed: p.velocity.length\n };\n const b = p.branching;\n if (b.remaining <= 0) {\n const branch = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() < (opts.branchChance ?? 0), maxAngle = opts.maxAngle ?? defaultOptions.maxAngle, delta = ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 2 - 1) * (branch ? maxAngle : maxAngle * 0.3);\n b.angle += delta;\n b.remaining = opts.segmentLength;\n const speedFactor = 1 + ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 2 - 1) * (opts.speedVariation ?? 0);\n b.speed = b.baseSpeed * speedFactor;\n }\n b.remaining -= b.speed;\n const targetX = Math.cos(b.angle) * b.speed, targetY = Math.sin(b.angle) * b.speed, inertia = opts.inertia;\n if (inertia?.enable) {\n const factor = inertia.factor ?? 0.1;\n p.velocity.x += (targetX - p.velocity.x) * factor;\n p.velocity.y += (targetY - p.velocity.y) * factor;\n this._res.x = p.velocity.x;\n this._res.y = p.velocity.y;\n } else {\n p.velocity.x = 0;\n p.velocity.y = 0;\n this._res.x = targetX;\n this._res.y = targetY;\n }\n return this._res;\n }\n init() {\n const source = this._container.actualOptions.particles.move.path.options;\n this.options.segmentLength = source[\"segmentLength\"] ?? this.options.segmentLength;\n this.options.branchChance = source[\"branchChance\"] ?? this.options.branchChance;\n this.options.maxAngle = source[\"maxAngle\"] ?? this.options.maxAngle;\n this.options.speedVariation = source[\"speedVariation\"] ?? this.options.speedVariation;\n const inertiaSource = source[\"inertia\"];\n if (inertiaSource) {\n const inertiaOptions = {\n ...defaultOptions.inertia\n };\n inertiaOptions.enable = inertiaSource.enable ?? inertiaOptions.enable;\n inertiaOptions.factor = inertiaSource.factor ?? inertiaOptions.factor;\n this.options.inertia = inertiaOptions;\n }\n }\n reset(p) {\n delete p.branching;\n }\n update() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-branches/./dist/browser/BranchesPathGenerator.js?\n}");
26
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ BranchesPathGenerator: () => (/* binding */ BranchesPathGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_plugin_move__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-move */ \"@tsparticles/plugin-move\");\n\n\nconst defaultOptions = {\n segmentLength: 20,\n branchChance: 0.2,\n maxAngle: Math.PI / 3,\n speedVariation: 0.3,\n inertia: {\n enable: false,\n factor: 0.1\n }\n};\nclass BranchesPathGenerator {\n options;\n _container;\n _res;\n constructor(container){\n this._container = container;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this.options = {\n ...defaultOptions,\n inertia: {\n ...defaultOptions.inertia\n }\n };\n }\n generate(p) {\n const opts = this.options;\n p.branching ??= {\n angle: (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI,\n remaining: opts.segmentLength,\n baseSpeed: p.velocity.length,\n speed: p.velocity.length\n };\n const b = p.branching;\n if (b.remaining <= 0) {\n const branch = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() < (opts.branchChance ?? 0), maxAngle = opts.maxAngle ?? defaultOptions.maxAngle, delta = ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 2 - 1) * (branch ? maxAngle : maxAngle * 0.3);\n b.angle += delta;\n b.remaining = opts.segmentLength;\n const speedFactor = 1 + ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)() * 2 - 1) * (opts.speedVariation ?? 0);\n b.speed = b.baseSpeed * speedFactor;\n }\n b.remaining -= b.speed;\n const targetX = Math.cos(b.angle) * b.speed, targetY = Math.sin(b.angle) * b.speed, inertia = opts.inertia;\n if (inertia?.enable) {\n const factor = inertia.factor ?? 0.1;\n p.velocity.x += (targetX - p.velocity.x) * factor;\n p.velocity.y += (targetY - p.velocity.y) * factor;\n this._res.x = p.velocity.x;\n this._res.y = p.velocity.y;\n } else {\n p.velocity.x = 0;\n p.velocity.y = 0;\n this._res.x = targetX;\n this._res.y = targetY;\n }\n return this._res;\n }\n init() {\n const source = this._container.actualOptions.particles.move.path.options;\n this.options.segmentLength = source[\"segmentLength\"] ?? this.options.segmentLength;\n this.options.branchChance = source[\"branchChance\"] ?? this.options.branchChance;\n this.options.maxAngle = source[\"maxAngle\"] ?? this.options.maxAngle;\n this.options.speedVariation = source[\"speedVariation\"] ?? this.options.speedVariation;\n const inertiaSource = source[\"inertia\"];\n if (inertiaSource) {\n const inertiaOptions = {\n ...defaultOptions.inertia\n };\n inertiaOptions.enable = inertiaSource.enable ?? inertiaOptions.enable;\n inertiaOptions.factor = inertiaSource.factor ?? inertiaOptions.factor;\n this.options.inertia = inertiaOptions;\n }\n }\n reset(p) {\n delete p.branching;\n }\n update() {}\n}\n\n\n//# sourceURL=webpack://@tsparticles/path-branches/./dist/browser/BranchesPathGenerator.js?\n}");
27
27
 
28
28
  /***/ }
29
29
 
@@ -1,4 +1,5 @@
1
1
  import { Vector, doublePI, getRandom } from "@tsparticles/engine";
2
+ import {} from "@tsparticles/plugin-move";
2
3
  const defaultOptions = {
3
4
  segmentLength: 20,
4
5
  branchChance: 0.2,
package/esm/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export const branchingPathName = "branchesPathGenerator";
2
2
  export async function loadBranchesPath(engine) {
3
- engine.checkVersion("4.0.0-beta.0");
4
- await engine.register(async (e) => {
3
+ engine.checkVersion("4.0.0-beta.2");
4
+ await engine.pluginManager.register(async (e) => {
5
5
  const { ensureBaseMoverLoaded } = await import("@tsparticles/plugin-move");
6
6
  ensureBaseMoverLoaded(e);
7
- e.addPathGenerator?.(branchingPathName, async (container) => {
7
+ e.pluginManager.addPathGenerator?.(branchingPathName, async (container) => {
8
8
  const { BranchesPathGenerator } = await import("./BranchesPathGenerator.js");
9
9
  return new BranchesPathGenerator(container);
10
10
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/path-branches",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.2",
4
4
  "description": "tsParticles branches path",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -98,14 +98,13 @@
98
98
  "browser": "./browser/index.js",
99
99
  "import": "./esm/index.js",
100
100
  "require": "./cjs/index.js",
101
- "umd": "./umd/index.js",
102
- "default": "./cjs/index.js"
101
+ "default": "./esm/index.js"
103
102
  },
104
103
  "./package.json": "./package.json"
105
104
  },
106
- "dependencies": {
107
- "@tsparticles/engine": "4.0.0-beta.0",
108
- "@tsparticles/plugin-move": "4.0.0-beta.0"
105
+ "peerDependencies": {
106
+ "@tsparticles/engine": "4.0.0-beta.1",
107
+ "@tsparticles/plugin-move": "4.0.0-beta.1"
109
108
  },
110
109
  "type": "module"
111
110
  }