pmndrs / use-cannon

👋💣 physics based hooks for @react-three/fiber
https://cannon.pmnd.rs
2.76k stars 154 forks source link

[propsToBody] TypeScript conversion #225

Closed bjornstar closed 3 years ago

bjornstar commented 3 years ago

There is a breaking change for useCompoundBody. We were using type as ShapeType. This was confusing because type is BodyType normally. I changed it to shapeType and defined CompoundBodyProps

A breaking type change is the naming of Event / Events, Event is already defined in the DOM lib I renamed them to CannonEvent / CannonEvents to avoid potential confusion.

I moved most of the type definitions into shared.ts and deleted setup.ts. context ended up in hooks.ts

There is a small functional change in propsToBody. I moved all of the addShape calls to after the body properties are assigned. It greatly simplified things.

There's still a little bit of work to do with the typing for the args usage. I'll leave this as a draft until I get that sorted out.

stockhuman commented 3 years ago

Pardon the merge, I'm looking into your mention of this within 224 as a fix for sphere collisions.

bjornstar commented 3 years ago

Pardon the merge, I'm looking into your mention of this within 224 as a fix for sphere collisions.

I welcome the help. I've been stuck on this one for a few days now. Technically it works as is, but I have been experimenting with improving the types on another branch.

bjornstar commented 3 years ago

I'll open a new one once the examples are converted to typescript.