Skip to content

Commit

Permalink
chore: rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacek Pietal committed Aug 18, 2022
1 parent e9b4c9c commit 4e74b0d
Show file tree
Hide file tree
Showing 37 changed files with 298 additions and 274 deletions.
36 changes: 21 additions & 15 deletions dist/demo/demo.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,22 @@ class System extends base_system_1.BaseSystem {
if (candidate.type === model_1.Types.Circle) {
return (0, sat_1.testCircleCircle)(body, candidate, this.response);
}
return (0, utils_1.ensureConvexPolygons)(candidate).some((convexCandidate) => (0, sat_1.testCirclePolygon)(body, convexCandidate, this.response));
return (0, utils_1.ensureConvexPolygons)(candidate).some((convexCandidate) => {
const collided = (0, sat_1.testCirclePolygon)(body, convexCandidate, this.response);
if (collided) {
this.response.b = candidate;
}
return collided;
});
}
if (candidate.type === model_1.Types.Circle) {
return (0, utils_1.ensureConvexPolygons)(body).some((convexBody) => (0, sat_1.testPolygonCircle)(convexBody, candidate, this.response));
return (0, utils_1.ensureConvexPolygons)(body).some((convexBody) => {
const collided = (0, sat_1.testPolygonCircle)(convexBody, candidate, this.response);
if (collided) {
this.response.a = body;
}
return collided;
});
}
if (body.type === model_1.Types.Polygon || candidate.type === model_1.Types.Polygon) {
const convexBodies = (0, utils_1.ensureConvexPolygons)(body);
Expand Down Expand Up @@ -2989,10 +3001,8 @@ class Stress {

update(timeScale) {
this.bodies.forEach((body) => {
if (body.type !== "Circle") {
body.rotationAngle += body.rotationSpeed * timeScale;
body.setAngle(body.rotationAngle);
}
body.rotationAngle += body.rotationSpeed * timeScale;
body.setAngle(body.rotationAngle);

// adaptive padding, when no collisions goes up to "padding" variable value
body.padding = (body.padding + padding) / 2;
Expand All @@ -3012,9 +3022,7 @@ class Stress {
this.bounce(a, b);
this.bounce(b, a);

if (a.type !== "Circle") {
a.rotationSpeed = (Math.random() - Math.random()) * 0.1;
}
a.rotationSpeed = (Math.random() - Math.random()) * 0.1;
});
}

Expand Down Expand Up @@ -3105,12 +3113,10 @@ class Stress {
break;
}

if (body.type !== "Circle") {
// set initial rotation angle direction
body.rotationSpeed = (Math.random() - Math.random()) * 0.1;
body.rotationAngle = (random(0, 360) * Math.PI) / 180;
body.setAngle(body.rotationAngle);
}
// set initial rotation angle direction
body.rotationSpeed = (Math.random() - Math.random()) * 0.1;
body.rotationAngle = (random(0, 360) * Math.PI) / 180;
body.setAngle(body.rotationAngle);

body.directionX = Math.cos(direction);
body.directionY = Math.sin(direction);
Expand Down
2 changes: 1 addition & 1 deletion dist/system.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions dist/system.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/system.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4e74b0d

Please sign in to comment.