@tsparticles/noise-field 4.0.0-alpha.5 → 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/browser/NoiseFieldGenerator.js +22 -15
- package/cjs/NoiseFieldGenerator.js +22 -15
- package/esm/NoiseFieldGenerator.js +22 -15
- package/package.json +3 -2
- package/report.html +3 -3
- package/tsparticles.noise.field.js +19 -19
- package/tsparticles.noise.field.min.js +1 -2
- package/types/NoiseFieldGenerator.d.ts +6 -4
- package/umd/NoiseFieldGenerator.js +21 -14
- package/tsparticles.noise.field.min.js.LICENSE.txt +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, deepExtend, doublePI, getRandom
|
|
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,
|
|
@@ -26,10 +26,18 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export class NoiseFieldGenerator {
|
|
29
|
-
|
|
29
|
+
container;
|
|
30
|
+
field;
|
|
31
|
+
noiseGen;
|
|
32
|
+
noiseW;
|
|
33
|
+
options;
|
|
34
|
+
_res;
|
|
35
|
+
constructor(container, noiseGen) {
|
|
36
|
+
this.container = container;
|
|
30
37
|
this.noiseGen = noiseGen;
|
|
31
38
|
this.field = [];
|
|
32
39
|
this.noiseW = 0;
|
|
40
|
+
this._res = Vector.origin;
|
|
33
41
|
this.options = deepExtend({}, defaultOptions);
|
|
34
42
|
}
|
|
35
43
|
generate(particle) {
|
|
@@ -38,18 +46,22 @@ export class NoiseFieldGenerator {
|
|
|
38
46
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
39
47
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
40
48
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
41
|
-
|
|
49
|
+
if (fieldPoint) {
|
|
50
|
+
this._res.x = fieldPoint.x;
|
|
51
|
+
this._res.y = fieldPoint.y;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this._res.x = 0;
|
|
55
|
+
this._res.y = 0;
|
|
56
|
+
}
|
|
57
|
+
return this._res;
|
|
42
58
|
}
|
|
43
|
-
init(
|
|
44
|
-
this.container = container;
|
|
59
|
+
init() {
|
|
45
60
|
this._setup();
|
|
46
61
|
}
|
|
47
62
|
reset() {
|
|
48
63
|
}
|
|
49
64
|
update() {
|
|
50
|
-
if (!this.container) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
65
|
this._calculateField();
|
|
54
66
|
this.noiseW += this.options.increment;
|
|
55
67
|
if (!this.options.draw) {
|
|
@@ -126,15 +138,10 @@ export class NoiseFieldGenerator {
|
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
_resetField() {
|
|
129
|
-
const container = this.container;
|
|
130
|
-
if (!container) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
141
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
134
142
|
options.width = container.canvas.size.width;
|
|
135
143
|
options.height = container.canvas.size.height;
|
|
136
|
-
options.size =
|
|
137
|
-
sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
144
|
+
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
138
145
|
options.increment =
|
|
139
146
|
sourceOptions["increment"] > empty
|
|
140
147
|
? sourceOptions["increment"]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, deepExtend, doublePI, getRandom
|
|
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,
|
|
@@ -26,10 +26,18 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export class NoiseFieldGenerator {
|
|
29
|
-
|
|
29
|
+
container;
|
|
30
|
+
field;
|
|
31
|
+
noiseGen;
|
|
32
|
+
noiseW;
|
|
33
|
+
options;
|
|
34
|
+
_res;
|
|
35
|
+
constructor(container, noiseGen) {
|
|
36
|
+
this.container = container;
|
|
30
37
|
this.noiseGen = noiseGen;
|
|
31
38
|
this.field = [];
|
|
32
39
|
this.noiseW = 0;
|
|
40
|
+
this._res = Vector.origin;
|
|
33
41
|
this.options = deepExtend({}, defaultOptions);
|
|
34
42
|
}
|
|
35
43
|
generate(particle) {
|
|
@@ -38,18 +46,22 @@ export class NoiseFieldGenerator {
|
|
|
38
46
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
39
47
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
40
48
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
41
|
-
|
|
49
|
+
if (fieldPoint) {
|
|
50
|
+
this._res.x = fieldPoint.x;
|
|
51
|
+
this._res.y = fieldPoint.y;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this._res.x = 0;
|
|
55
|
+
this._res.y = 0;
|
|
56
|
+
}
|
|
57
|
+
return this._res;
|
|
42
58
|
}
|
|
43
|
-
init(
|
|
44
|
-
this.container = container;
|
|
59
|
+
init() {
|
|
45
60
|
this._setup();
|
|
46
61
|
}
|
|
47
62
|
reset() {
|
|
48
63
|
}
|
|
49
64
|
update() {
|
|
50
|
-
if (!this.container) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
65
|
this._calculateField();
|
|
54
66
|
this.noiseW += this.options.increment;
|
|
55
67
|
if (!this.options.draw) {
|
|
@@ -126,15 +138,10 @@ export class NoiseFieldGenerator {
|
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
_resetField() {
|
|
129
|
-
const container = this.container;
|
|
130
|
-
if (!container) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
141
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
134
142
|
options.width = container.canvas.size.width;
|
|
135
143
|
options.height = container.canvas.size.height;
|
|
136
|
-
options.size =
|
|
137
|
-
sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
144
|
+
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
138
145
|
options.increment =
|
|
139
146
|
sourceOptions["increment"] > empty
|
|
140
147
|
? sourceOptions["increment"]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, deepExtend, doublePI, getRandom
|
|
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,
|
|
@@ -26,10 +26,18 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export class NoiseFieldGenerator {
|
|
29
|
-
|
|
29
|
+
container;
|
|
30
|
+
field;
|
|
31
|
+
noiseGen;
|
|
32
|
+
noiseW;
|
|
33
|
+
options;
|
|
34
|
+
_res;
|
|
35
|
+
constructor(container, noiseGen) {
|
|
36
|
+
this.container = container;
|
|
30
37
|
this.noiseGen = noiseGen;
|
|
31
38
|
this.field = [];
|
|
32
39
|
this.noiseW = 0;
|
|
40
|
+
this._res = Vector.origin;
|
|
33
41
|
this.options = deepExtend({}, defaultOptions);
|
|
34
42
|
}
|
|
35
43
|
generate(particle) {
|
|
@@ -38,18 +46,22 @@ export class NoiseFieldGenerator {
|
|
|
38
46
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
39
47
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
40
48
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
41
|
-
|
|
49
|
+
if (fieldPoint) {
|
|
50
|
+
this._res.x = fieldPoint.x;
|
|
51
|
+
this._res.y = fieldPoint.y;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this._res.x = 0;
|
|
55
|
+
this._res.y = 0;
|
|
56
|
+
}
|
|
57
|
+
return this._res;
|
|
42
58
|
}
|
|
43
|
-
init(
|
|
44
|
-
this.container = container;
|
|
59
|
+
init() {
|
|
45
60
|
this._setup();
|
|
46
61
|
}
|
|
47
62
|
reset() {
|
|
48
63
|
}
|
|
49
64
|
update() {
|
|
50
|
-
if (!this.container) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
65
|
this._calculateField();
|
|
54
66
|
this.noiseW += this.options.increment;
|
|
55
67
|
if (!this.options.draw) {
|
|
@@ -126,15 +138,10 @@ export class NoiseFieldGenerator {
|
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
_resetField() {
|
|
129
|
-
const container = this.container;
|
|
130
|
-
if (!container) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
141
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
134
142
|
options.width = container.canvas.size.width;
|
|
135
143
|
options.height = container.canvas.size.height;
|
|
136
|
-
options.size =
|
|
137
|
-
sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
144
|
+
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
138
145
|
options.increment =
|
|
139
146
|
sourceOptions["increment"] > empty
|
|
140
147
|
? sourceOptions["increment"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/noise-field",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"description": "tsParticles noise field library",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -92,7 +92,8 @@
|
|
|
92
92
|
"module": "esm/index.js",
|
|
93
93
|
"types": "types/index.d.ts",
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@tsparticles/engine": "4.0.0-
|
|
95
|
+
"@tsparticles/engine": "4.0.0-beta.0",
|
|
96
|
+
"@tsparticles/plugin-move": "4.0.0-beta.0"
|
|
96
97
|
},
|
|
97
98
|
"exports": {
|
|
98
99
|
".": {
|