@tsparticles/smooth-value-noise 3.9.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.
@@ -0,0 +1,116 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.9.0
8
+ */
9
+ /*
10
+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
+ * This devtool is neither made for production nor for readable output files.
12
+ * It uses "eval()" calls to create a separate source file in the browser devtools.
13
+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
+ * or disable the default devtool with "devtool: false".
15
+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
16
+ */
17
+ (function webpackUniversalModuleDefinition(root, factory) {
18
+ if(typeof exports === 'object' && typeof module === 'object')
19
+ module.exports = factory();
20
+ else if(typeof define === 'function' && define.amd)
21
+ define([], factory);
22
+ else {
23
+ var a = factory();
24
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
25
+ }
26
+ })(this, () => {
27
+ return /******/ (() => { // webpackBootstrap
28
+ /******/ "use strict";
29
+ /******/ var __webpack_modules__ = ({
30
+
31
+ /***/ "./dist/browser/SmoothValueNoise.js":
32
+ /*!******************************************!*\
33
+ !*** ./dist/browser/SmoothValueNoise.js ***!
34
+ \******************************************/
35
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
36
+
37
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SmoothValueNoise: () => (/* binding */ SmoothValueNoise)\n/* harmony export */ });\nconst lerp = (a, b, t) => {\n return a + t * (b - a);\n },\n smoothstep = t => {\n return t * t * (3 - 2 * t);\n },\n fract = x => {\n return x - Math.floor(x);\n };\nclass SmoothValueNoise {\n constructor() {\n this._coeffW = 29.537;\n this._coeffX = 127.1;\n this._coeffY = 311.7;\n this._coeffZ = 78.233;\n this._coeffZW = 37.719;\n this._scaleFactor = 43758.5453;\n }\n noise2d(x, y) {\n const x0 = Math.floor(x),\n y0 = Math.floor(y),\n x1 = x0 + 1,\n y1 = y0 + 1,\n sx = smoothstep(x - x0),\n sy = smoothstep(y - y0),\n n00 = this._valueNoise2D(x0, y0),\n n10 = this._valueNoise2D(x1, y0),\n n01 = this._valueNoise2D(x0, y1),\n n11 = this._valueNoise2D(x1, y1),\n ix0 = lerp(n00, n10, sx),\n ix1 = lerp(n01, n11, sx);\n return lerp(ix0, ix1, sy);\n }\n noise3d(x, y, z) {\n const x0 = Math.floor(x),\n y0 = Math.floor(y),\n z0 = Math.floor(z),\n x1 = x0 + 1,\n y1 = y0 + 1,\n z1 = z0 + 1,\n sx = smoothstep(x - x0),\n sy = smoothstep(y - y0),\n sz = smoothstep(z - z0),\n n000 = this._valueNoise3D(x0, y0, z0),\n n100 = this._valueNoise3D(x1, y0, z0),\n n010 = this._valueNoise3D(x0, y1, z0),\n n110 = this._valueNoise3D(x1, y1, z0),\n n001 = this._valueNoise3D(x0, y0, z1),\n n101 = this._valueNoise3D(x1, y0, z1),\n n011 = this._valueNoise3D(x0, y1, z1),\n n111 = this._valueNoise3D(x1, y1, z1),\n ix00 = lerp(n000, n100, sx),\n ix10 = lerp(n010, n110, sx),\n ix01 = lerp(n001, n101, sx),\n ix11 = lerp(n011, n111, sx),\n iy0 = lerp(ix00, ix10, sy),\n iy1 = lerp(ix01, ix11, sy);\n return lerp(iy0, iy1, sz);\n }\n noise4d(x, y, z, w) {\n const x0 = Math.floor(x),\n y0 = Math.floor(y),\n z0 = Math.floor(z),\n w0 = Math.floor(w),\n x1 = x0 + 1,\n y1 = y0 + 1,\n z1 = z0 + 1,\n w1 = w0 + 1,\n sx = smoothstep(x - x0),\n sy = smoothstep(y - y0),\n sz = smoothstep(z - z0),\n sw = smoothstep(w - w0),\n n0000 = this._valueNoise4D(x0, y0, z0, w0),\n n1000 = this._valueNoise4D(x1, y0, z0, w0),\n n0100 = this._valueNoise4D(x0, y1, z0, w0),\n n1100 = this._valueNoise4D(x1, y1, z0, w0),\n n0010 = this._valueNoise4D(x0, y0, z1, w0),\n n1010 = this._valueNoise4D(x1, y0, z1, w0),\n n0110 = this._valueNoise4D(x0, y1, z1, w0),\n n1110 = this._valueNoise4D(x1, y1, z1, w0),\n n0001 = this._valueNoise4D(x0, y0, z0, w1),\n n1001 = this._valueNoise4D(x1, y0, z0, w1),\n n0101 = this._valueNoise4D(x0, y1, z0, w1),\n n1101 = this._valueNoise4D(x1, y1, z0, w1),\n n0011 = this._valueNoise4D(x0, y0, z1, w1),\n n1011 = this._valueNoise4D(x1, y0, z1, w1),\n n0111 = this._valueNoise4D(x0, y1, z1, w1),\n n1111 = this._valueNoise4D(x1, y1, z1, w1),\n ix000 = lerp(n0000, n1000, sx),\n ix100 = lerp(n0100, n1100, sx),\n ix010 = lerp(n0010, n1010, sx),\n ix110 = lerp(n0110, n1110, sx),\n ix001 = lerp(n0001, n1001, sx),\n ix101 = lerp(n0101, n1101, sx),\n ix011 = lerp(n0011, n1011, sx),\n ix111 = lerp(n0111, n1111, sx),\n iy00 = lerp(ix000, ix100, sy),\n iy10 = lerp(ix010, ix110, sy),\n iy01 = lerp(ix001, ix101, sy),\n iy11 = lerp(ix011, ix111, sy),\n iz0 = lerp(iy00, iy10, sz),\n iz1 = lerp(iy01, iy11, sz);\n return lerp(iz0, iz1, sw);\n }\n seed(seed) {\n const s = Math.sin(seed) * 10000;\n this._coeffX = fract(s * 15731);\n this._coeffY = fract(s * 789221);\n this._coeffZ = fract(s * 1376312589);\n this._coeffZW = fract(s * 974634777);\n this._coeffW = fract(s * 592558533);\n this._scaleFactor = 43758.5453;\n }\n _valueNoise2D(x, y) {\n const n = Math.sin(x * this._coeffX + y * this._coeffY) * this._scaleFactor;\n return (n - Math.floor(n)) * 2 - 1;\n }\n _valueNoise3D(x, y, z) {\n const n = Math.sin(x * this._coeffX + y * this._coeffY + z * this._coeffZ) * this._scaleFactor;\n return (n - Math.floor(n)) * 2 - 1;\n }\n _valueNoise4D(x, y, z, w) {\n const n = Math.sin(x * this._coeffX + y * this._coeffY + z * this._coeffZW + w * this._coeffW) * this._scaleFactor;\n return (n - Math.floor(n)) * 2 - 1;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/smooth-value-noise/./dist/browser/SmoothValueNoise.js?\n}");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "./dist/browser/index.js":
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
46
+
47
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SmoothValueNoise: () => (/* reexport safe */ _SmoothValueNoise_js__WEBPACK_IMPORTED_MODULE_0__.SmoothValueNoise)\n/* harmony export */ });\n/* harmony import */ var _SmoothValueNoise_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SmoothValueNoise.js */ \"./dist/browser/SmoothValueNoise.js\");\n\n\n//# sourceURL=webpack://@tsparticles/smooth-value-noise/./dist/browser/index.js?\n}");
48
+
49
+ /***/ })
50
+
51
+ /******/ });
52
+ /************************************************************************/
53
+ /******/ // The module cache
54
+ /******/ var __webpack_module_cache__ = {};
55
+ /******/
56
+ /******/ // The require function
57
+ /******/ function __webpack_require__(moduleId) {
58
+ /******/ // Check if module is in cache
59
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
60
+ /******/ if (cachedModule !== undefined) {
61
+ /******/ return cachedModule.exports;
62
+ /******/ }
63
+ /******/ // Create a new module (and put it into the cache)
64
+ /******/ var module = __webpack_module_cache__[moduleId] = {
65
+ /******/ // no module.id needed
66
+ /******/ // no module.loaded needed
67
+ /******/ exports: {}
68
+ /******/ };
69
+ /******/
70
+ /******/ // Execute the module function
71
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
72
+ /******/
73
+ /******/ // Return the exports of the module
74
+ /******/ return module.exports;
75
+ /******/ }
76
+ /******/
77
+ /************************************************************************/
78
+ /******/ /* webpack/runtime/define property getters */
79
+ /******/ (() => {
80
+ /******/ // define getter functions for harmony exports
81
+ /******/ __webpack_require__.d = (exports, definition) => {
82
+ /******/ for(var key in definition) {
83
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
84
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
85
+ /******/ }
86
+ /******/ }
87
+ /******/ };
88
+ /******/ })();
89
+ /******/
90
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
91
+ /******/ (() => {
92
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
93
+ /******/ })();
94
+ /******/
95
+ /******/ /* webpack/runtime/make namespace object */
96
+ /******/ (() => {
97
+ /******/ // define __esModule on exports
98
+ /******/ __webpack_require__.r = (exports) => {
99
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
100
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
101
+ /******/ }
102
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
103
+ /******/ };
104
+ /******/ })();
105
+ /******/
106
+ /************************************************************************/
107
+ /******/
108
+ /******/ // startup
109
+ /******/ // Load entry module and return exports
110
+ /******/ // This entry module can't be inlined because the eval devtool is used.
111
+ /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
112
+ /******/
113
+ /******/ return __webpack_exports__;
114
+ /******/ })()
115
+ ;
116
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.smooth.value.noise.min.js.LICENSE.txt */
2
+ !function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o();else if("function"==typeof define&&define.amd)define([],o);else{var t=o();for(var s in t)("object"==typeof exports?exports:e)[s]=t[s]}}(this,(()=>(()=>{var e={d:(o,t)=>{for(var s in t)e.o(t,s)&&!e.o(o,s)&&Object.defineProperty(o,s,{enumerable:!0,get:t[s]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{SmoothValueNoise:()=>a});const t=(e,o,t)=>e+t*(o-e),s=e=>e*e*(3-2*e),i=e=>e-Math.floor(e);class a{constructor(){this._coeffW=29.537,this._coeffX=127.1,this._coeffY=311.7,this._coeffZ=78.233,this._coeffZW=37.719,this._scaleFactor=43758.5453}noise2d(e,o){const i=Math.floor(e),a=Math.floor(o),h=i+1,f=a+1,l=s(e-i),r=s(o-a),_=this._valueNoise2D(i,a),c=this._valueNoise2D(h,a),u=this._valueNoise2D(i,f),n=this._valueNoise2D(h,f),v=t(_,c,l),N=t(u,n,l);return t(v,N,r)}noise3d(e,o,i){const a=Math.floor(e),h=Math.floor(o),f=Math.floor(i),l=a+1,r=h+1,_=f+1,c=s(e-a),u=s(o-h),n=s(i-f),v=this._valueNoise3D(a,h,f),N=this._valueNoise3D(l,h,f),D=this._valueNoise3D(a,r,f),d=this._valueNoise3D(l,r,f),M=this._valueNoise3D(a,h,_),p=this._valueNoise3D(l,h,_),y=this._valueNoise3D(a,r,_),b=this._valueNoise3D(l,r,_),m=t(v,N,c),j=t(D,d,c),S=t(M,p,c),W=t(y,b,c),Z=t(m,j,u),g=t(S,W,u);return t(Z,g,n)}noise4d(e,o,i,a){const h=Math.floor(e),f=Math.floor(o),l=Math.floor(i),r=Math.floor(a),_=h+1,c=f+1,u=l+1,n=r+1,v=s(e-h),N=s(o-f),D=s(i-l),d=s(a-r),M=this._valueNoise4D(h,f,l,r),p=this._valueNoise4D(_,f,l,r),y=this._valueNoise4D(h,c,l,r),b=this._valueNoise4D(_,c,l,r),m=this._valueNoise4D(h,f,u,r),j=this._valueNoise4D(_,f,u,r),S=this._valueNoise4D(h,c,u,r),W=this._valueNoise4D(_,c,u,r),Z=this._valueNoise4D(h,f,l,n),g=this._valueNoise4D(_,f,l,n),F=this._valueNoise4D(h,c,l,n),O=this._valueNoise4D(_,c,l,n),X=this._valueNoise4D(h,f,u,n),Y=this._valueNoise4D(_,f,u,n),x=this._valueNoise4D(h,c,u,n),P=this._valueNoise4D(_,c,u,n),T=t(M,p,v),w=t(y,b,v),V=t(m,j,v),k=t(S,W,v),q=t(Z,g,v),z=t(F,O,v),A=t(X,Y,v),B=t(x,P,v),C=t(T,w,N),E=t(V,k,N),G=t(q,z,N),H=t(A,B,N),I=t(C,E,D),J=t(G,H,D);return t(I,J,d)}seed(e){const o=1e4*Math.sin(e);this._coeffX=i(15731*o),this._coeffY=i(789221*o),this._coeffZ=i(1376312589*o),this._coeffZW=i(974634777*o),this._coeffW=i(592558533*o),this._scaleFactor=43758.5453}_valueNoise2D(e,o){const t=Math.sin(e*this._coeffX+o*this._coeffY)*this._scaleFactor;return 2*(t-Math.floor(t))-1}_valueNoise3D(e,o,t){const s=Math.sin(e*this._coeffX+o*this._coeffY+t*this._coeffZ)*this._scaleFactor;return 2*(s-Math.floor(s))-1}_valueNoise4D(e,o,t,s){const i=Math.sin(e*this._coeffX+o*this._coeffY+t*this._coeffZW+s*this._coeffW)*this._scaleFactor;return 2*(i-Math.floor(i))-1}}return o})()));
@@ -0,0 +1 @@
1
+ /*! tsParticles Smooth Value Noise v3.9.0 by Matteo Bruni */
@@ -0,0 +1,15 @@
1
+ export declare class SmoothValueNoise {
2
+ private _coeffW;
3
+ private _coeffX;
4
+ private _coeffY;
5
+ private _coeffZ;
6
+ private _coeffZW;
7
+ private _scaleFactor;
8
+ noise2d(x: number, y: number): number;
9
+ noise3d(x: number, y: number, z: number): number;
10
+ noise4d(x: number, y: number, z: number, w: number): number;
11
+ seed(seed: number): void;
12
+ private _valueNoise2D;
13
+ private _valueNoise3D;
14
+ private _valueNoise4D;
15
+ }
@@ -0,0 +1 @@
1
+ export { SmoothValueNoise } from "./SmoothValueNoise.js";
@@ -0,0 +1,64 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SmoothValueNoise = void 0;
13
+ const lerp = (a, b, t) => {
14
+ return a + t * (b - a);
15
+ }, smoothstep = (t) => {
16
+ return t * t * (3 - 2 * t);
17
+ }, fract = (x) => {
18
+ return x - Math.floor(x);
19
+ };
20
+ class SmoothValueNoise {
21
+ constructor() {
22
+ this._coeffW = 29.537;
23
+ this._coeffX = 127.1;
24
+ this._coeffY = 311.7;
25
+ this._coeffZ = 78.233;
26
+ this._coeffZW = 37.719;
27
+ this._scaleFactor = 43758.5453;
28
+ }
29
+ noise2d(x, y) {
30
+ const x0 = Math.floor(x), y0 = Math.floor(y), x1 = x0 + 1, y1 = y0 + 1, sx = smoothstep(x - x0), sy = smoothstep(y - y0), n00 = this._valueNoise2D(x0, y0), n10 = this._valueNoise2D(x1, y0), n01 = this._valueNoise2D(x0, y1), n11 = this._valueNoise2D(x1, y1), ix0 = lerp(n00, n10, sx), ix1 = lerp(n01, n11, sx);
31
+ return lerp(ix0, ix1, sy);
32
+ }
33
+ noise3d(x, y, z) {
34
+ const x0 = Math.floor(x), y0 = Math.floor(y), z0 = Math.floor(z), x1 = x0 + 1, y1 = y0 + 1, z1 = z0 + 1, sx = smoothstep(x - x0), sy = smoothstep(y - y0), sz = smoothstep(z - z0), n000 = this._valueNoise3D(x0, y0, z0), n100 = this._valueNoise3D(x1, y0, z0), n010 = this._valueNoise3D(x0, y1, z0), n110 = this._valueNoise3D(x1, y1, z0), n001 = this._valueNoise3D(x0, y0, z1), n101 = this._valueNoise3D(x1, y0, z1), n011 = this._valueNoise3D(x0, y1, z1), n111 = this._valueNoise3D(x1, y1, z1), ix00 = lerp(n000, n100, sx), ix10 = lerp(n010, n110, sx), ix01 = lerp(n001, n101, sx), ix11 = lerp(n011, n111, sx), iy0 = lerp(ix00, ix10, sy), iy1 = lerp(ix01, ix11, sy);
35
+ return lerp(iy0, iy1, sz);
36
+ }
37
+ noise4d(x, y, z, w) {
38
+ const x0 = Math.floor(x), y0 = Math.floor(y), z0 = Math.floor(z), w0 = Math.floor(w), x1 = x0 + 1, y1 = y0 + 1, z1 = z0 + 1, w1 = w0 + 1, sx = smoothstep(x - x0), sy = smoothstep(y - y0), sz = smoothstep(z - z0), sw = smoothstep(w - w0), n0000 = this._valueNoise4D(x0, y0, z0, w0), n1000 = this._valueNoise4D(x1, y0, z0, w0), n0100 = this._valueNoise4D(x0, y1, z0, w0), n1100 = this._valueNoise4D(x1, y1, z0, w0), n0010 = this._valueNoise4D(x0, y0, z1, w0), n1010 = this._valueNoise4D(x1, y0, z1, w0), n0110 = this._valueNoise4D(x0, y1, z1, w0), n1110 = this._valueNoise4D(x1, y1, z1, w0), n0001 = this._valueNoise4D(x0, y0, z0, w1), n1001 = this._valueNoise4D(x1, y0, z0, w1), n0101 = this._valueNoise4D(x0, y1, z0, w1), n1101 = this._valueNoise4D(x1, y1, z0, w1), n0011 = this._valueNoise4D(x0, y0, z1, w1), n1011 = this._valueNoise4D(x1, y0, z1, w1), n0111 = this._valueNoise4D(x0, y1, z1, w1), n1111 = this._valueNoise4D(x1, y1, z1, w1), ix000 = lerp(n0000, n1000, sx), ix100 = lerp(n0100, n1100, sx), ix010 = lerp(n0010, n1010, sx), ix110 = lerp(n0110, n1110, sx), ix001 = lerp(n0001, n1001, sx), ix101 = lerp(n0101, n1101, sx), ix011 = lerp(n0011, n1011, sx), ix111 = lerp(n0111, n1111, sx), iy00 = lerp(ix000, ix100, sy), iy10 = lerp(ix010, ix110, sy), iy01 = lerp(ix001, ix101, sy), iy11 = lerp(ix011, ix111, sy), iz0 = lerp(iy00, iy10, sz), iz1 = lerp(iy01, iy11, sz);
39
+ return lerp(iz0, iz1, sw);
40
+ }
41
+ seed(seed) {
42
+ const s = Math.sin(seed) * 10000;
43
+ this._coeffX = fract(s * 15731);
44
+ this._coeffY = fract(s * 789221);
45
+ this._coeffZ = fract(s * 1376312589);
46
+ this._coeffZW = fract(s * 974634777);
47
+ this._coeffW = fract(s * 592558533);
48
+ this._scaleFactor = 43758.5453;
49
+ }
50
+ _valueNoise2D(x, y) {
51
+ const n = Math.sin(x * this._coeffX + y * this._coeffY) * this._scaleFactor;
52
+ return (n - Math.floor(n)) * 2 - 1;
53
+ }
54
+ _valueNoise3D(x, y, z) {
55
+ const n = Math.sin(x * this._coeffX + y * this._coeffY + z * this._coeffZ) * this._scaleFactor;
56
+ return (n - Math.floor(n)) * 2 - 1;
57
+ }
58
+ _valueNoise4D(x, y, z, w) {
59
+ const n = Math.sin(x * this._coeffX + y * this._coeffY + z * this._coeffZW + w * this._coeffW) * this._scaleFactor;
60
+ return (n - Math.floor(n)) * 2 - 1;
61
+ }
62
+ }
63
+ exports.SmoothValueNoise = SmoothValueNoise;
64
+ });
package/umd/index.js ADDED
@@ -0,0 +1,15 @@
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./SmoothValueNoise.js"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ "use strict";
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.SmoothValueNoise = void 0;
13
+ var SmoothValueNoise_js_1 = require("./SmoothValueNoise.js");
14
+ Object.defineProperty(exports, "SmoothValueNoise", { enumerable: true, get: function () { return SmoothValueNoise_js_1.SmoothValueNoise; } });
15
+ });