aframe-physics-system
aframe-physics-system copied to clipboard
`body` doesn't have the same rotation value as entity

Description
I'm having trouble getting the body of an element to have the same rotation value as its entity. Here's a demo: https://codepen.io/billyroh/pen/PemGMB
Steps to Repro
- Create
a-entitythat is astatic-bodyand load an.objfile into it. - Rotate the
a-entity. - The
a-entityis rotated, but thebodyis not.
Additional Context I'm guessing what's happening is that...
- The
a-entityis rendered. - The entity's
bodyis rendered. - The
rotationis applied to thea-entity, but thebodydoesn't update accordingly.
It appears to only affect non-primitive objects. In the demo above, I've tried rotating a-box and its body is rotated accordingly.
I'm not sure if this an issue for aframe-physics-system or Cannon, so let me know if I should post this issue somewhere else!
Don't know if this issue is related, (please tell me to open a new issue if not) but I've been having a similar problem, but this time with primitives.
It manifests itself when an entity contains a child entity, which also has geometry, demonstrated here: https://misterpdjs-static-body-rotation-test.glitch.me/
I've replaced the inner <a-box> entities with <a-entity>, which solves it, until I then add any geometry="primitive: ..." attribute, which goes back to the unwanted behaviour.
It looks like the same issue as above. It only appears in the above example that the body mesh isn't moving at all because the rotation is a multiple of 90 degrees. Reducing the rotation to 45 degrees (for example) in the codepen demo above seems to yield a similar result as mine.
@misterpdj does this patch resolve your issue?
@wmurphyrd I think so!
So full disclosure: This is my first attempt to compile this kind of project (normally more of a back-end guy) so I could have got this very wrong indeed. I've built using Webpack, and the file size for the nested-rotation branch came out at 165k compared to the 3.2.0 minified version which is at 250k.
Having said that though, I've added the resultant .js file to my glitch and created a new page that references it here: https://misterpdjs-static-body-rotation-test.glitch.me/fixed.html. Which seems to do the trick. It also works for the codepen demo above, when substituting in https://misterpdjs-static-body-rotation-test.glitch.me/main.js for the normal package.
I've also tested by dropping this in to another project, and the physics interactions still work, so I'm a little bit confident that this is working.
Hopefully this can be incorporated and compiled by someone considerably more competent than me! Is there anything else I can help with to get the pull request accepted?
Thanks for answering by the way! M
I'm still having this issue when entities are nested as seem here.
it only seems to occur when nested entities are attached. As here if you remove them the colliders are in the expected place.
I'm not sure if its an expected behavior, does the body try to draw on top of the nested objects? Is it not recommended to nest on body entities?
The underlying physics engine has no concept of nesting – every object's position is independent of every other object. A-Frame Physics System tries to account for that and adjust positions of nested physics bodies, but it's definitely imperfect/buggy at doing so. Avoiding nesting is the simplest way to work around those issues.
Right, but the body entities are not nested onto anything. But nesting child entities on it will mess the collider. So the physics engine try to account for the shape of nested entities when drawing the body?
Yes, in either case it is probably a bug.
Got it, I was just checking if I understand the expected behavior right, thank you for the quick responses :))
I have a similar issue, I can't rotate the balls to align with the gun although rotation is applied. example: https://glitch.com/~morning-fuschia-hiss Am I missing some property or something?