Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set quaternion in argsFn of useBox (and other useBody hooks) #389

Closed
mz8i opened this issue Jun 7, 2022 · 7 comments
Closed

Cannot set quaternion in argsFn of useBox (and other useBody hooks) #389

mz8i opened this issue Jun 7, 2022 · 7 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mz8i
Copy link

mz8i commented Jun 7, 2022

When using one of the hooks like useBox or useTrimesh, one can set rotation inside the object returned from argsFn, but a quaternion property is ignored (the body's rotation will always be reset to zero when dependencies of the useX hook change).

A brief check in the code suggests that the problem is in

export const propsToBody = (options) => {
- propsToBody in the worker code only extracts rotation from props, but not quaternion.

The workaround right now is simply to use rotation rather than quaternion, or convert quaternions to Euler angles when saving the rotation externally to later restore it. But as the API allows working only with quaternions, I think it would be appropriate to also allow users to set the body's quaternion in the argsFn of the hooks.

@mz8i mz8i changed the title Cannot set quaternion in useBox (and other useBody hooks) argsFn Cannot set quaternion in argsFn of useBox (and other useBody hooks) Jun 7, 2022
@isaac-mason isaac-mason added enhancement New feature or request good first issue Good for newcomers labels Aug 15, 2022
@isaac-mason
Copy link
Member

Thanks for working on this @Soham1803

The body props type has both a rotation (euler) and a quaternion prop.

We should update props-to-body.js to support the quaternion prop as well as rotation, rather than treating rotation as a quaternion.

@Soham1803
Copy link
Contributor

Won't these lead to conflicts if we have two different props handling the same property of the body?

@isaac-mason
Copy link
Member

We'd just need to prefer one if both are provided, we can document the behaviour.

@Soham1803
Copy link
Contributor

Ok I got it. I hope this #437 solves it. I requested a pull for a new branch. I noticed I had unnecessary changes in my yarn.lock file pushed in the previous branch.

@isaac-mason
Copy link
Member

Thanks @Soham1803 🙂 will get this released shortly

@Soham1803
Copy link
Contributor

Well, thanks to you too @isaac-mason for your guidance. 😇

@isaac-mason
Copy link
Member

The fix has been released, closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants