Skip to content

Commit bccad67

Browse files
committed
fix point argument of Body.scale
1 parent 5862949 commit bccad67

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • v3/src/physics/matter-js/lib/body

v3/src/physics/matter-js/lib/body/Body.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,17 @@ var Axes = require('../geometry/Axes');
538538
* @param {vector} [point]
539539
*/
540540
Body.scale = function(body, scaleX, scaleY, point) {
541+
point = point || body.position;
542+
541543
for (var i = 0; i < body.parts.length; i++) {
542544
var part = body.parts[i];
543545

546+
// scale position
547+
part.position.x = point.x + (part.position.x - point.x) * scaleX;
548+
part.position.y = point.y + (part.position.y - point.y) * scaleY;
549+
544550
// scale vertices
545-
Vertices.scale(part.vertices, scaleX, scaleY, body.position);
551+
Vertices.scale(part.vertices, scaleX, scaleY, point);
546552

547553
// update properties
548554
part.axes = Axes.fromVertices(part.vertices);

0 commit comments

Comments
 (0)