tsparticles 1.37.4 → 1.37.5

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/Utils/Utils.js CHANGED
@@ -200,14 +200,11 @@ function circleBounceDataFromParticle(p) {
200
200
  }
201
201
  exports.circleBounceDataFromParticle = circleBounceDataFromParticle;
202
202
  function circleBounce(p1, p2) {
203
- const xVelocityDiff = p1.velocity.x;
204
- const yVelocityDiff = p1.velocity.y;
205
- const pos1 = p1.position;
206
- const pos2 = p2.position;
207
- const xDist = pos2.x - pos1.x;
208
- const yDist = pos2.y - pos1.y;
203
+ const { x: xVelocityDiff, y: yVelocityDiff } = p1.velocity.sub(p2.velocity);
204
+ const [pos1, pos2] = [p1.position, p2.position];
205
+ const { dx: xDist, dy: yDist } = (0, NumberUtils_1.getDistances)(pos2, pos1);
209
206
  if (xVelocityDiff * xDist + yVelocityDiff * yDist >= 0) {
210
- const angle = -Math.atan2(pos2.y - pos1.y, pos2.x - pos1.x);
207
+ const angle = -Math.atan2(yDist, xDist);
211
208
  const m1 = p1.mass;
212
209
  const m2 = p2.mass;
213
210
  const u1 = p1.velocity.rotate(angle);
@@ -1,5 +1,5 @@
1
1
  import { OutModeDirection } from "../Enums";
2
- import { collisionVelocity, getValue } from "./NumberUtils";
2
+ import { collisionVelocity, getValue, getDistances } from "./NumberUtils";
3
3
  import { Vector } from "../Core/Particle/Vector";
4
4
  function rectSideBounce(pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor) {
5
5
  const res = { bounced: false };
@@ -188,16 +188,13 @@ export function circleBounceDataFromParticle(p) {
188
188
  };
189
189
  }
190
190
  export function circleBounce(p1, p2) {
191
- const xVelocityDiff = p1.velocity.x;
192
- const yVelocityDiff = p1.velocity.y;
193
- const pos1 = p1.position;
194
- const pos2 = p2.position;
195
- const xDist = pos2.x - pos1.x;
196
- const yDist = pos2.y - pos1.y;
191
+ const { x: xVelocityDiff, y: yVelocityDiff } = p1.velocity.sub(p2.velocity);
192
+ const [pos1, pos2] = [p1.position, p2.position];
193
+ const { dx: xDist, dy: yDist } = getDistances(pos2, pos1);
197
194
  // Prevent accidental overlap of particles
198
195
  if (xVelocityDiff * xDist + yVelocityDiff * yDist >= 0) {
199
196
  // Grab angle between the two colliding particles
200
- const angle = -Math.atan2(pos2.y - pos1.y, pos2.x - pos1.x);
197
+ const angle = -Math.atan2(yDist, xDist);
201
198
  // Store mass in var for better readability in collision equation
202
199
  const m1 = p1.mass;
203
200
  const m2 = p2.mass;
@@ -1,5 +1,5 @@
1
1
  import { OutModeDirection } from "../Enums";
2
- import { collisionVelocity, getValue } from "./NumberUtils";
2
+ import { collisionVelocity, getValue, getDistances } from "./NumberUtils";
3
3
  import { Vector } from "../Core/Particle/Vector";
4
4
  function rectSideBounce(pSide, pOtherSide, rectSide, rectOtherSide, velocity, factor) {
5
5
  const res = { bounced: false };
@@ -181,14 +181,11 @@ export function circleBounceDataFromParticle(p) {
181
181
  };
182
182
  }
183
183
  export function circleBounce(p1, p2) {
184
- const xVelocityDiff = p1.velocity.x;
185
- const yVelocityDiff = p1.velocity.y;
186
- const pos1 = p1.position;
187
- const pos2 = p2.position;
188
- const xDist = pos2.x - pos1.x;
189
- const yDist = pos2.y - pos1.y;
184
+ const { x: xVelocityDiff, y: yVelocityDiff } = p1.velocity.sub(p2.velocity);
185
+ const [pos1, pos2] = [p1.position, p2.position];
186
+ const { dx: xDist, dy: yDist } = getDistances(pos2, pos1);
190
187
  if (xVelocityDiff * xDist + yVelocityDiff * yDist >= 0) {
191
- const angle = -Math.atan2(pos2.y - pos1.y, pos2.x - pos1.x);
188
+ const angle = -Math.atan2(yDist, xDist);
192
189
  const m1 = p1.mass;
193
190
  const m2 = p2.mass;
194
191
  const u1 = p1.velocity.rotate(angle);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsparticles",
3
- "version": "1.37.4",
3
+ "version": "1.37.5",
4
4
  "description": "Easily create highly customizable particle animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.",
5
5
  "homepage": "https://particles.js.org/",
6
6
  "scripts": {