4 ms·
I've tried a number of times to build a physics engine for my 2D canvas library - the one thing that's defeated me every time has been the collision detection.
by rikroots 3y ago
I've tried a number of times to build a physics engine for my 2D canvas library - the one thing that's defeated me every time has been the collision detection. In the end I gave up on building the whole thing and settled on just doing the particle part of the job; it's enough for my purposes without over-complexifying the library[1]. If people need collision detection for their canvas animation they can include a 3rd party library that does the job properly[2].
But it was definitely worth making the attempt - an excellent learning experience into an area of computing I never want to visit again!
[1] - Some examples:
A particle emitter - https://scrawl-v8.rikweb.org.uk/demo/particles-003.html https://scrawl-v8.rikweb.org.uk/demo/particles-003.html
Emulate a flag with a net of particles - https://scrawl-v8.rikweb.org.uk/demo/particles-008.html https://scrawl-v8.rikweb.org.uk/demo/particles-008.html
Position things using particles - https://scrawl-v8.rikweb.org.uk/demo/particles-012.html https://scrawl-v8.rikweb.org.uk/demo/particles-012.html
[2] - My favourite JS physics library is MatterJS - https://brm.io/matter-js/ https://brm.io/matter-js/ . I want to like Rapier, which is coded in Rust and can be imported into the browser via WASM, but I haven't had the time to properly play with it - https://rapier.rs/docs/user_guides/javascript/getting_started_js/ https://rapier.rs/docs/user_guides/javascript/getting_starte...