@tsparticles/noise-field 4.0.0-beta.0 → 4.0.0-beta.1
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/browser/NoiseFieldGenerator.js +6 -6
- package/cjs/NoiseFieldGenerator.js +6 -6
- package/esm/NoiseFieldGenerator.js +6 -6
- package/package.json +3 -3
- package/report.html +84 -29
- package/tsparticles.noise.field.js +2 -2
- package/tsparticles.noise.field.min.js +1 -1
- package/umd/NoiseFieldGenerator.js +5 -5
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-beta.
|
|
7
|
+
* v4.0.0-beta.1
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -44,7 +44,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
44
44
|
\*********************************************/
|
|
45
45
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
46
46
|
|
|
47
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseFieldGenerator: () => (/* binding */ NoiseFieldGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {\n a: 1,\n b: 0,\n c: 0,\n d: 1,\n e: 0,\n f: 0\n}, defaultOptions = {\n draw: false,\n size: 20,\n increment: 0.004,\n columns: 0,\n rows: 0,\n layers: 0,\n width: 0,\n height: 0,\n factor: {\n angle: 0.02,\n length: 0.01\n },\n offset: {\n x: 40000,\n y: 40000,\n z: 40000\n }\n};\nclass NoiseFieldGenerator {\n container;\n field;\n noiseGen;\n noiseW;\n options;\n _res;\n constructor(container, noiseGen){\n this.container = container;\n this.noiseGen = noiseGen;\n this.field = [];\n this.noiseW = 0;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(), { size } = this.options, point = {\n x: Math.max(Math.floor(pos.x
|
|
47
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseFieldGenerator: () => (/* binding */ NoiseFieldGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {\n a: 1,\n b: 0,\n c: 0,\n d: 1,\n e: 0,\n f: 0\n}, defaultOptions = {\n draw: false,\n size: 20,\n increment: 0.004,\n columns: 0,\n rows: 0,\n layers: 0,\n width: 0,\n height: 0,\n factor: {\n angle: 0.02,\n length: 0.01\n },\n offset: {\n x: 40000,\n y: 40000,\n z: 40000\n }\n};\nclass NoiseFieldGenerator {\n container;\n field;\n noiseGen;\n noiseW;\n options;\n _res;\n constructor(container, noiseGen){\n this.container = container;\n this.noiseGen = noiseGen;\n this.field = [];\n this.noiseW = 0;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(), { size } = this.options, sizeFactor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.identity / size, point = {\n x: Math.max(Math.floor(pos.x * sizeFactor), originCoordinate),\n y: Math.max(Math.floor(pos.y * sizeFactor), originCoordinate),\n z: Math.max(Math.floor(pos.z * sizeFactor), originCoordinate)\n }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];\n if (fieldPoint) {\n this._res.x = fieldPoint.x;\n this._res.y = fieldPoint.y;\n } else {\n this._res.x = 0;\n this._res.y = 0;\n }\n return this._res;\n }\n init() {\n this._setup();\n }\n reset() {}\n update() {\n this._calculateField();\n this.noiseW += this.options.increment;\n if (!this.options.draw) {\n return;\n }\n this.container.canvas.render.draw((ctx)=>{\n this._drawField(ctx);\n });\n }\n _calculateField() {\n const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;\n for(let x = 0; x < options.columns; x++){\n const xColumn = field[x];\n if (!xColumn) {\n continue;\n }\n for(let y = 0; y < options.rows; y++){\n const yColumn = xColumn[y];\n if (!yColumn) {\n continue;\n }\n for(let z = 0; z < options.layers; z++){\n const cell = yColumn[z];\n if (!cell) {\n continue;\n }\n cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);\n cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI;\n }\n }\n }\n }\n _drawField(ctx) {\n const { field, options } = this;\n for(let x = 0; x < options.columns; x++){\n const xColumn = field[x];\n if (!xColumn) {\n continue;\n }\n for(let y = 0; y < options.rows; y++){\n const yColumn = xColumn[y];\n if (!yColumn) {\n continue;\n }\n const cell = yColumn[firstIndex];\n if (!cell) {\n continue;\n }\n const { angle, length } = cell;\n ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);\n ctx.rotate(angle);\n ctx.strokeStyle = \"white\";\n ctx.beginPath();\n ctx.moveTo(originCoordinate, originCoordinate);\n ctx.lineTo(originCoordinate, this.options.size * length);\n ctx.stroke();\n ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);\n }\n }\n }\n _initField() {\n const { columns, rows, layers } = this.options;\n this.field = new Array(columns);\n for(let x = 0; x < columns; x++){\n const newX = new Array(rows);\n for(let y = 0; y < rows; y++){\n const newY = new Array(layers);\n for(let z = 0; z < layers; z++){\n newY[z] = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n newX[y] = newY;\n }\n this.field[x] = newX;\n }\n }\n _resetField() {\n const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;\n options.width = container.canvas.size.width;\n options.height = container.canvas.size.height;\n options.size = sourceOptions[\"size\"] > empty ? sourceOptions[\"size\"] : defaultOptions.size;\n options.increment = sourceOptions[\"increment\"] > empty ? sourceOptions[\"increment\"] : defaultOptions.increment;\n options.draw = !!sourceOptions[\"draw\"];\n const offset = sourceOptions[\"offset\"];\n options.offset.x = offset?.x ?? defaultOptions.offset.x;\n options.offset.y = offset?.y ?? defaultOptions.offset.y;\n options.offset.z = offset?.z ?? defaultOptions.offset.z;\n const factor = sourceOptions[\"factor\"];\n options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;\n options.factor.length = factor?.length ?? defaultOptions.factor.length;\n options.seed = sourceOptions[\"seed\"];\n this.noiseGen.seed(options.seed ?? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)());\n options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;\n options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;\n options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;\n this._initField();\n }\n _setup() {\n this.noiseW = 0;\n this._resetField();\n addEventListener(\"resize\", ()=>{\n this._resetField();\n });\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/noise-field/./dist/browser/NoiseFieldGenerator.js?\n}");
|
|
48
48
|
|
|
49
49
|
/***/ },
|
|
50
50
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(this,e=>(()=>{"use strict";var t={303(t){t.exports=e}},i={};function o(e){var s=i[e];if(void 0!==s)return s.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};o.r(s),o.d(s,{NoiseFieldGenerator:()=>l});var r=o(303);let n={draw:!1,size:20,increment:.004,columns:0,rows:0,layers:0,width:0,height:0,factor:{angle:.02,length:.01},offset:{x:4e4,y:4e4,z:4e4}};class l{container;field;noiseGen;noiseW;options;_res;constructor(e,t){this.container=e,this.noiseGen=t,this.field=[],this.noiseW=0,this._res=r.Vector.origin,this.options=(0,r.deepExtend)({},n)}generate(e){let t=e.getPosition(),{size:i}=this.options,o={x:Math.max(Math.floor(t.x
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(this,e=>(()=>{"use strict";var t={303(t){t.exports=e}},i={};function o(e){var s=i[e];if(void 0!==s)return s.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};o.r(s),o.d(s,{NoiseFieldGenerator:()=>l});var r=o(303);let n={draw:!1,size:20,increment:.004,columns:0,rows:0,layers:0,width:0,height:0,factor:{angle:.02,length:.01},offset:{x:4e4,y:4e4,z:4e4}};class l{container;field;noiseGen;noiseW;options;_res;constructor(e,t){this.container=e,this.noiseGen=t,this.field=[],this.noiseW=0,this._res=r.Vector.origin,this.options=(0,r.deepExtend)({},n)}generate(e){let t=e.getPosition(),{size:i}=this.options,o=r.identity/i,s={x:Math.max(Math.floor(t.x*o),0),y:Math.max(Math.floor(t.y*o),0),z:Math.max(Math.floor(t.z*o),0)},{field:n}=this,l=n[s.x]?.[s.y]?.[s.z];return l?(this._res.x=l.x,this._res.y=l.y):(this._res.x=0,this._res.y=0),this._res}init(){this._setup()}reset(){}update(){this._calculateField(),this.noiseW+=this.options.increment,this.options.draw&&this.container.canvas.render.draw(e=>{this._drawField(e)})}_calculateField(){let{field:e,noiseGen:t,options:i,noiseW:o}=this,s=i.factor.length,n=i.factor.angle;for(let l=0;l<i.columns;l++){let a=e[l];if(a)for(let e=0;e<i.rows;e++){let f=a[e];if(f)for(let a=0;a<i.layers;a++){let h=f[a];h&&(h.length=t.noise4d(l*s+i.offset.x,e*s+i.offset.y,a*s+i.offset.z,o),h.angle=t.noise4d(l*n,e*n,a*n,o)*r.doublePI)}}}}_drawField(e){let{field:t,options:i}=this;for(let o=0;o<i.columns;o++){let s=t[o];if(s)for(let t=0;t<i.rows;t++){let i=s[t];if(!i)continue;let r=i[0];if(!r)continue;let{angle:n,length:l}=r;e.setTransform(1,0,0,1,o*this.options.size,t*this.options.size),e.rotate(n),e.strokeStyle="white",e.beginPath(),e.moveTo(0,0),e.lineTo(0,this.options.size*l),e.stroke(),e.setTransform(1,0,0,1,0,0)}}}_initField(){let{columns:e,rows:t,layers:i}=this.options;this.field=Array(e);for(let o=0;o<e;o++){let e=Array(t);for(let o=0;o<t;o++){let t=Array(i);for(let e=0;e<i;e++)t[e]=r.Vector.origin;e[o]=t}this.field[o]=e}}_resetField(){let e=this.container,t=e.actualOptions.particles.move.path.options,{options:i}=this;i.width=e.canvas.size.width,i.height=e.canvas.size.height,i.size=t.size>0?t.size:n.size,i.increment=t.increment>0?t.increment:n.increment,i.draw=!!t.draw;let o=t.offset;i.offset.x=o?.x??n.offset.x,i.offset.y=o?.y??n.offset.y,i.offset.z=o?.z??n.offset.z;let s=t.factor;i.factor.angle=s?.angle??n.factor.angle,i.factor.length=s?.length??n.factor.length,i.seed=t.seed,this.noiseGen.seed(i.seed??(0,r.getRandom)()),i.columns=Math.floor(i.width/i.size)+1,i.rows=Math.floor(i.height/i.size)+1,i.layers=Math.floor(e.zLayers/i.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",()=>{this._resetField()})}}return s})());
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
54
54
|
}
|
|
55
55
|
generate(particle) {
|
|
56
|
-
const pos = particle.getPosition(), { size } = this.options, point = {
|
|
57
|
-
x: Math.max(Math.floor(pos.x
|
|
58
|
-
y: Math.max(Math.floor(pos.y
|
|
59
|
-
z: Math.max(Math.floor(pos.z
|
|
56
|
+
const pos = particle.getPosition(), { size } = this.options, sizeFactor = engine_1.identity / size, point = {
|
|
57
|
+
x: Math.max(Math.floor(pos.x * sizeFactor), originCoordinate),
|
|
58
|
+
y: Math.max(Math.floor(pos.y * sizeFactor), originCoordinate),
|
|
59
|
+
z: Math.max(Math.floor(pos.z * sizeFactor), originCoordinate),
|
|
60
60
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
61
61
|
if (fieldPoint) {
|
|
62
62
|
this._res.x = fieldPoint.x;
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
if (!this.options.draw) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
this.container.canvas.draw(ctx => {
|
|
82
|
+
this.container.canvas.render.draw(ctx => {
|
|
83
83
|
this._drawField(ctx);
|
|
84
84
|
});
|
|
85
85
|
}
|