ikaruga Posted August 11, 2021 Share Posted August 11, 2021 Use case: simple particle simulation with collision detection. Think billiards. For what I'm doing i prefer doing it myself. In fact i have done this in the past. So I'm looking for a refresher tutorial. Would also consider using a physics library. The only concern there is bundle size. It's for a web app so i need to keep download size to a minimum. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 11, 2021 Share Posted August 11, 2021 (edited) in case you go for physics lib, you can try architecture like that: https://codesandbox.io/s/app-architecture-3-j0di5 i used p2 for the case, but beware: npm version is wrong, you have to build it from the repo Edited August 11, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
threader Posted August 12, 2021 Share Posted August 12, 2021 If you're not going for super-realistic collisions I have a nice collision handling library out there written in TypeScript called `bump-ts`: https://www.npmjs.com/package/bump-ts. Jammy and ivan.popelyshev 2 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted August 12, 2021 Share Posted August 12, 2021 Pure AABB? Nice! Thank you @threader, i'll look at it . Too many people are asking for this. Quote Link to comment Share on other sites More sharing options...
threader Posted August 12, 2021 Share Posted August 12, 2021 @ivan.popelyshev Yep, it uses AABB checking + QuadTrees under the hood to run fast and keep a light footprint. A lot of people ask for physics libraries but don't really need one: this library covers pretty much all the arcade use-cases for which a realistic physics library is overkill. Quote Link to comment Share on other sites More sharing options...
ikaruga Posted August 12, 2021 Author Share Posted August 12, 2021 (edited) 7 hours ago, threader said: If you're not going for super-realistic collisions I have a nice collision handling library out there written in TypeScript called `bump-ts`: https://www.npmjs.com/package/bump-ts. Nice. As per bundlephobia, its 4kb. The use case is literally something similar to billiards. Objects need to push other objects in a somewhat realistic fashion, following the laws of physics. It doesn't need to be super realistic though. Is your library appropriate? Here's what i mean: balls need to bounce off each other as well as the walls. Friction and gravity should be supported. Suggestion: an examples sectiion would help a ton Edited August 12, 2021 by ikaruga Quote Link to comment Share on other sites More sharing options...
Jammy Posted August 17, 2021 Share Posted August 17, 2021 On 8/12/2021 at 5:38 PM, threader said: If you're not going for super-realistic collisions I have a nice collision handling library out there written in TypeScript called `bump-ts`: https://www.npmjs.com/package/bump-ts. Oh god I have to rewrite my physics system again now haha. This looks great. Quote Link to comment Share on other sites More sharing options...
ikaruga Posted August 25, 2021 Author Share Posted August 25, 2021 FYI. I ended up going with matter.js. It's battle hardened and less than 23kb. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.