Skip to content

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

@isaac-mason

Description

@isaac-mason

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions