Show HN: I built a space travel calculator using Vanilla JavaScript
54 points| captainnemo729 | 1 month ago |cosmic-odometer.vercel.app
The first version only used Earth's orbital speed (~30km/s), but the number moved too slowly. To get the "existential dread" feeling, I switched to using the Milky Way's velocity relative to the CMB (~600km/s). The math takes some liberties (using scalar sum instead of vector) to make the speed feel "fast," but it gets the point across.
Under the hood, it's a single HTML file with zero dependencies. No React, no build step. The main challenge was the canvas starfield—I had to pre-allocate the star objects to stop the garbage collector from causing stutters on mobile.
Let me know if the physics makes you angry or if the stars run smooth on your device.
Tiberium|1 month ago
I'm not against vibecoded stuff, but the author said it's a "deliberate design choice" in one of the comments, clearly not being open about the use of LLMs.
> https://web.archive.org/web/20260124143216/https://cosmic-od...
/* FIXED: Changed cursor from 'help' to 'default' to avoid confusion */
/* --- UPDATED MOON LOGIC --- */
croisillon|1 month ago
potluri|1 month ago
captainnemo729|1 month ago
you're totally right about the resize jank though. the math definitely breaks when the window dimensions change. on the todo list.
reconnecting|1 month ago
Life looks much easier when realising that we're all flying at least ~30 km/s through dark space every second of our lives.
Thank you so much! I was just thinking about how to create something similar a month ago for my birthday, but didn't succeed like you did.
captainnemo729|1 month ago
And definitely give yours another shot. Since this is just vanilla JS, feel free to view source on mine to see how I handled the frame loop if you get stuck.
widforss|1 month ago
It's interesting to see how little effect the orbit and rotation had on the straight line. A proposal is to align the numbers for the different movement categories so that it's easier to see the magnitudes of them.
It took me a couple of seconds to understand the concept, from the title I though it was going to be a planner to show gravity assists etc.
captainnemo729|1 month ago
Good call on the number alignment. I'm using a variable-width font which makes comparing them messy. I'll switch to monospace or tabular-nums in the next push so the magnitudes scan better.
And fair point on the title-'calculator' implies mission planning. Maybe 'travel visualizer' would have been safer!
netsharc|1 month ago
captainnemo729|1 month ago
pushing a label fix now so it's not a guessing game. thanks.
unknown|1 month ago
[deleted]
anileated|1 month ago
captainnemo729|1 month ago
netsharc|1 month ago
croisillon|1 month ago
also there are some cursors with question marks but they don't espatially ;) call the FAQ, do they? firefox on win10
captainnemo729|1 month ago
re: the cursors that's definitely my bad UX. they are just hover tooltips (standard title attributes), but setting the cursor to help (?) makes them look like clickable buttons. i'll swap that out so it's less confusing. thanks for the firefox check.
arendtio|1 month ago
captainnemo729|1 month ago
redmattred|1 month ago
captainnemo729|1 month ago
DmitryO|1 month ago
captainnemo729|1 month ago
dalton_zk|1 month ago
captainnemo729|1 month ago
bvan|1 month ago
captainnemo729|1 month ago
unknown|1 month ago
[deleted]