0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-14 16:28:42 -05:00

Merge pull request #1 from tylerfurtwangler/setPartsPositionFix

fix: apply same delta from position to previous position when setParts runs
This commit is contained in:
tylerfurtwangler 2021-12-28 10:58:43 -08:00 committed by GitHub
commit 2a7fd84dea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -418,13 +418,14 @@ var Axes = require('../geometry/Axes');
// sum the properties of all compound parts of the parent body
var total = Body._totalProperties(body);
var positionDelta = Vector.sub(body.positionPrev, body.position);
body.area = total.area;
body.parent = body;
body.position.x = total.centre.x;
body.position.y = total.centre.y;
body.positionPrev.x = total.centre.x;
body.positionPrev.y = total.centre.y;
body.positionPrev.x = total.centre.x + positionDelta.x;
body.positionPrev.y = total.centre.y + positionDelta.y;
Body.setMass(body, total.mass);
Body.setInertia(body, total.inertia);