@tsparticles/noise-field 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Matteo Bruni
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ [![banner](https://particles.js.org/images/banner3.png)](https://particles.js.org)
2
+
3
+ # tsParticles Fractal Noise Library
4
+
5
+ [![jsDelivr](https://data.jsdelivr.com/v1/package/npm/@tsparticles/fractal-noise/badge)](https://www.jsdelivr.com/package/npm/@tsparticles/fractal-noise)
6
+ [![npmjs](https://badge.fury.io/js/@tsparticles/fractal-noise.svg)](https://www.npmjs.com/package/@tsparticles/fractal-noise)
7
+ [![npmjs](https://img.shields.io/npm/dt/@tsparticles/fractal-noise)](https://www.npmjs.com/package/@tsparticles/fractal-noise) [![GitHub Sponsors](https://img.shields.io/github/sponsors/matteobruni)](https://github.com/sponsors/matteobruni)
8
+
9
+ [tsParticles](https://github.com/tsparticles/tsparticles) path plugin for fractal noise movement.
10
+
11
+ ## How to use it
12
+
13
+ ### CDN / Vanilla JS / jQuery
14
+
15
+ The CDN/Vanilla version JS has one required file in vanilla configuration:
16
+
17
+ Including the `tsparticles.fractal.noise.min.js` file will export the function to load the path plugin:
18
+
19
+ ```text
20
+ loadFractalNoisePath
21
+ ```
22
+
23
+ ### Usage
24
+
25
+ Once the scripts are loaded you can set up `tsParticles` and the path plugin like this:
26
+
27
+ ```javascript
28
+ (async () => {
29
+ await loadFractalNoisePath(tsParticles);
30
+
31
+ await tsParticles.load({
32
+ id: "tsparticles",
33
+ options: {
34
+ /* options */
35
+ },
36
+ });
37
+ })();
38
+ ```
39
+
40
+ ### ESM / CommonJS
41
+
42
+ This package is compatible also with ES or CommonJS modules, firstly this needs to be installed, like this:
43
+
44
+ ```shell
45
+ $ npm install @tsparticles/fractal-noise
46
+ ```
47
+
48
+ or
49
+
50
+ ```shell
51
+ $ yarn add @tsparticles/fractal-noise
52
+ ```
53
+
54
+ Then you need to import it in the app, like this:
55
+
56
+ ```javascript
57
+ const { tsParticles } = require("@tsparticles/engine");
58
+ const { loadFractalNoisePath } = require("@tsparticles/fractal-noise");
59
+
60
+ (async () => {
61
+ await loadFractalNoisePath(tsParticles);
62
+ })();
63
+ ```
64
+
65
+ or
66
+
67
+ ```javascript
68
+ import { tsParticles } from "@tsparticles/engine";
69
+ import { loadFractalNoisePath } from "@tsparticles/fractal-noise";
70
+
71
+ (async () => {
72
+ await loadFractalNoisePath(tsParticles);
73
+ })();
74
+ ```
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,164 @@
1
+ import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
2
+ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
+ a: 1,
4
+ b: 0,
5
+ c: 0,
6
+ d: 1,
7
+ e: 0,
8
+ f: 0,
9
+ }, double = 2, doublePI = Math.PI * double, defaultOptions = {
10
+ draw: false,
11
+ size: 20,
12
+ increment: 0.004,
13
+ columns: 0,
14
+ rows: 0,
15
+ layers: 0,
16
+ width: 0,
17
+ height: 0,
18
+ factor: {
19
+ angle: 0.02,
20
+ length: 0.01,
21
+ },
22
+ offset: {
23
+ x: 40000,
24
+ y: 40000,
25
+ z: 40000,
26
+ },
27
+ };
28
+ export class NoiseFieldGenerator {
29
+ constructor(noiseGen) {
30
+ this.noiseGen = noiseGen;
31
+ this.field = [];
32
+ this.noiseW = 0;
33
+ this.options = deepExtend({}, defaultOptions);
34
+ }
35
+ generate(particle) {
36
+ const pos = particle.getPosition(), { size } = this.options, point = {
37
+ x: Math.max(Math.floor(pos.x / size), originCoordinate),
38
+ y: Math.max(Math.floor(pos.y / size), originCoordinate),
39
+ z: Math.max(Math.floor(pos.z / size), originCoordinate),
40
+ }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
41
+ return fieldPoint ? fieldPoint.copy() : Vector.origin;
42
+ }
43
+ init(container) {
44
+ this.container = container;
45
+ this._setup();
46
+ }
47
+ reset() {
48
+ }
49
+ update() {
50
+ if (!this.container) {
51
+ return;
52
+ }
53
+ this._calculateField();
54
+ this.noiseW += this.options.increment;
55
+ if (!this.options.draw) {
56
+ return;
57
+ }
58
+ this.container.canvas.draw(ctx => {
59
+ this._drawField(ctx);
60
+ });
61
+ }
62
+ _calculateField() {
63
+ const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
64
+ for (let x = 0; x < options.columns; x++) {
65
+ const xColumn = field[x];
66
+ if (!xColumn) {
67
+ continue;
68
+ }
69
+ for (let y = 0; y < options.rows; y++) {
70
+ const yColumn = xColumn[y];
71
+ if (!yColumn) {
72
+ continue;
73
+ }
74
+ for (let z = 0; z < options.layers; z++) {
75
+ const cell = yColumn[z];
76
+ if (!cell) {
77
+ continue;
78
+ }
79
+ cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
80
+ cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * doublePI;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ _drawField(ctx) {
86
+ const { field, options } = this;
87
+ for (let x = 0; x < options.columns; x++) {
88
+ const xColumn = field[x];
89
+ if (!xColumn) {
90
+ continue;
91
+ }
92
+ for (let y = 0; y < options.rows; y++) {
93
+ const yColumn = xColumn[y];
94
+ if (!yColumn) {
95
+ continue;
96
+ }
97
+ const cell = yColumn[firstIndex];
98
+ if (!cell) {
99
+ continue;
100
+ }
101
+ const { angle, length } = cell;
102
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);
103
+ ctx.rotate(angle);
104
+ ctx.strokeStyle = "white";
105
+ ctx.beginPath();
106
+ ctx.moveTo(originCoordinate, originCoordinate);
107
+ ctx.lineTo(originCoordinate, this.options.size * length);
108
+ ctx.stroke();
109
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);
110
+ }
111
+ }
112
+ }
113
+ _initField() {
114
+ const { columns, rows, layers } = this.options;
115
+ this.field = new Array(columns);
116
+ for (let x = 0; x < columns; x++) {
117
+ const newX = new Array(rows);
118
+ for (let y = 0; y < rows; y++) {
119
+ const newY = new Array(layers);
120
+ for (let z = 0; z < layers; z++) {
121
+ newY[z] = Vector.origin;
122
+ }
123
+ newX[y] = newY;
124
+ }
125
+ this.field[x] = newX;
126
+ }
127
+ }
128
+ _resetField() {
129
+ const container = this.container;
130
+ if (!container) {
131
+ return;
132
+ }
133
+ const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
134
+ options.width = container.canvas.size.width;
135
+ options.height = container.canvas.size.height;
136
+ options.size =
137
+ sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
138
+ options.increment =
139
+ sourceOptions["increment"] > empty
140
+ ? sourceOptions["increment"]
141
+ : defaultOptions.increment;
142
+ options.draw = !!sourceOptions["draw"];
143
+ const offset = sourceOptions["offset"];
144
+ options.offset.x = offset?.x ?? defaultOptions.offset.x;
145
+ options.offset.y = offset?.y ?? defaultOptions.offset.y;
146
+ options.offset.z = offset?.z ?? defaultOptions.offset.z;
147
+ const factor = sourceOptions["factor"];
148
+ options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
149
+ options.factor.length = factor?.length ?? defaultOptions.factor.length;
150
+ options.seed = sourceOptions["seed"];
151
+ this.noiseGen.seed(options.seed ?? getRandom());
152
+ options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;
153
+ options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;
154
+ options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;
155
+ this._initField();
156
+ }
157
+ _setup() {
158
+ this.noiseW = 0;
159
+ this._resetField();
160
+ addEventListener("resize", () => {
161
+ this._resetField();
162
+ });
163
+ }
164
+ }
@@ -0,0 +1 @@
1
+ export { NoiseFieldGenerator } from "./NoiseFieldGenerator.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,164 @@
1
+ import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
2
+ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
+ a: 1,
4
+ b: 0,
5
+ c: 0,
6
+ d: 1,
7
+ e: 0,
8
+ f: 0,
9
+ }, double = 2, doublePI = Math.PI * double, defaultOptions = {
10
+ draw: false,
11
+ size: 20,
12
+ increment: 0.004,
13
+ columns: 0,
14
+ rows: 0,
15
+ layers: 0,
16
+ width: 0,
17
+ height: 0,
18
+ factor: {
19
+ angle: 0.02,
20
+ length: 0.01,
21
+ },
22
+ offset: {
23
+ x: 40000,
24
+ y: 40000,
25
+ z: 40000,
26
+ },
27
+ };
28
+ export class NoiseFieldGenerator {
29
+ constructor(noiseGen) {
30
+ this.noiseGen = noiseGen;
31
+ this.field = [];
32
+ this.noiseW = 0;
33
+ this.options = deepExtend({}, defaultOptions);
34
+ }
35
+ generate(particle) {
36
+ const pos = particle.getPosition(), { size } = this.options, point = {
37
+ x: Math.max(Math.floor(pos.x / size), originCoordinate),
38
+ y: Math.max(Math.floor(pos.y / size), originCoordinate),
39
+ z: Math.max(Math.floor(pos.z / size), originCoordinate),
40
+ }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
41
+ return fieldPoint ? fieldPoint.copy() : Vector.origin;
42
+ }
43
+ init(container) {
44
+ this.container = container;
45
+ this._setup();
46
+ }
47
+ reset() {
48
+ }
49
+ update() {
50
+ if (!this.container) {
51
+ return;
52
+ }
53
+ this._calculateField();
54
+ this.noiseW += this.options.increment;
55
+ if (!this.options.draw) {
56
+ return;
57
+ }
58
+ this.container.canvas.draw(ctx => {
59
+ this._drawField(ctx);
60
+ });
61
+ }
62
+ _calculateField() {
63
+ const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
64
+ for (let x = 0; x < options.columns; x++) {
65
+ const xColumn = field[x];
66
+ if (!xColumn) {
67
+ continue;
68
+ }
69
+ for (let y = 0; y < options.rows; y++) {
70
+ const yColumn = xColumn[y];
71
+ if (!yColumn) {
72
+ continue;
73
+ }
74
+ for (let z = 0; z < options.layers; z++) {
75
+ const cell = yColumn[z];
76
+ if (!cell) {
77
+ continue;
78
+ }
79
+ cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
80
+ cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * doublePI;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ _drawField(ctx) {
86
+ const { field, options } = this;
87
+ for (let x = 0; x < options.columns; x++) {
88
+ const xColumn = field[x];
89
+ if (!xColumn) {
90
+ continue;
91
+ }
92
+ for (let y = 0; y < options.rows; y++) {
93
+ const yColumn = xColumn[y];
94
+ if (!yColumn) {
95
+ continue;
96
+ }
97
+ const cell = yColumn[firstIndex];
98
+ if (!cell) {
99
+ continue;
100
+ }
101
+ const { angle, length } = cell;
102
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);
103
+ ctx.rotate(angle);
104
+ ctx.strokeStyle = "white";
105
+ ctx.beginPath();
106
+ ctx.moveTo(originCoordinate, originCoordinate);
107
+ ctx.lineTo(originCoordinate, this.options.size * length);
108
+ ctx.stroke();
109
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);
110
+ }
111
+ }
112
+ }
113
+ _initField() {
114
+ const { columns, rows, layers } = this.options;
115
+ this.field = new Array(columns);
116
+ for (let x = 0; x < columns; x++) {
117
+ const newX = new Array(rows);
118
+ for (let y = 0; y < rows; y++) {
119
+ const newY = new Array(layers);
120
+ for (let z = 0; z < layers; z++) {
121
+ newY[z] = Vector.origin;
122
+ }
123
+ newX[y] = newY;
124
+ }
125
+ this.field[x] = newX;
126
+ }
127
+ }
128
+ _resetField() {
129
+ const container = this.container;
130
+ if (!container) {
131
+ return;
132
+ }
133
+ const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
134
+ options.width = container.canvas.size.width;
135
+ options.height = container.canvas.size.height;
136
+ options.size =
137
+ sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
138
+ options.increment =
139
+ sourceOptions["increment"] > empty
140
+ ? sourceOptions["increment"]
141
+ : defaultOptions.increment;
142
+ options.draw = !!sourceOptions["draw"];
143
+ const offset = sourceOptions["offset"];
144
+ options.offset.x = offset?.x ?? defaultOptions.offset.x;
145
+ options.offset.y = offset?.y ?? defaultOptions.offset.y;
146
+ options.offset.z = offset?.z ?? defaultOptions.offset.z;
147
+ const factor = sourceOptions["factor"];
148
+ options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
149
+ options.factor.length = factor?.length ?? defaultOptions.factor.length;
150
+ options.seed = sourceOptions["seed"];
151
+ this.noiseGen.seed(options.seed ?? getRandom());
152
+ options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;
153
+ options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;
154
+ options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;
155
+ this._initField();
156
+ }
157
+ _setup() {
158
+ this.noiseW = 0;
159
+ this._resetField();
160
+ addEventListener("resize", () => {
161
+ this._resetField();
162
+ });
163
+ }
164
+ }
package/cjs/index.js ADDED
@@ -0,0 +1 @@
1
+ export { NoiseFieldGenerator } from "./NoiseFieldGenerator.js";
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,164 @@
1
+ import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
2
+ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
+ a: 1,
4
+ b: 0,
5
+ c: 0,
6
+ d: 1,
7
+ e: 0,
8
+ f: 0,
9
+ }, double = 2, doublePI = Math.PI * double, defaultOptions = {
10
+ draw: false,
11
+ size: 20,
12
+ increment: 0.004,
13
+ columns: 0,
14
+ rows: 0,
15
+ layers: 0,
16
+ width: 0,
17
+ height: 0,
18
+ factor: {
19
+ angle: 0.02,
20
+ length: 0.01,
21
+ },
22
+ offset: {
23
+ x: 40000,
24
+ y: 40000,
25
+ z: 40000,
26
+ },
27
+ };
28
+ export class NoiseFieldGenerator {
29
+ constructor(noiseGen) {
30
+ this.noiseGen = noiseGen;
31
+ this.field = [];
32
+ this.noiseW = 0;
33
+ this.options = deepExtend({}, defaultOptions);
34
+ }
35
+ generate(particle) {
36
+ const pos = particle.getPosition(), { size } = this.options, point = {
37
+ x: Math.max(Math.floor(pos.x / size), originCoordinate),
38
+ y: Math.max(Math.floor(pos.y / size), originCoordinate),
39
+ z: Math.max(Math.floor(pos.z / size), originCoordinate),
40
+ }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
41
+ return fieldPoint ? fieldPoint.copy() : Vector.origin;
42
+ }
43
+ init(container) {
44
+ this.container = container;
45
+ this._setup();
46
+ }
47
+ reset() {
48
+ }
49
+ update() {
50
+ if (!this.container) {
51
+ return;
52
+ }
53
+ this._calculateField();
54
+ this.noiseW += this.options.increment;
55
+ if (!this.options.draw) {
56
+ return;
57
+ }
58
+ this.container.canvas.draw(ctx => {
59
+ this._drawField(ctx);
60
+ });
61
+ }
62
+ _calculateField() {
63
+ const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
64
+ for (let x = 0; x < options.columns; x++) {
65
+ const xColumn = field[x];
66
+ if (!xColumn) {
67
+ continue;
68
+ }
69
+ for (let y = 0; y < options.rows; y++) {
70
+ const yColumn = xColumn[y];
71
+ if (!yColumn) {
72
+ continue;
73
+ }
74
+ for (let z = 0; z < options.layers; z++) {
75
+ const cell = yColumn[z];
76
+ if (!cell) {
77
+ continue;
78
+ }
79
+ cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
80
+ cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * doublePI;
81
+ }
82
+ }
83
+ }
84
+ }
85
+ _drawField(ctx) {
86
+ const { field, options } = this;
87
+ for (let x = 0; x < options.columns; x++) {
88
+ const xColumn = field[x];
89
+ if (!xColumn) {
90
+ continue;
91
+ }
92
+ for (let y = 0; y < options.rows; y++) {
93
+ const yColumn = xColumn[y];
94
+ if (!yColumn) {
95
+ continue;
96
+ }
97
+ const cell = yColumn[firstIndex];
98
+ if (!cell) {
99
+ continue;
100
+ }
101
+ const { angle, length } = cell;
102
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);
103
+ ctx.rotate(angle);
104
+ ctx.strokeStyle = "white";
105
+ ctx.beginPath();
106
+ ctx.moveTo(originCoordinate, originCoordinate);
107
+ ctx.lineTo(originCoordinate, this.options.size * length);
108
+ ctx.stroke();
109
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);
110
+ }
111
+ }
112
+ }
113
+ _initField() {
114
+ const { columns, rows, layers } = this.options;
115
+ this.field = new Array(columns);
116
+ for (let x = 0; x < columns; x++) {
117
+ const newX = new Array(rows);
118
+ for (let y = 0; y < rows; y++) {
119
+ const newY = new Array(layers);
120
+ for (let z = 0; z < layers; z++) {
121
+ newY[z] = Vector.origin;
122
+ }
123
+ newX[y] = newY;
124
+ }
125
+ this.field[x] = newX;
126
+ }
127
+ }
128
+ _resetField() {
129
+ const container = this.container;
130
+ if (!container) {
131
+ return;
132
+ }
133
+ const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
134
+ options.width = container.canvas.size.width;
135
+ options.height = container.canvas.size.height;
136
+ options.size =
137
+ sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
138
+ options.increment =
139
+ sourceOptions["increment"] > empty
140
+ ? sourceOptions["increment"]
141
+ : defaultOptions.increment;
142
+ options.draw = !!sourceOptions["draw"];
143
+ const offset = sourceOptions["offset"];
144
+ options.offset.x = offset?.x ?? defaultOptions.offset.x;
145
+ options.offset.y = offset?.y ?? defaultOptions.offset.y;
146
+ options.offset.z = offset?.z ?? defaultOptions.offset.z;
147
+ const factor = sourceOptions["factor"];
148
+ options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
149
+ options.factor.length = factor?.length ?? defaultOptions.factor.length;
150
+ options.seed = sourceOptions["seed"];
151
+ this.noiseGen.seed(options.seed ?? getRandom());
152
+ options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;
153
+ options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;
154
+ options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;
155
+ this._initField();
156
+ }
157
+ _setup() {
158
+ this.noiseW = 0;
159
+ this._resetField();
160
+ addEventListener("resize", () => {
161
+ this._resetField();
162
+ });
163
+ }
164
+ }
package/esm/index.js ADDED
@@ -0,0 +1 @@
1
+ export { NoiseFieldGenerator } from "./NoiseFieldGenerator.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }