@tsparticles/fractal-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.
- package/LICENSE +21 -0
- package/README.md +74 -0
- package/browser/FractalNoise.js +40 -0
- package/browser/index.js +1 -0
- package/browser/package.json +1 -0
- package/cjs/FractalNoise.js +44 -0
- package/cjs/index.js +5 -0
- package/cjs/package.json +1 -0
- package/esm/FractalNoise.js +40 -0
- package/esm/index.js +1 -0
- package/esm/package.json +1 -0
- package/package.json +108 -0
- package/report.html +39 -0
- package/tsparticles.fractal.noise.js +138 -0
- package/tsparticles.fractal.noise.min.js +2 -0
- package/tsparticles.fractal.noise.min.js.LICENSE.txt +1 -0
- package/types/FractalNoise.d.ts +8 -0
- package/types/index.d.ts +1 -0
- package/umd/FractalNoise.js +54 -0
- package/umd/index.js +15 -0
|
@@ -0,0 +1,138 @@
|
|
|
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(require("@tsparticles/smooth-value-noise"));
|
|
20
|
+
else if(typeof define === 'function' && define.amd)
|
|
21
|
+
define(["@tsparticles/smooth-value-noise"], factory);
|
|
22
|
+
else {
|
|
23
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/smooth-value-noise")) : factory(root["window"]);
|
|
24
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
+
}
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_smooth_value_noise__) => {
|
|
27
|
+
return /******/ (() => { // webpackBootstrap
|
|
28
|
+
/******/ "use strict";
|
|
29
|
+
/******/ var __webpack_modules__ = ({
|
|
30
|
+
|
|
31
|
+
/***/ "./dist/browser/FractalNoise.js":
|
|
32
|
+
/*!**************************************!*\
|
|
33
|
+
!*** ./dist/browser/FractalNoise.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 */ FractalNoise: () => (/* binding */ FractalNoise)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_smooth_value_noise__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/smooth-value-noise */ \"@tsparticles/smooth-value-noise\");\n/* harmony import */ var _tsparticles_smooth_value_noise__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_smooth_value_noise__WEBPACK_IMPORTED_MODULE_0__);\n\nclass FractalNoise {\n constructor() {\n this._smoothValueNoise = new _tsparticles_smooth_value_noise__WEBPACK_IMPORTED_MODULE_0__.SmoothValueNoise();\n }\n noise2d(x, y, octaves = 5, persistence = 0.5, lacunarity = 2.0) {\n let total = 0,\n frequency = 1,\n amplitude = 1,\n maxValue = 0;\n for (let i = 0; i < octaves; i++) {\n total += this._smoothValueNoise.noise2d(x * frequency, y * frequency) * amplitude;\n maxValue += amplitude;\n amplitude *= persistence;\n frequency *= lacunarity;\n }\n return total / maxValue;\n }\n noise3d(x, y, z, octaves = 5, persistence = 0.5, lacunarity = 2.0) {\n let total = 0,\n frequency = 1,\n amplitude = 1,\n maxValue = 0;\n for (let i = 0; i < octaves; i++) {\n total += this._smoothValueNoise.noise3d(x * frequency, y * frequency, z * frequency) * amplitude;\n maxValue += amplitude;\n amplitude *= persistence;\n frequency *= lacunarity;\n }\n return total / maxValue;\n }\n noise4d(x, y, z, w, octaves = 5, persistence = 0.5, lacunarity = 2.0) {\n let total = 0,\n frequency = 1,\n amplitude = 1,\n maxValue = 0;\n for (let i = 0; i < octaves; i++) {\n total += this._smoothValueNoise.noise4d(x * frequency, y * frequency, z * frequency, w * frequency) * amplitude;\n maxValue += amplitude;\n amplitude *= persistence;\n frequency *= lacunarity;\n }\n return total / maxValue;\n }\n seed(seed) {\n this._smoothValueNoise.seed(seed);\n }\n}\n\n//# sourceURL=webpack://@tsparticles/fractal-noise/./dist/browser/FractalNoise.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 */ FractalNoise: () => (/* reexport safe */ _FractalNoise_js__WEBPACK_IMPORTED_MODULE_0__.FractalNoise)\n/* harmony export */ });\n/* harmony import */ var _FractalNoise_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FractalNoise.js */ \"./dist/browser/FractalNoise.js\");\n\n\n//# sourceURL=webpack://@tsparticles/fractal-noise/./dist/browser/index.js?\n}");
|
|
48
|
+
|
|
49
|
+
/***/ }),
|
|
50
|
+
|
|
51
|
+
/***/ "@tsparticles/smooth-value-noise":
|
|
52
|
+
/*!*********************************************************************************************************************************************************************!*\
|
|
53
|
+
!*** external {"commonjs":"@tsparticles/smooth-value-noise","commonjs2":"@tsparticles/smooth-value-noise","amd":"@tsparticles/smooth-value-noise","root":"window"} ***!
|
|
54
|
+
\*********************************************************************************************************************************************************************/
|
|
55
|
+
/***/ ((module) => {
|
|
56
|
+
|
|
57
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_smooth_value_noise__;
|
|
58
|
+
|
|
59
|
+
/***/ })
|
|
60
|
+
|
|
61
|
+
/******/ });
|
|
62
|
+
/************************************************************************/
|
|
63
|
+
/******/ // The module cache
|
|
64
|
+
/******/ var __webpack_module_cache__ = {};
|
|
65
|
+
/******/
|
|
66
|
+
/******/ // The require function
|
|
67
|
+
/******/ function __webpack_require__(moduleId) {
|
|
68
|
+
/******/ // Check if module is in cache
|
|
69
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
70
|
+
/******/ if (cachedModule !== undefined) {
|
|
71
|
+
/******/ return cachedModule.exports;
|
|
72
|
+
/******/ }
|
|
73
|
+
/******/ // Create a new module (and put it into the cache)
|
|
74
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
75
|
+
/******/ // no module.id needed
|
|
76
|
+
/******/ // no module.loaded needed
|
|
77
|
+
/******/ exports: {}
|
|
78
|
+
/******/ };
|
|
79
|
+
/******/
|
|
80
|
+
/******/ // Execute the module function
|
|
81
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
82
|
+
/******/
|
|
83
|
+
/******/ // Return the exports of the module
|
|
84
|
+
/******/ return module.exports;
|
|
85
|
+
/******/ }
|
|
86
|
+
/******/
|
|
87
|
+
/************************************************************************/
|
|
88
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
89
|
+
/******/ (() => {
|
|
90
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
91
|
+
/******/ __webpack_require__.n = (module) => {
|
|
92
|
+
/******/ var getter = module && module.__esModule ?
|
|
93
|
+
/******/ () => (module['default']) :
|
|
94
|
+
/******/ () => (module);
|
|
95
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
96
|
+
/******/ return getter;
|
|
97
|
+
/******/ };
|
|
98
|
+
/******/ })();
|
|
99
|
+
/******/
|
|
100
|
+
/******/ /* webpack/runtime/define property getters */
|
|
101
|
+
/******/ (() => {
|
|
102
|
+
/******/ // define getter functions for harmony exports
|
|
103
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
104
|
+
/******/ for(var key in definition) {
|
|
105
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
106
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
107
|
+
/******/ }
|
|
108
|
+
/******/ }
|
|
109
|
+
/******/ };
|
|
110
|
+
/******/ })();
|
|
111
|
+
/******/
|
|
112
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
113
|
+
/******/ (() => {
|
|
114
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
115
|
+
/******/ })();
|
|
116
|
+
/******/
|
|
117
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
118
|
+
/******/ (() => {
|
|
119
|
+
/******/ // define __esModule on exports
|
|
120
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
121
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
122
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
123
|
+
/******/ }
|
|
124
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
125
|
+
/******/ };
|
|
126
|
+
/******/ })();
|
|
127
|
+
/******/
|
|
128
|
+
/************************************************************************/
|
|
129
|
+
/******/
|
|
130
|
+
/******/ // startup
|
|
131
|
+
/******/ // Load entry module and return exports
|
|
132
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
133
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
134
|
+
/******/
|
|
135
|
+
/******/ return __webpack_exports__;
|
|
136
|
+
/******/ })()
|
|
137
|
+
;
|
|
138
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.fractal.noise.min.js.LICENSE.txt */
|
|
2
|
+
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("@tsparticles/smooth-value-noise"));else if("function"==typeof define&&define.amd)define(["@tsparticles/smooth-value-noise"],o);else{var t="object"==typeof exports?o(require("@tsparticles/smooth-value-noise")):o(e.window);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{var o={434:o=>{o.exports=e}},t={};function r(e){var s=t[e];if(void 0!==s)return s.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,r),i.exports}r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};r.r(s),r.d(s,{FractalNoise:()=>n});var i=r(434);class n{constructor(){this._smoothValueNoise=new i.SmoothValueNoise}noise2d(e,o,t=5,r=.5,s=2){let i=0,n=1,l=1,a=0;for(let u=0;u<t;u++)i+=this._smoothValueNoise.noise2d(e*n,o*n)*l,a+=l,l*=r,n*=s;return i/a}noise3d(e,o,t,r=5,s=.5,i=2){let n=0,l=1,a=1,u=0;for(let d=0;d<r;d++)n+=this._smoothValueNoise.noise3d(e*l,o*l,t*l)*a,u+=a,a*=s,l*=i;return n/u}noise4d(e,o,t,r,s=5,i=.5,n=2){let l=0,a=1,u=1,d=0;for(let p=0;p<s;p++)l+=this._smoothValueNoise.noise4d(e*a,o*a,t*a,r*a)*u,d+=u,u*=i,a*=n;return l/d}seed(e){this._smoothValueNoise.seed(e)}}return s})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Fractal Noise v3.9.0 by Matteo Bruni */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class FractalNoise {
|
|
2
|
+
private readonly _smoothValueNoise;
|
|
3
|
+
constructor();
|
|
4
|
+
noise2d(x: number, y: number, octaves?: number, persistence?: number, lacunarity?: number): number;
|
|
5
|
+
noise3d(x: number, y: number, z: number, octaves?: number, persistence?: number, lacunarity?: number): number;
|
|
6
|
+
noise4d(x: number, y: number, z: number, w: number, octaves?: number, persistence?: number, lacunarity?: number): number;
|
|
7
|
+
seed(seed: number): void;
|
|
8
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FractalNoise } from "./FractalNoise.js";
|
|
@@ -0,0 +1,54 @@
|
|
|
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", "@tsparticles/smooth-value-noise"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FractalNoise = void 0;
|
|
13
|
+
const smooth_value_noise_1 = require("@tsparticles/smooth-value-noise");
|
|
14
|
+
class FractalNoise {
|
|
15
|
+
constructor() {
|
|
16
|
+
this._smoothValueNoise = new smooth_value_noise_1.SmoothValueNoise();
|
|
17
|
+
}
|
|
18
|
+
noise2d(x, y, octaves = 5, persistence = 0.5, lacunarity = 2.0) {
|
|
19
|
+
let total = 0, frequency = 1, amplitude = 1, maxValue = 0;
|
|
20
|
+
for (let i = 0; i < octaves; i++) {
|
|
21
|
+
total += this._smoothValueNoise.noise2d(x * frequency, y * frequency) * amplitude;
|
|
22
|
+
maxValue += amplitude;
|
|
23
|
+
amplitude *= persistence;
|
|
24
|
+
frequency *= lacunarity;
|
|
25
|
+
}
|
|
26
|
+
return total / maxValue;
|
|
27
|
+
}
|
|
28
|
+
noise3d(x, y, z, octaves = 5, persistence = 0.5, lacunarity = 2.0) {
|
|
29
|
+
let total = 0, frequency = 1, amplitude = 1, maxValue = 0;
|
|
30
|
+
for (let i = 0; i < octaves; i++) {
|
|
31
|
+
total += this._smoothValueNoise.noise3d(x * frequency, y * frequency, z * frequency) * amplitude;
|
|
32
|
+
maxValue += amplitude;
|
|
33
|
+
amplitude *= persistence;
|
|
34
|
+
frequency *= lacunarity;
|
|
35
|
+
}
|
|
36
|
+
return total / maxValue;
|
|
37
|
+
}
|
|
38
|
+
noise4d(x, y, z, w, octaves = 5, persistence = 0.5, lacunarity = 2.0) {
|
|
39
|
+
let total = 0, frequency = 1, amplitude = 1, maxValue = 0;
|
|
40
|
+
for (let i = 0; i < octaves; i++) {
|
|
41
|
+
total +=
|
|
42
|
+
this._smoothValueNoise.noise4d(x * frequency, y * frequency, z * frequency, w * frequency) * amplitude;
|
|
43
|
+
maxValue += amplitude;
|
|
44
|
+
amplitude *= persistence;
|
|
45
|
+
frequency *= lacunarity;
|
|
46
|
+
}
|
|
47
|
+
return total / maxValue;
|
|
48
|
+
}
|
|
49
|
+
seed(seed) {
|
|
50
|
+
this._smoothValueNoise.seed(seed);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.FractalNoise = FractalNoise;
|
|
54
|
+
});
|
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", "./FractalNoise.js"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FractalNoise = void 0;
|
|
13
|
+
var FractalNoise_js_1 = require("./FractalNoise.js");
|
|
14
|
+
Object.defineProperty(exports, "FractalNoise", { enumerable: true, get: function () { return FractalNoise_js_1.FractalNoise; } });
|
|
15
|
+
});
|