pmndrs / use-cannon

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

Add types for all worker messages #250

Closed bjornstar closed 3 years ago

bjornstar commented 3 years ago

With this we will have types for all messages being sent to the worker.

Maybe someone who's better at TypeScript can figure out a way to write a replacement post function, but I couldn't figure it out.

Once again, I want to suggest merging #242 because the ground truth of the system is that ref.current is often null and we avoid posting messages to the worker when that happens. We should not just close our eyes and pretend like it always has a value.

stockhuman commented 3 years ago

Alright, you have my vote for #242. :)

bjornstar commented 3 years ago

I'm happy with this PR now. All messages to the worker are typed and the API is consistently typed too. I will focus on converting the rest of the examples after this.

stockhuman commented 3 years ago

Hey, I noticed all instanceMesh are broken, bodies within them don't render. :/

bjornstar commented 3 years ago

Hey, I noticed all instanceMesh are broken, bodies within them don't render. :/

Hmmm, I tested all the examples just now, KinematicCube & CubeHeap both rendered. Is there a specific one that's not rendering?

stockhuman commented 3 years ago

Nope, every example that implements instanceMesh does not render its instances. Rather strange. These are screenshots of Firefox, but the same is observable in other browsers.

Screen Shot 2021-08-22 at 11 49 08 AM Screen Shot 2021-08-22 at 11 49 37 AM Screen Shot 2021-08-22 at 11 50 04 AM

bjornstar commented 3 years ago

It's a weird one, doesn't occur when installing dependencies with npm. I have raised #260 it seems to fix the problem.

bjornstar commented 3 years ago

It should be fixed now, can you give it a try?

stockhuman commented 3 years ago

Fixed, thanks!