@tsparticles/simplex-noise 4.0.0-beta.0 → 4.0.0-beta.10
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/README.md +17 -0
- package/browser/Classes/SimplexNoise2D.js +8 -6
- package/browser/Classes/SimplexNoise3D.js +4 -3
- package/browser/Classes/SimplexNoise4D.js +4 -3
- package/cjs/Classes/SimplexNoise2D.js +8 -6
- package/cjs/Classes/SimplexNoise3D.js +4 -3
- package/cjs/Classes/SimplexNoise4D.js +4 -3
- package/esm/Classes/SimplexNoise2D.js +8 -6
- package/esm/Classes/SimplexNoise3D.js +4 -3
- package/esm/Classes/SimplexNoise4D.js +4 -3
- package/package.json +2 -3
- package/report.html +84 -29
- package/tsparticles.simplex.noise.js +4 -4
- package/tsparticles.simplex.noise.min.js +1 -1
- package/umd/Classes/SimplexNoise2D.js +0 -174
- package/umd/Classes/SimplexNoise3D.js +0 -552
- package/umd/Classes/SimplexNoise4D.js +0 -2889
- package/umd/Contributions.js +0 -12
- package/umd/SimplexNoise.js +0 -27
- package/umd/index.js +0 -15
- package/umd/utils.js +0 -18
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/tsparticles/tsparticles) library for simplex noise movement.
|
|
10
10
|
|
|
11
|
+
## Quick checklist
|
|
12
|
+
|
|
13
|
+
1. Install `@tsparticles/engine` (or use the CDN bundle below)
|
|
14
|
+
2. Call the package loader function(s) before `tsParticles.load(...)`
|
|
15
|
+
3. Apply the package options in your `tsParticles.load(...)` config
|
|
16
|
+
|
|
11
17
|
## How to use it
|
|
12
18
|
|
|
13
19
|
### CDN / Vanilla JS / jQuery
|
|
@@ -72,3 +78,14 @@ import { loadSimplexNoisePath } from "@tsparticles/path-simplex-noise";
|
|
|
72
78
|
await loadSimplexNoisePath(tsParticles);
|
|
73
79
|
})();
|
|
74
80
|
```
|
|
81
|
+
|
|
82
|
+
## Common pitfalls
|
|
83
|
+
|
|
84
|
+
- Calling `tsParticles.load(...)` before `loadSimplexNoisePath(...)`
|
|
85
|
+
- Verify required peer packages before enabling advanced options
|
|
86
|
+
- Change one option group at a time to isolate regressions quickly
|
|
87
|
+
|
|
88
|
+
## Related docs
|
|
89
|
+
|
|
90
|
+
- All packages catalog: <https://github.com/tsparticles/tsparticles>
|
|
91
|
+
- Main docs: <https://particles.js.org/docs/>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const half = 0.5;
|
|
2
3
|
export class SimplexNoise2D {
|
|
3
4
|
_NORM_2D;
|
|
4
5
|
_SQUISH_2D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise2D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm2D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_2D = 1
|
|
15
|
-
this._SQUISH_2D = (Math.sqrt(2 + 1) - 1)
|
|
16
|
-
this._STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1)
|
|
15
|
+
this._NORM_2D = 1 / 47;
|
|
16
|
+
this._SQUISH_2D = (Math.sqrt(2 + 1) - 1) * half;
|
|
17
|
+
this._STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1) * half;
|
|
17
18
|
this._base2D = [
|
|
18
19
|
[1, 1, 0, 1, 0, 1, 0, 0, 0],
|
|
19
20
|
[1, 1, 0, 1, 0, 1, 2, 1, 1],
|
|
@@ -97,10 +98,11 @@ export class SimplexNoise2D {
|
|
|
97
98
|
let value = 0;
|
|
98
99
|
for (let c = _lookup[hash]; c !== undefined; c = c.next) {
|
|
99
100
|
const dx = dx0 + c.dx, dy = dy0 + c.dy, attn = 2 - dx * dx - dy * dy;
|
|
100
|
-
if (attn
|
|
101
|
-
|
|
102
|
-
value += attn * attn * attn * attn * valuePart;
|
|
101
|
+
if (attn <= 0) {
|
|
102
|
+
continue;
|
|
103
103
|
}
|
|
104
|
+
const px = xsb + c.xsb, py = ysb + c.ysb, indexPartA = _perm[px & 0xff], index = _perm2D[(indexPartA + py) & 0xff], valuePart = _gradients2D[index] * dx + _gradients2D[index + 1] * dy;
|
|
105
|
+
value += attn * attn * attn * attn * valuePart;
|
|
104
106
|
}
|
|
105
107
|
return value * _NORM_2D;
|
|
106
108
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const third = 1 / 3;
|
|
2
3
|
export class SimplexNoise3D {
|
|
3
4
|
_NORM_3D;
|
|
4
5
|
_SQUISH_3D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise3D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm3D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_3D = 1
|
|
15
|
-
this._SQUISH_3D = (Math.sqrt(3 + 1) - 1)
|
|
16
|
-
this._STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1)
|
|
15
|
+
this._NORM_3D = 1 / 103;
|
|
16
|
+
this._SQUISH_3D = (Math.sqrt(3 + 1) - 1) * third;
|
|
17
|
+
this._STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1) * third;
|
|
17
18
|
this._base3D = [
|
|
18
19
|
[0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1],
|
|
19
20
|
[2, 1, 1, 0, 2, 1, 0, 1, 2, 0, 1, 1, 3, 1, 1, 1],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const quarter = 0.25;
|
|
2
3
|
export class SimplexNoise4D {
|
|
3
4
|
_NORM_4D;
|
|
4
5
|
_SQUISH_4D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise4D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm4D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_4D = 1
|
|
15
|
-
this._SQUISH_4D = (Math.sqrt(4 + 1) - 1) *
|
|
16
|
-
this._STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) *
|
|
15
|
+
this._NORM_4D = 1 / 30;
|
|
16
|
+
this._SQUISH_4D = (Math.sqrt(4 + 1) - 1) * quarter;
|
|
17
|
+
this._STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) * quarter;
|
|
17
18
|
this._lookup = [];
|
|
18
19
|
this._perm = new Uint8Array(0);
|
|
19
20
|
this._perm4D = new Uint8Array(0);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const half = 0.5;
|
|
2
3
|
export class SimplexNoise2D {
|
|
3
4
|
_NORM_2D;
|
|
4
5
|
_SQUISH_2D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise2D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm2D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_2D = 1
|
|
15
|
-
this._SQUISH_2D = (Math.sqrt(2 + 1) - 1)
|
|
16
|
-
this._STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1)
|
|
15
|
+
this._NORM_2D = 1 / 47;
|
|
16
|
+
this._SQUISH_2D = (Math.sqrt(2 + 1) - 1) * half;
|
|
17
|
+
this._STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1) * half;
|
|
17
18
|
this._base2D = [
|
|
18
19
|
[1, 1, 0, 1, 0, 1, 0, 0, 0],
|
|
19
20
|
[1, 1, 0, 1, 0, 1, 2, 1, 1],
|
|
@@ -97,10 +98,11 @@ export class SimplexNoise2D {
|
|
|
97
98
|
let value = 0;
|
|
98
99
|
for (let c = _lookup[hash]; c !== undefined; c = c.next) {
|
|
99
100
|
const dx = dx0 + c.dx, dy = dy0 + c.dy, attn = 2 - dx * dx - dy * dy;
|
|
100
|
-
if (attn
|
|
101
|
-
|
|
102
|
-
value += attn * attn * attn * attn * valuePart;
|
|
101
|
+
if (attn <= 0) {
|
|
102
|
+
continue;
|
|
103
103
|
}
|
|
104
|
+
const px = xsb + c.xsb, py = ysb + c.ysb, indexPartA = _perm[px & 0xff], index = _perm2D[(indexPartA + py) & 0xff], valuePart = _gradients2D[index] * dx + _gradients2D[index + 1] * dy;
|
|
105
|
+
value += attn * attn * attn * attn * valuePart;
|
|
104
106
|
}
|
|
105
107
|
return value * _NORM_2D;
|
|
106
108
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const third = 1 / 3;
|
|
2
3
|
export class SimplexNoise3D {
|
|
3
4
|
_NORM_3D;
|
|
4
5
|
_SQUISH_3D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise3D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm3D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_3D = 1
|
|
15
|
-
this._SQUISH_3D = (Math.sqrt(3 + 1) - 1)
|
|
16
|
-
this._STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1)
|
|
15
|
+
this._NORM_3D = 1 / 103;
|
|
16
|
+
this._SQUISH_3D = (Math.sqrt(3 + 1) - 1) * third;
|
|
17
|
+
this._STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1) * third;
|
|
17
18
|
this._base3D = [
|
|
18
19
|
[0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1],
|
|
19
20
|
[2, 1, 1, 0, 2, 1, 0, 1, 2, 0, 1, 1, 3, 1, 1, 1],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const quarter = 0.25;
|
|
2
3
|
export class SimplexNoise4D {
|
|
3
4
|
_NORM_4D;
|
|
4
5
|
_SQUISH_4D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise4D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm4D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_4D = 1
|
|
15
|
-
this._SQUISH_4D = (Math.sqrt(4 + 1) - 1) *
|
|
16
|
-
this._STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) *
|
|
15
|
+
this._NORM_4D = 1 / 30;
|
|
16
|
+
this._SQUISH_4D = (Math.sqrt(4 + 1) - 1) * quarter;
|
|
17
|
+
this._STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) * quarter;
|
|
17
18
|
this._lookup = [];
|
|
18
19
|
this._perm = new Uint8Array(0);
|
|
19
20
|
this._perm4D = new Uint8Array(0);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const half = 0.5;
|
|
2
3
|
export class SimplexNoise2D {
|
|
3
4
|
_NORM_2D;
|
|
4
5
|
_SQUISH_2D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise2D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm2D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_2D = 1
|
|
15
|
-
this._SQUISH_2D = (Math.sqrt(2 + 1) - 1)
|
|
16
|
-
this._STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1)
|
|
15
|
+
this._NORM_2D = 1 / 47;
|
|
16
|
+
this._SQUISH_2D = (Math.sqrt(2 + 1) - 1) * half;
|
|
17
|
+
this._STRETCH_2D = (1 / Math.sqrt(2 + 1) - 1) * half;
|
|
17
18
|
this._base2D = [
|
|
18
19
|
[1, 1, 0, 1, 0, 1, 0, 0, 0],
|
|
19
20
|
[1, 1, 0, 1, 0, 1, 2, 1, 1],
|
|
@@ -97,10 +98,11 @@ export class SimplexNoise2D {
|
|
|
97
98
|
let value = 0;
|
|
98
99
|
for (let c = _lookup[hash]; c !== undefined; c = c.next) {
|
|
99
100
|
const dx = dx0 + c.dx, dy = dy0 + c.dy, attn = 2 - dx * dx - dy * dy;
|
|
100
|
-
if (attn
|
|
101
|
-
|
|
102
|
-
value += attn * attn * attn * attn * valuePart;
|
|
101
|
+
if (attn <= 0) {
|
|
102
|
+
continue;
|
|
103
103
|
}
|
|
104
|
+
const px = xsb + c.xsb, py = ysb + c.ysb, indexPartA = _perm[px & 0xff], index = _perm2D[(indexPartA + py) & 0xff], valuePart = _gradients2D[index] * dx + _gradients2D[index + 1] * dy;
|
|
105
|
+
value += attn * attn * attn * attn * valuePart;
|
|
104
106
|
}
|
|
105
107
|
return value * _NORM_2D;
|
|
106
108
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const third = 1 / 3;
|
|
2
3
|
export class SimplexNoise3D {
|
|
3
4
|
_NORM_3D;
|
|
4
5
|
_SQUISH_3D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise3D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm3D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_3D = 1
|
|
15
|
-
this._SQUISH_3D = (Math.sqrt(3 + 1) - 1)
|
|
16
|
-
this._STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1)
|
|
15
|
+
this._NORM_3D = 1 / 103;
|
|
16
|
+
this._SQUISH_3D = (Math.sqrt(3 + 1) - 1) * third;
|
|
17
|
+
this._STRETCH_3D = (1 / Math.sqrt(3 + 1) - 1) * third;
|
|
17
18
|
this._base3D = [
|
|
18
19
|
[0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1],
|
|
19
20
|
[2, 1, 1, 0, 2, 1, 0, 1, 2, 0, 1, 1, 3, 1, 1, 1],
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { shuffleSeed } from "../utils.js";
|
|
2
|
+
const quarter = 0.25;
|
|
2
3
|
export class SimplexNoise4D {
|
|
3
4
|
_NORM_4D;
|
|
4
5
|
_SQUISH_4D;
|
|
@@ -11,9 +12,9 @@ export class SimplexNoise4D {
|
|
|
11
12
|
_perm;
|
|
12
13
|
_perm4D;
|
|
13
14
|
constructor() {
|
|
14
|
-
this._NORM_4D = 1
|
|
15
|
-
this._SQUISH_4D = (Math.sqrt(4 + 1) - 1) *
|
|
16
|
-
this._STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) *
|
|
15
|
+
this._NORM_4D = 1 / 30;
|
|
16
|
+
this._SQUISH_4D = (Math.sqrt(4 + 1) - 1) * quarter;
|
|
17
|
+
this._STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) * quarter;
|
|
17
18
|
this._lookup = [];
|
|
18
19
|
this._perm = new Uint8Array(0);
|
|
19
20
|
this._perm4D = new Uint8Array(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/simplex-noise",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.10",
|
|
4
4
|
"description": "tsParticles simplex noise library",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -97,8 +97,7 @@
|
|
|
97
97
|
"browser": "./browser/index.js",
|
|
98
98
|
"import": "./esm/index.js",
|
|
99
99
|
"require": "./cjs/index.js",
|
|
100
|
-
"
|
|
101
|
-
"default": "./cjs/index.js"
|
|
100
|
+
"default": "./esm/index.js"
|
|
102
101
|
},
|
|
103
102
|
"./package.json": "./package.json"
|
|
104
103
|
},
|