Coffee Physics is a promising lightweight 2D physics engine, by Justin Windle. With a name like that, it’s probably small surprise that it’s written in CoffeeScript. Down to the nitty gritty!
Calculations are performed relative to a fixed time interval so that extreme variations in the frame-rate shouldn’t cause the physics to explode. The algorithm (integrator) that’s used to determine the motion of objects can be customised too, keeping things nice and flexible.
3D support is said to be in the pipeline, and there’s apparently still room for optimisation; cool!
Six demos are available, including: attraction, chain, cloth and balloon – all of which tick along at a solid 50+ FPS. For best results use Chrome, work is underway to improve stability/performance in other browsers.
While I’m still not convinced that we should be abstracting away native JavaScript syntax using languages such as CoffeeScript (many of my concerns are well-covered in this post by Ryan Florence), there’s a lot to like in this project.
Check out the fun demo suite, or grab the source from GitHub.