@tsparticles/path-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/FractalNoiseGenerator.js +100 -0
- package/browser/IFractalOptions.js +1 -0
- package/browser/IOffsetValues.js +1 -0
- package/browser/index.js +6 -0
- package/browser/package.json +1 -0
- package/cjs/FractalNoiseGenerator.js +104 -0
- package/cjs/IFractalOptions.js +2 -0
- package/cjs/IOffsetValues.js +2 -0
- package/cjs/index.js +10 -0
- package/cjs/package.json +1 -0
- package/esm/FractalNoiseGenerator.js +100 -0
- package/esm/IFractalOptions.js +1 -0
- package/esm/IOffsetValues.js +1 -0
- package/esm/index.js +6 -0
- package/esm/package.json +1 -0
- package/package.json +110 -0
- package/report.html +39 -0
- package/tsparticles.path.fractal.noise.js +148 -0
- package/tsparticles.path.fractal.noise.min.js +2 -0
- package/tsparticles.path.fractal.noise.min.js.LICENSE.txt +1 -0
- package/types/FractalNoiseGenerator.d.ts +18 -0
- package/types/IFractalOptions.d.ts +12 -0
- package/types/IOffsetValues.d.ts +5 -0
- package/types/index.d.ts +3 -0
- package/umd/FractalNoiseGenerator.js +114 -0
- package/umd/IFractalOptions.js +12 -0
- package/umd/IOffsetValues.js +12 -0
- package/umd/index.js +20 -0
|
@@ -0,0 +1,148 @@
|
|
|
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/engine"), require("@tsparticles/fractal-noise"));
|
|
20
|
+
else if(typeof define === 'function' && define.amd)
|
|
21
|
+
define(["@tsparticles/engine", "@tsparticles/fractal-noise"], factory);
|
|
22
|
+
else {
|
|
23
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine"), require("@tsparticles/fractal-noise")) : factory(root["window"], root["window"]);
|
|
24
|
+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
|
+
}
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__, __WEBPACK_EXTERNAL_MODULE__tsparticles_fractal_noise__) => {
|
|
27
|
+
return /******/ (() => { // webpackBootstrap
|
|
28
|
+
/******/ "use strict";
|
|
29
|
+
/******/ var __webpack_modules__ = ({
|
|
30
|
+
|
|
31
|
+
/***/ "./dist/browser/FractalNoiseGenerator.js":
|
|
32
|
+
/*!***********************************************!*\
|
|
33
|
+
!*** ./dist/browser/FractalNoiseGenerator.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 */ FractalNoiseGenerator: () => (/* binding */ FractalNoiseGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _tsparticles_fractal_noise__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/fractal-noise */ \"@tsparticles/fractal-noise\");\n/* harmony import */ var _tsparticles_fractal_noise__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_fractal_noise__WEBPACK_IMPORTED_MODULE_1__);\n\n\nconst defaultOptions = {\n size: 20,\n increment: 0.004,\n columns: 0,\n rows: 0,\n layers: 0,\n width: 0,\n height: 0,\n offset: {\n x: 40000,\n y: 40000,\n z: 40000\n }\n};\nclass FractalNoiseGenerator {\n constructor() {\n this._fractal = new _tsparticles_fractal_noise__WEBPACK_IMPORTED_MODULE_1__.FractalNoise();\n this.field = [];\n this.noiseW = 0;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(),\n point = {\n x: Math.max(Math.floor(pos.x / this.options.size), 0),\n y: Math.max(Math.floor(pos.y / this.options.size), 0),\n z: Math.max(Math.floor(pos.z / this.options.size), 0)\n },\n v = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n if (!this.field?.[point.x]?.[point.y]?.[point.z]) {\n return v;\n }\n v.setTo(this.field[point.x][point.y][point.z]);\n return v;\n }\n init(container) {\n this.container = container;\n this._setup();\n }\n reset() {}\n update() {\n if (!this.container) {\n return;\n }\n this._calculateField();\n this.noiseW += this.options.increment;\n }\n _calculateField() {\n const options = this.options;\n for (let x = 0; x < options.columns; x++) {\n for (let y = 0; y < options.rows; y++) {\n for (let z = 0; z < options.layers; z++) {\n this.field[x][y][z].angle = this._fractal.noise4d(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;\n this.field[x][y][z].length = this._fractal.noise4d(x / 100 + options.offset.x, y / 100 + options.offset.y, z / 100 + options.offset.z, this.noiseW);\n }\n }\n }\n }\n _initField() {\n this.field = new Array(this.options.columns);\n for (let x = 0; x < this.options.columns; x++) {\n this.field[x] = new Array(this.options.rows);\n for (let y = 0; y < this.options.rows; y++) {\n this.field[x][y] = new Array(this.options.layers);\n for (let z = 0; z < this.options.layers; z++) {\n this.field[x][y][z] = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n }\n }\n }\n _resetField() {\n const container = this.container;\n if (!container) {\n return;\n }\n const sourceOptions = container.actualOptions.particles.move.path.options;\n this.options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;\n this.options.increment = sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;\n this.options.width = container.canvas.size.width;\n this.options.height = container.canvas.size.height;\n const offset = sourceOptions.offset;\n this.options.offset.x = offset?.x ?? defaultOptions.offset.x;\n this.options.offset.y = offset?.y ?? defaultOptions.offset.y;\n this.options.offset.z = offset?.z ?? defaultOptions.offset.z;\n this.options.seed = sourceOptions.seed;\n this._fractal.seed(this.options.seed ?? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)());\n this.options.columns = Math.floor(this.options.width / this.options.size) + 1;\n this.options.rows = Math.floor(this.options.height / this.options.size) + 1;\n this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;\n this._initField();\n }\n _setup() {\n this.noiseW = 0;\n this._resetField();\n addEventListener(\"resize\", () => this._resetField());\n }\n}\n\n//# sourceURL=webpack://@tsparticles/path-fractal-noise/./dist/browser/FractalNoiseGenerator.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 */ fractalNoisePathName: () => (/* binding */ fractalNoisePathName),\n/* harmony export */ loadFractalNoisePath: () => (/* binding */ loadFractalNoisePath)\n/* harmony export */ });\n/* harmony import */ var _FractalNoiseGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./FractalNoiseGenerator.js */ \"./dist/browser/FractalNoiseGenerator.js\");\n\nconst fractalNoisePathName = \"fractalNoise\";\nasync function loadFractalNoisePath(engine, refresh = true) {\n engine.checkVersion(\"3.9.0\");\n await engine.addPathGenerator(fractalNoisePathName, new _FractalNoiseGenerator_js__WEBPACK_IMPORTED_MODULE_0__.FractalNoiseGenerator(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/path-fractal-noise/./dist/browser/index.js?\n}");
|
|
48
|
+
|
|
49
|
+
/***/ }),
|
|
50
|
+
|
|
51
|
+
/***/ "@tsparticles/engine":
|
|
52
|
+
/*!*********************************************************************************************************************************!*\
|
|
53
|
+
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
54
|
+
\*********************************************************************************************************************************/
|
|
55
|
+
/***/ ((module) => {
|
|
56
|
+
|
|
57
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
58
|
+
|
|
59
|
+
/***/ }),
|
|
60
|
+
|
|
61
|
+
/***/ "@tsparticles/fractal-noise":
|
|
62
|
+
/*!******************************************************************************************************************************************************!*\
|
|
63
|
+
!*** external {"commonjs":"@tsparticles/fractal-noise","commonjs2":"@tsparticles/fractal-noise","amd":"@tsparticles/fractal-noise","root":"window"} ***!
|
|
64
|
+
\******************************************************************************************************************************************************/
|
|
65
|
+
/***/ ((module) => {
|
|
66
|
+
|
|
67
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_fractal_noise__;
|
|
68
|
+
|
|
69
|
+
/***/ })
|
|
70
|
+
|
|
71
|
+
/******/ });
|
|
72
|
+
/************************************************************************/
|
|
73
|
+
/******/ // The module cache
|
|
74
|
+
/******/ var __webpack_module_cache__ = {};
|
|
75
|
+
/******/
|
|
76
|
+
/******/ // The require function
|
|
77
|
+
/******/ function __webpack_require__(moduleId) {
|
|
78
|
+
/******/ // Check if module is in cache
|
|
79
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
80
|
+
/******/ if (cachedModule !== undefined) {
|
|
81
|
+
/******/ return cachedModule.exports;
|
|
82
|
+
/******/ }
|
|
83
|
+
/******/ // Create a new module (and put it into the cache)
|
|
84
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
85
|
+
/******/ // no module.id needed
|
|
86
|
+
/******/ // no module.loaded needed
|
|
87
|
+
/******/ exports: {}
|
|
88
|
+
/******/ };
|
|
89
|
+
/******/
|
|
90
|
+
/******/ // Execute the module function
|
|
91
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
92
|
+
/******/
|
|
93
|
+
/******/ // Return the exports of the module
|
|
94
|
+
/******/ return module.exports;
|
|
95
|
+
/******/ }
|
|
96
|
+
/******/
|
|
97
|
+
/************************************************************************/
|
|
98
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
99
|
+
/******/ (() => {
|
|
100
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
101
|
+
/******/ __webpack_require__.n = (module) => {
|
|
102
|
+
/******/ var getter = module && module.__esModule ?
|
|
103
|
+
/******/ () => (module['default']) :
|
|
104
|
+
/******/ () => (module);
|
|
105
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
106
|
+
/******/ return getter;
|
|
107
|
+
/******/ };
|
|
108
|
+
/******/ })();
|
|
109
|
+
/******/
|
|
110
|
+
/******/ /* webpack/runtime/define property getters */
|
|
111
|
+
/******/ (() => {
|
|
112
|
+
/******/ // define getter functions for harmony exports
|
|
113
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
114
|
+
/******/ for(var key in definition) {
|
|
115
|
+
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
116
|
+
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
117
|
+
/******/ }
|
|
118
|
+
/******/ }
|
|
119
|
+
/******/ };
|
|
120
|
+
/******/ })();
|
|
121
|
+
/******/
|
|
122
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
123
|
+
/******/ (() => {
|
|
124
|
+
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
125
|
+
/******/ })();
|
|
126
|
+
/******/
|
|
127
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
128
|
+
/******/ (() => {
|
|
129
|
+
/******/ // define __esModule on exports
|
|
130
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
131
|
+
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
132
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
133
|
+
/******/ }
|
|
134
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
135
|
+
/******/ };
|
|
136
|
+
/******/ })();
|
|
137
|
+
/******/
|
|
138
|
+
/************************************************************************/
|
|
139
|
+
/******/
|
|
140
|
+
/******/ // startup
|
|
141
|
+
/******/ // Load entry module and return exports
|
|
142
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
143
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
144
|
+
/******/
|
|
145
|
+
/******/ return __webpack_exports__;
|
|
146
|
+
/******/ })()
|
|
147
|
+
;
|
|
148
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see tsparticles.path.fractal.noise.min.js.LICENSE.txt */
|
|
2
|
+
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("@tsparticles/engine"),require("@tsparticles/fractal-noise"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/fractal-noise"],e);else{var i="object"==typeof exports?e(require("@tsparticles/engine"),require("@tsparticles/fractal-noise")):e(t.window,t.window);for(var s in i)("object"==typeof exports?exports:t)[s]=i[s]}}(this,((t,e)=>(()=>{var i={303:e=>{e.exports=t},689:t=>{t.exports=e}},s={};function o(t){var e=s[t];if(void 0!==e)return e.exports;var n=s[t]={exports:{}};return i[t](n,n.exports,o),n.exports}o.d=(t,e)=>{for(var i in e)o.o(e,i)&&!o.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};o.r(n),o.d(n,{fractalNoisePathName:()=>f,loadFractalNoisePath:()=>c});var r=o(303),a=o(689);const h={size:20,increment:.004,columns:0,rows:0,layers:0,width:0,height:0,offset:{x:4e4,y:4e4,z:4e4}};class l{constructor(){this._fractal=new a.FractalNoise,this.field=[],this.noiseW=0,this.options=(0,r.deepExtend)({},h)}generate(t){const e=t.getPosition(),i=Math.max(Math.floor(e.x/this.options.size),0),s=Math.max(Math.floor(e.y/this.options.size),0),o=Math.max(Math.floor(e.z/this.options.size),0),n=r.Vector.origin;return this.field?.[i]?.[s]?.[o]?(n.setTo(this.field[i][s][o]),n):n}init(t){this.container=t,this._setup()}reset(){}update(){this.container&&(this._calculateField(),this.noiseW+=this.options.increment)}_calculateField(){const t=this.options;for(let e=0;e<t.columns;e++)for(let i=0;i<t.rows;i++)for(let s=0;s<t.layers;s++)this.field[e][i][s].angle=this._fractal.noise4d(e/50,i/50,s/50,this.noiseW)*Math.PI*2,this.field[e][i][s].length=this._fractal.noise4d(e/100+t.offset.x,i/100+t.offset.y,s/100+t.offset.z,this.noiseW)}_initField(){this.field=new Array(this.options.columns);for(let t=0;t<this.options.columns;t++){this.field[t]=new Array(this.options.rows);for(let e=0;e<this.options.rows;e++){this.field[t][e]=new Array(this.options.layers);for(let i=0;i<this.options.layers;i++)this.field[t][e][i]=r.Vector.origin}}}_resetField(){const t=this.container;if(!t)return;const e=t.actualOptions.particles.move.path.options;this.options.size=e.size>0?e.size:h.size,this.options.increment=e.increment>0?e.increment:h.increment,this.options.width=t.canvas.size.width,this.options.height=t.canvas.size.height;const i=e.offset;this.options.offset.x=i?.x??h.offset.x,this.options.offset.y=i?.y??h.offset.y,this.options.offset.z=i?.z??h.offset.z,this.options.seed=e.seed,this._fractal.seed(this.options.seed??(0,r.getRandom)()),this.options.columns=Math.floor(this.options.width/this.options.size)+1,this.options.rows=Math.floor(this.options.height/this.options.size)+1,this.options.layers=Math.floor(t.zLayers/this.options.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",(()=>this._resetField()))}}const f="fractalNoise";async function c(t,e=!0){t.checkVersion("3.9.0"),await t.addPathGenerator(f,new l,e)}return n})()));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! tsParticles Fractal Noise Path v3.9.0 by Matteo Bruni */
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Container, type IMovePathGenerator, type Particle, Vector } from "@tsparticles/engine";
|
|
2
|
+
import type { IFractalOptions } from "./IFractalOptions.js";
|
|
3
|
+
export declare class FractalNoiseGenerator implements IMovePathGenerator {
|
|
4
|
+
container?: Container;
|
|
5
|
+
field: Vector[][][];
|
|
6
|
+
noiseW: number;
|
|
7
|
+
readonly options: IFractalOptions;
|
|
8
|
+
private readonly _fractal;
|
|
9
|
+
constructor();
|
|
10
|
+
generate(particle: Particle): Vector;
|
|
11
|
+
init(container: Container): void;
|
|
12
|
+
reset(): void;
|
|
13
|
+
update(): void;
|
|
14
|
+
private _calculateField;
|
|
15
|
+
private _initField;
|
|
16
|
+
private _resetField;
|
|
17
|
+
private _setup;
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IOffsetValues } from "./IOffsetValues.js";
|
|
2
|
+
export interface IFractalOptions {
|
|
3
|
+
columns: number;
|
|
4
|
+
height: number;
|
|
5
|
+
increment: number;
|
|
6
|
+
layers: number;
|
|
7
|
+
offset: IOffsetValues;
|
|
8
|
+
rows: number;
|
|
9
|
+
seed?: number;
|
|
10
|
+
size: number;
|
|
11
|
+
width: number;
|
|
12
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
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/engine", "@tsparticles/fractal-noise"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.FractalNoiseGenerator = void 0;
|
|
13
|
+
const engine_1 = require("@tsparticles/engine");
|
|
14
|
+
const fractal_noise_1 = require("@tsparticles/fractal-noise");
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
size: 20,
|
|
17
|
+
increment: 0.004,
|
|
18
|
+
columns: 0,
|
|
19
|
+
rows: 0,
|
|
20
|
+
layers: 0,
|
|
21
|
+
width: 0,
|
|
22
|
+
height: 0,
|
|
23
|
+
offset: {
|
|
24
|
+
x: 40000,
|
|
25
|
+
y: 40000,
|
|
26
|
+
z: 40000,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
class FractalNoiseGenerator {
|
|
30
|
+
constructor() {
|
|
31
|
+
this._fractal = new fractal_noise_1.FractalNoise();
|
|
32
|
+
this.field = [];
|
|
33
|
+
this.noiseW = 0;
|
|
34
|
+
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
35
|
+
}
|
|
36
|
+
generate(particle) {
|
|
37
|
+
const pos = particle.getPosition(), point = {
|
|
38
|
+
x: Math.max(Math.floor(pos.x / this.options.size), 0),
|
|
39
|
+
y: Math.max(Math.floor(pos.y / this.options.size), 0),
|
|
40
|
+
z: Math.max(Math.floor(pos.z / this.options.size), 0),
|
|
41
|
+
}, v = engine_1.Vector.origin;
|
|
42
|
+
if (!this.field?.[point.x]?.[point.y]?.[point.z]) {
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
v.setTo(this.field[point.x][point.y][point.z]);
|
|
46
|
+
return v;
|
|
47
|
+
}
|
|
48
|
+
init(container) {
|
|
49
|
+
this.container = container;
|
|
50
|
+
this._setup();
|
|
51
|
+
}
|
|
52
|
+
reset() {
|
|
53
|
+
}
|
|
54
|
+
update() {
|
|
55
|
+
if (!this.container) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this._calculateField();
|
|
59
|
+
this.noiseW += this.options.increment;
|
|
60
|
+
}
|
|
61
|
+
_calculateField() {
|
|
62
|
+
const options = this.options;
|
|
63
|
+
for (let x = 0; x < options.columns; x++) {
|
|
64
|
+
for (let y = 0; y < options.rows; y++) {
|
|
65
|
+
for (let z = 0; z < options.layers; z++) {
|
|
66
|
+
this.field[x][y][z].angle =
|
|
67
|
+
this._fractal.noise4d(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
68
|
+
this.field[x][y][z].length = this._fractal.noise4d(x / 100 + options.offset.x, y / 100 + options.offset.y, z / 100 + options.offset.z, this.noiseW);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
_initField() {
|
|
74
|
+
this.field = new Array(this.options.columns);
|
|
75
|
+
for (let x = 0; x < this.options.columns; x++) {
|
|
76
|
+
this.field[x] = new Array(this.options.rows);
|
|
77
|
+
for (let y = 0; y < this.options.rows; y++) {
|
|
78
|
+
this.field[x][y] = new Array(this.options.layers);
|
|
79
|
+
for (let z = 0; z < this.options.layers; z++) {
|
|
80
|
+
this.field[x][y][z] = engine_1.Vector.origin;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
_resetField() {
|
|
86
|
+
const container = this.container;
|
|
87
|
+
if (!container) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
91
|
+
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
92
|
+
this.options.increment =
|
|
93
|
+
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
94
|
+
this.options.width = container.canvas.size.width;
|
|
95
|
+
this.options.height = container.canvas.size.height;
|
|
96
|
+
const offset = sourceOptions.offset;
|
|
97
|
+
this.options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
98
|
+
this.options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
99
|
+
this.options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
100
|
+
this.options.seed = sourceOptions.seed;
|
|
101
|
+
this._fractal.seed(this.options.seed ?? (0, engine_1.getRandom)());
|
|
102
|
+
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
103
|
+
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
104
|
+
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
105
|
+
this._initField();
|
|
106
|
+
}
|
|
107
|
+
_setup() {
|
|
108
|
+
this.noiseW = 0;
|
|
109
|
+
this._resetField();
|
|
110
|
+
addEventListener("resize", () => this._resetField());
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.FractalNoiseGenerator = FractalNoiseGenerator;
|
|
114
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
});
|
package/umd/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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", "./FractalNoiseGenerator.js"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.fractalNoisePathName = void 0;
|
|
13
|
+
exports.loadFractalNoisePath = loadFractalNoisePath;
|
|
14
|
+
const FractalNoiseGenerator_js_1 = require("./FractalNoiseGenerator.js");
|
|
15
|
+
exports.fractalNoisePathName = "fractalNoise";
|
|
16
|
+
async function loadFractalNoisePath(engine, refresh = true) {
|
|
17
|
+
engine.checkVersion("3.9.0");
|
|
18
|
+
await engine.addPathGenerator(exports.fractalNoisePathName, new FractalNoiseGenerator_js_1.FractalNoiseGenerator(), refresh);
|
|
19
|
+
}
|
|
20
|
+
});
|