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

Body 'damping' and 'linearDamping' prop name inconsistency breaks providing 'linearDamping' in body hook props #11

Open
Tracked by #13
isaac-mason opened this issue May 14, 2022 · 0 comments

Comments

@isaac-mason
Copy link
Member

isaac-mason commented May 14, 2022

I noticed that the linear damping prop in use-p2 is called linearDamping (same as cannon), but in the p2 lib it is called damping.

Setting linearDamping via the body hook api works, as the setLinearDamping op sets the damping property correctly:

e.g.

const Example = () => {
  const [_, api] = useCircle(...)

  useEffect(() => {
    api.linearDamping.set(someValue) // this works!
  }, [])
  
  // ...
}

But providing linearDamping in the props of a body hook doesn't work. From a quick look, it appears that's because propsToBody doesn't have any handling for the linearDamping -> damping property name mismatch.

e.g.

const Example = () => {
  const [_, api] = useCircle({
    linearDamping: someValue, // this doesn't work!
    damping: someValue, // this works as it's passed through to `propsToBody`, but conflicts with our types!
  })

  // ...
}

I can think of a few options for fixing this:

  1. We could rename the prop from linearDamping -> damping in this lib to be consistent with p2

  2. We could update propsToBody and keep the API in as-is

  3. Once we start using p2-es in this lib, we could rename damping to linearDamping in p2-es for consistency with cannon

@isaac-mason isaac-mason changed the title Body linearDamping and damping prop name mismatch breaks setting linearDamping in hook props Body damping prop name mismatch breaks setting linearDamping in body hook props May 14, 2022
@isaac-mason isaac-mason changed the title Body damping prop name mismatch breaks setting linearDamping in body hook props Body damping and linearDamping prop name inconsistency breaks providing linearDamping in body hook props May 14, 2022
@isaac-mason isaac-mason changed the title Body damping and linearDamping prop name inconsistency breaks providing linearDamping in body hook props Body 'damping' and 'linearDamping' prop name inconsistency breaks providing 'linearDamping' in body hook props May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant