You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been trying to get a zoom effect on multiple bodies so that means that I need them all to scale to the same point, rather than to their own midpoints. I looked at the code and i looks like the optional point parameter for Body.scale() isn't being used at all despite what the documentation says.
The reason I'm not just changing the width/height bounds is that I'm not trying to scale/zoom on everything, I'm going for a layered effect. I did a bit of testing and I believe something adding the center variable like this would fix the issue:
Body.scale = function(body, scaleX, scaleY, point) {
let center = (point == null) ? body.position : point
for (var i = 0; i < body.parts.length; i++) {
var part = body.parts[i];
// scale vertices
Vertices.scale(part.vertices, scaleX, scaleY, center);
...
}
Any thoughts about this? Should I submit a PR?
Edit: Moved the declaration out of the loop
The text was updated successfully, but these errors were encountered:
I looked at the code and i looks like the optional point parameter for Body.scale() isn't being used at all despite what the documentation says.
Hey, looks like this is a bug. Thanks for raising.
I've been trying to get a zoom effect on multiple bodies so that means that I need them all to scale to the same point, rather than to their own midpoints.
Did you try using Composite.scale? I think that one actually does work with a point and for multiple bodies too, see the demo.
I started using World but then switched to a Composite since it made more sense, and that has helped some but there is still something not quite working right. I try to scale my PIXI container and my Matter.js Composite by the same factor yet it is looking like the Matter one isn't scaling enough to stay in sync with the Pixi one. I made a rough example to show what I'm talking about: move the bunny with WASD and press Tab once to scale the Composite that the green square is in. After scaling you are able to clip through the square and the square responds to collisions from a body that isn't properly lined up with the sprite that you see.
I've been trying to get a zoom effect on multiple bodies so that means that I need them all to scale to the same point, rather than to their own midpoints. I looked at the code and i looks like the optional
point
parameter for Body.scale() isn't being used at all despite what the documentation says.The reason I'm not just changing the width/height bounds is that I'm not trying to scale/zoom on everything, I'm going for a layered effect. I did a bit of testing and I believe something adding the
center
variable like this would fix the issue:Any thoughts about this? Should I submit a PR?
Edit: Moved the declaration out of the loop
The text was updated successfully, but these errors were encountered: