Skip to content

Commit

Permalink
feat: improved move path generators
Browse files Browse the repository at this point in the history
feat: added 3 external path generators (curves, perlin and simplex noise)
build: updated demo with noise path news
  • Loading branch information
matteobruni committed Aug 12, 2021
1 parent f2d444e commit 9b67377
Show file tree
Hide file tree
Showing 151 changed files with 8,744 additions and 840 deletions.
2 changes: 1 addition & 1 deletion components/angular/projects/ng-particles/package.json
Expand Up @@ -45,7 +45,7 @@
"animated",
"background"
],
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"files": [
"**/*"
Expand Down
12 changes: 0 additions & 12 deletions components/angular/yarn.lock
Expand Up @@ -5754,11 +5754,6 @@ path-type@^4.0.0:
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==

pathseg@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/pathseg/-/pathseg-1.2.1.tgz#50b3fc4fc05c64f4a52f8c04156f6f3975b0df3c"
integrity sha512-LtvemzPvcGamWBbNWJaIrgfUzpynXfwYrP6SSFVRhNHVcCaq6SVm4kRGJNuIV8qzBKgCN3fEXFZZ16YETFIXoA==

performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
Expand Down Expand Up @@ -7689,13 +7684,6 @@ tslint@~6.1.3:
tslib "^1.13.0"
tsutils "^2.29.0"

tsparticles@^1.33.3:
version "1.33.3"
resolved "https://registry.yarnpkg.com/tsparticles/-/tsparticles-1.33.3.tgz#98428156d6cc5ed10af806f595a4335a4086c77d"
integrity sha512-3pK9dNa0TCZC29sWXg4rU/sx6jXKPfDPmWfwGphfBPx9HDrKmP8ZJ1QTesZ7WBm3g6vCxBNOsb8yaCAofDwzIg==
optionalDependencies:
pathseg "^1.2.0"

tsutils@^2.29.0:
version "2.29.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
Expand Down
2 changes: 1 addition & 1 deletion components/inferno/package.json
Expand Up @@ -63,7 +63,7 @@
"animated",
"background"
],
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"homepage": "https://particles.js.org/",
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion components/preact/package.json
Expand Up @@ -66,7 +66,7 @@
"bugs": {
"url": "https://github.com/matteobruni/tsparticles/issues"
},
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"homepage": "https://particles.js.org/",
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion components/react/package.json
Expand Up @@ -74,7 +74,7 @@
"bugs": {
"url": "https://github.com/matteobruni/tsparticles/issues"
},
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"peerDependencies": {
"react": ">=16"
Expand Down
2 changes: 1 addition & 1 deletion components/riot/package.json
Expand Up @@ -51,7 +51,7 @@
"animated",
"background"
],
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"peerDependencies": {
"riot": ">=5"
Expand Down
2 changes: 1 addition & 1 deletion components/solid/package.json
Expand Up @@ -64,7 +64,7 @@
"animated",
"background"
],
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"homepage": "https://particles.js.org/",
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion components/svelte/package.json
Expand Up @@ -48,7 +48,7 @@
"animated",
"background"
],
"author": "Matteo Bruni <matteo.bruni@me.com> (https://www.matteobruni.it)",
"author": "Matteo Bruni <matteo.bruni@me.com>",
"license": "MIT",
"files": [
"dist/**/*",
Expand Down
3 changes: 3 additions & 0 deletions demo/vanilla/app.js
Expand Up @@ -29,6 +29,9 @@ app.use("/tsparticles", express.static("./node_modules/tsparticles"));
app.use("/interaction-light", express.static("./node_modules/tsparticles-interaction-light"));
app.use("/interaction-particles-repulse", express.static("./node_modules/tsparticles-interaction-particles-repulse"));
app.use("/updater-orbit", express.static("./node_modules/tsparticles-updater-orbit"));
app.use("/path-curves", express.static("./node_modules/tsparticles-path-curves"));
app.use("/path-perlin-noise", express.static("./node_modules/tsparticles-path-perlin-noise"));
app.use("/path-simplex-noise", express.static("./node_modules/tsparticles-path-simplex-noise"));
app.use("/plugin-infection", express.static("./node_modules/tsparticles-plugin-infection"));
app.use("/preset-big-circles", express.static("./node_modules/tsparticles-preset-big-circles"));
app.use("/preset-bubbles", express.static("./node_modules/tsparticles-preset-bubbles"));
Expand Down
3 changes: 3 additions & 0 deletions demo/vanilla/package.json
Expand Up @@ -45,6 +45,9 @@
"tsparticles": "^1.33.3",
"tsparticles-interaction-light": "^1.33.3",
"tsparticles-interaction-particles-repulse": "^1.33.3",
"tsparticles-path-curves": "^1.33.3",
"tsparticles-path-perlin-noise": "^1.33.3",
"tsparticles-path-simplex-noise": "^1.33.3",
"tsparticles-plugin-infection": "^1.33.3",
"tsparticles-preset-big-circles": "^1.18.3",
"tsparticles-preset-bubbles": "^1.18.3",
Expand Down
91 changes: 3 additions & 88 deletions demo/vanilla/public/javascripts/demo.js
@@ -1,48 +1,4 @@
(function () {
let noiseZ;
let size;
let columns;
let rows;
let w;
let h;
let field;

function setup(container) {
size = 20;
noiseZ = 0;
reset(container);
}

function initField() {
field = new Array(columns);
for (let x = 0; x < columns; x++) {
field[x] = new Array(columns);
for (let y = 0; y < rows; y++) {
field[x][y] = [0, 0];
}
}
}

function calculateField() {
for (let x = 0; x < columns; x++) {
for (let y = 0; y < rows; y++) {
let angle = noise.perlin3(x / 50, y / 50, noiseZ) * Math.PI * 2;
let length = noise.perlin3(x / 100 + 40000, y / 100 + 40000, noiseZ);
field[x][y][0] = angle;
field[x][y][1] = length;
}
}
}

function reset(container) {
w = container.canvas.size.width;
h = container.canvas.size.height;
noise.seed(Math.random());
columns = Math.floor(w / size) + 1;
rows = Math.floor(h / size) + 1;
initField();
}

let schema = {};
const stats = new Stats();

Expand Down Expand Up @@ -111,50 +67,6 @@
localStorage.presetId = presetId;
editor.set(particles.options);
editor.expandAll();

if (particles.options.particles.move.path.enable) {
particles.setPath({
init: function () {
setup(particles);
},
update: function () {
calculateField();

const mousePos = particles.interactivity.mouse.position;

let sumZ;

if (mousePos) {
sumZ =
(mousePos.x * mousePos.y) /
(25 * particles.canvas.size.width * particles.canvas.size.height);
} else {
sumZ = 0.004;
}

noiseZ += sumZ;
},
generate: function (p) {
const pos = p.getPosition();

const px = Math.max(Math.floor(pos.x / size), 0);
const py = Math.max(Math.floor(pos.y / size), 0);

const v = Vector.create(0, 0);

if (!field || !field[px] || !field[px][py]) {
return v;
}

v.length = field[px][py][1];
v.angle = field[px][py][0];

return v;
}
});

particles.refresh();
}
});
};

Expand Down Expand Up @@ -351,5 +263,8 @@ canvas {
loadLightInteraction(tsParticles);
loadParticlesRepulseInteraction(tsParticles);
loadOrbitUpdater(tsParticles);
loadCurvesPath(tsParticles);
loadPerlinNoisePath(tsParticles);
loadSimplexNoisePath(tsParticles);
});
})();

0 comments on commit 9b67377

Please sign in to comment.