liabru / matter-js

a 2D rigid body physics engine for the web ▲● ■
MIT License
16.53k stars 1.96k forks source link

The angle of an object which is a part of composed object is always 0 #828

Open vyshkov opened 4 years ago

vyshkov commented 4 years ago

Hi,

If i create an object with a

const testObject = Body.create({
        parts: [body],
})

Then a body.angle is always 0, even if testObject actively rotating.

This is causing issues with textures rendering: https://github.com/liabru/matter-js/blob/master/src/render/Render.js#L658 The texture doesn't reflecting angle change.

vyshkov commented 4 years ago

Please check the PR 👆

liabru commented 4 years ago

Thanks for reporting and the PR. Are you trying to set sprites on the parts?

The renderer doesn't actually support sprites for individual parts, only the parent, even though it looks like it. Is this something you need?

vyshkov commented 4 years ago

Are you trying to set sprites on the parts?

Yes, I have multiple textures for a compound body. I don't see problems by passing an angle to all child objects. No new complexity introduced.

At the moment I have an outer callback 'beforeTick' in the main file where I have to loop over my compound body parts and update angle there.