I just submitted a package that includes a spaceship script (full source code) for simulating 2D planetary gravity physics + and example scene to show how it works (see webplayer at the bottom).
Touch the screen with your mouse (or your finger on iOS/Android) to navigate the spaceship through the gravity fields of the surrounding planets.
Play the included example scene as Unity3d Webplayer:CLICK HERE
Hey jammy!
Thanks for your interest.
Yes it’s in C# but it’s not a huge script, since I optimized all the maths a lot - it should be easy to port to javascript.