@tsparticles/noise-field 4.0.0-alpha.2 → 4.0.0-alpha.20

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.
@@ -1,4 +1,4 @@
1
- import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, doublePI, getRandom, } from "@tsparticles/engine";
2
2
  const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
3
  a: 1,
4
4
  b: 0,
@@ -6,7 +6,7 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
6
6
  d: 1,
7
7
  e: 0,
8
8
  f: 0,
9
- }, double = 2, doublePI = Math.PI * double, defaultOptions = {
9
+ }, defaultOptions = {
10
10
  draw: false,
11
11
  size: 20,
12
12
  increment: 0.004,
@@ -26,7 +26,13 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
26
26
  },
27
27
  };
28
28
  export class NoiseFieldGenerator {
29
- constructor(noiseGen) {
29
+ container;
30
+ field;
31
+ noiseGen;
32
+ noiseW;
33
+ options;
34
+ constructor(container, noiseGen) {
35
+ this.container = container;
30
36
  this.noiseGen = noiseGen;
31
37
  this.field = [];
32
38
  this.noiseW = 0;
@@ -40,16 +46,12 @@ export class NoiseFieldGenerator {
40
46
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
41
47
  return fieldPoint ? fieldPoint.copy() : Vector.origin;
42
48
  }
43
- init(container) {
44
- this.container = container;
49
+ init() {
45
50
  this._setup();
46
51
  }
47
52
  reset() {
48
53
  }
49
54
  update() {
50
- if (!this.container) {
51
- return;
52
- }
53
55
  this._calculateField();
54
56
  this.noiseW += this.options.increment;
55
57
  if (!this.options.draw) {
@@ -126,15 +128,10 @@ export class NoiseFieldGenerator {
126
128
  }
127
129
  }
128
130
  _resetField() {
129
- const container = this.container;
130
- if (!container) {
131
- return;
132
- }
133
- const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
131
+ const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
134
132
  options.width = container.canvas.size.width;
135
133
  options.height = container.canvas.size.height;
136
- options.size =
137
- sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
134
+ options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
138
135
  options.increment =
139
136
  sourceOptions["increment"] > empty
140
137
  ? sourceOptions["increment"]
@@ -1,4 +1,4 @@
1
- import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, doublePI, getRandom, } from "@tsparticles/engine";
2
2
  const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
3
  a: 1,
4
4
  b: 0,
@@ -6,7 +6,7 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
6
6
  d: 1,
7
7
  e: 0,
8
8
  f: 0,
9
- }, double = 2, doublePI = Math.PI * double, defaultOptions = {
9
+ }, defaultOptions = {
10
10
  draw: false,
11
11
  size: 20,
12
12
  increment: 0.004,
@@ -26,7 +26,13 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
26
26
  },
27
27
  };
28
28
  export class NoiseFieldGenerator {
29
- constructor(noiseGen) {
29
+ container;
30
+ field;
31
+ noiseGen;
32
+ noiseW;
33
+ options;
34
+ constructor(container, noiseGen) {
35
+ this.container = container;
30
36
  this.noiseGen = noiseGen;
31
37
  this.field = [];
32
38
  this.noiseW = 0;
@@ -40,16 +46,12 @@ export class NoiseFieldGenerator {
40
46
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
41
47
  return fieldPoint ? fieldPoint.copy() : Vector.origin;
42
48
  }
43
- init(container) {
44
- this.container = container;
49
+ init() {
45
50
  this._setup();
46
51
  }
47
52
  reset() {
48
53
  }
49
54
  update() {
50
- if (!this.container) {
51
- return;
52
- }
53
55
  this._calculateField();
54
56
  this.noiseW += this.options.increment;
55
57
  if (!this.options.draw) {
@@ -126,15 +128,10 @@ export class NoiseFieldGenerator {
126
128
  }
127
129
  }
128
130
  _resetField() {
129
- const container = this.container;
130
- if (!container) {
131
- return;
132
- }
133
- const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
131
+ const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
134
132
  options.width = container.canvas.size.width;
135
133
  options.height = container.canvas.size.height;
136
- options.size =
137
- sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
134
+ options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
138
135
  options.increment =
139
136
  sourceOptions["increment"] > empty
140
137
  ? sourceOptions["increment"]
@@ -1,4 +1,4 @@
1
- import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, doublePI, getRandom, } from "@tsparticles/engine";
2
2
  const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
3
  a: 1,
4
4
  b: 0,
@@ -6,7 +6,7 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
6
6
  d: 1,
7
7
  e: 0,
8
8
  f: 0,
9
- }, double = 2, doublePI = Math.PI * double, defaultOptions = {
9
+ }, defaultOptions = {
10
10
  draw: false,
11
11
  size: 20,
12
12
  increment: 0.004,
@@ -26,7 +26,13 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
26
26
  },
27
27
  };
28
28
  export class NoiseFieldGenerator {
29
- constructor(noiseGen) {
29
+ container;
30
+ field;
31
+ noiseGen;
32
+ noiseW;
33
+ options;
34
+ constructor(container, noiseGen) {
35
+ this.container = container;
30
36
  this.noiseGen = noiseGen;
31
37
  this.field = [];
32
38
  this.noiseW = 0;
@@ -40,16 +46,12 @@ export class NoiseFieldGenerator {
40
46
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
41
47
  return fieldPoint ? fieldPoint.copy() : Vector.origin;
42
48
  }
43
- init(container) {
44
- this.container = container;
49
+ init() {
45
50
  this._setup();
46
51
  }
47
52
  reset() {
48
53
  }
49
54
  update() {
50
- if (!this.container) {
51
- return;
52
- }
53
55
  this._calculateField();
54
56
  this.noiseW += this.options.increment;
55
57
  if (!this.options.draw) {
@@ -126,15 +128,10 @@ export class NoiseFieldGenerator {
126
128
  }
127
129
  }
128
130
  _resetField() {
129
- const container = this.container;
130
- if (!container) {
131
- return;
132
- }
133
- const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
131
+ const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
134
132
  options.width = container.canvas.size.width;
135
133
  options.height = container.canvas.size.height;
136
- options.size =
137
- sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
134
+ options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
138
135
  options.increment =
139
136
  sourceOptions["increment"] > empty
140
137
  ? sourceOptions["increment"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/noise-field",
3
- "version": "4.0.0-alpha.2",
3
+ "version": "4.0.0-alpha.20",
4
4
  "description": "tsParticles noise field library",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -92,7 +92,7 @@
92
92
  "module": "esm/index.js",
93
93
  "types": "types/index.d.ts",
94
94
  "dependencies": {
95
- "@tsparticles/engine": "4.0.0-alpha.2"
95
+ "@tsparticles/engine": "4.0.0-alpha.20"
96
96
  },
97
97
  "exports": {
98
98
  ".": {