logoalt Hacker News

Show HN: I built a space travel calculator using Vanilla JavaScript

51 pointsby captainnemo729today at 9:55 AM34 commentsview on HN

I built this because measuring my age in years felt boring—I wanted to see the kilometers.

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.


Comments

Tiberiumtoday at 2:26 PM

New account, vibecoded demo (the style gives it away, plus the comments in source), author using LLM to write comments, yet this reached the top page.. HN is certainly interesting nowadays.

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 --- */

show 1 reply
potluritoday at 2:11 PM

Just want to comment on the star background. I did something similar for my own site (link in bio). I ended up rendering the stars in a three.js scene because drawing them on a 2D canvas did not look like a satisfying effect. CPU usage was lessened as well, at least on my mobile and two desktops (can't verify your site's CPU utilization since I'm on mobile atm). It also fixed the issue where resizing the viewport would mess with the rendering of the stars, like it occurs in your app currently.

show 1 reply
reconnectingtoday at 11:27 AM

It's really odd that we're stuck in this fish tank with zero idea where we're flying now, or where we were before. I believe this is vital information for every journey.

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.

show 1 reply
netsharctoday at 12:01 PM

Geez, gotta love that you have to reach the bottom of the page and read the small print to realize that the date input on the top is supposed to be for your birthday... and then to figure out that the site is a calculator of "this is how far you've travelled relative to [the center of the universe?] since birth"...

show 1 reply
widforsstoday at 11:00 AM

Nice job!

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.

show 1 reply
anileatedtoday at 11:46 AM

Even if you remember the times of iPod, you can safely say you're less than one light year old.

show 2 replies
croisillontoday at 11:51 AM

it's cool but i was expecting some kind of visualization, how do my 1.2 trillion km look on a map?

also there are some cursors with question marks but they don't espatially ;) call the FAQ, do they? firefox on win10

show 1 reply
arendtiotoday at 11:38 AM

So, how much does the galaxy's travel affect the speed of time?

show 1 reply
redmattredtoday at 12:08 PM

This is great, well done.

show 1 reply
DmitryOtoday at 2:01 PM

Its vibecoded, I can see this shitty borders and neon that Gemini and other AI tools like so much

show 1 reply
dalton_zktoday at 12:29 PM

Awesome!!!

show 1 reply
bvantoday at 2:12 PM

Love it and the fact it’s lean. No back-end slop.

show 1 reply