Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: I rebuilt the Flash app “Scale of the Universe” in WebGL (htwins.net)
276 points by mattmar96 on Dec 8, 2021 | hide | past | favorite | 79 comments



Was this a port of the Flash app or reverse engineering it? The description on GitHub mentions that the Flash version was made by your friend, so I presume you have the original source available.

I've wanted to port an old Flash game for a long time, but I only have the .swf file, not .fla, because I'm not the original developer. I've tried several decompilers to examine the code and resources, but it would take a lot of work to make sense of the obfuscated code. Unfortunately, it can't be played in the Ruffle emulator since it is written in ActionScript 3, which is not currently supported.


It was closer to a port than reverse engineering. I spoke with Cary (the original creator) to get explanations from him on how the features and math behind it worked. He then sent over the metadata and images for all the objects. I think he sent the original flash project as well but I don't remember reading that code too much because his explanations of the functionality were sufficient.


You can check out the source code here: https://github.com/matttt/scale_of_the_universe


I wonder how much time did the original version took, and how much time did you spend?

I assume Flash version is easier to implement and requires less technical knowledge.


Not sure on the original, but I spent about a year working on it on weekends here and there. Hard to find time with full time work and other projects mixed in. I would say it was around 100 hours of work in total. The majority of the was done within a couple weeks but there were a lot of performance tweaks and bugs to fix.


Thank you for your sharing!


I didn't realize that the Planck length was so much smaller than the elementary particles. "There's plenty of room at the bottom" indeed.


Loving this, really nice work. Works super smooth and even the music is quite nice!

A little bit of unrequested feedback:

- Allow me to drag the viewport somehow. A couple times I wanted see elements around to position them on my screen in perspective but couldn't do that.

- Allow me to stop the zoom out animation somehow. At the moment one move on my trackpad and I teleport from coffee bean to Rwanda. I can't stop this zoom animation. It seems that I have to go to Rwanda.

- Support retina screens. This might come in really useful. To do this (it occurs to me that you're using PIXI.js), when creating your app set resolution to window.devicePixelRatio || 1. You might be on a devicePixelRatio === 1 screen and can't see the difference right but trust me it's there. You can test and see it on any modern mac or apple mobile device.

Sending you a digital high five of size of the observable universe.


The performance is really good. Usually when I open a GPU-intensive visualization in the browser, my laptop fans start making a lot of noise, but not this time.


I'm very glad to hear it. I spent a lot of time optimizing.


> even the music is quite nice

Thanks for mentioning that; the music does not play in Safari, so I opened Firefox in the background for the music while zooming in Safari via trackpad scrolling (which doesn't appear to work in Firefox).

The wonderful "Powers of Ten" video has been mentioned elsewhere in the comments; see also "The Simpsons" take: https://www.youtube.com/watch?v=ycvlJ9XMd94 .

Lots of fun - thank you, mattmar96!


Ah so many bugs. Going to take care of all of these soon. Glad you enjoyed.


Thank you for the kind words and feedback! I'll look into these.


Past threads about the original (and maybe a few variations):

(Edit: this is fun too: https://abcnews.go.com/Technology/page/scale-universe-cary-m...)

The Scale of the Universe (2012) - https://news.ycombinator.com/item?id=9629418 - May 2015 (8 comments)

Scale of the Universe - https://news.ycombinator.com/item?id=7298423 - Feb 2014 (80 comments)

The Scale of The Universe- Made by 14 year old twins - https://news.ycombinator.com/item?id=4816166 - Nov 2012 (1 comment)

The Scale of the Universe 2 - https://news.ycombinator.com/item?id=4691798 - Oct 2012 (1 comment)

The Scale of the Universe - https://news.ycombinator.com/item?id=3589030 - Feb 2012 (8 comments)

The Scale of the Universe - https://news.ycombinator.com/item?id=3585187 - Feb 2012 (2 comments)

The scale of the universe, and everything - https://news.ycombinator.com/item?id=2398150 - April 2011 (17 comments)

Scale of the Universe - https://news.ycombinator.com/item?id=1953919 - Nov 2010 (39 comments)

Scale of the Universe - https://news.ycombinator.com/item?id=1835460 - Oct 2010 (46 comments)

Scale of the universe (flash) - https://news.ycombinator.com/item?id=1261816 - April 2010 (15 comments)


Thank you for this. It has been nice to read the old threads.

btw, I appreciate you fixing my grammar in the title.


For people who like scale comparisons of absurdly large things, there is also: https://www.youtube.com/watch?v=7XbeVosPszo

Original: https://www.nicovideo.jp/watch/sm20365493


I like this (1) one even better because it highlights the mind bogling vast distances in space instead of just the size of objects.

(1) https://joshworth.com/dev/pixelspace/pixelspace_solarsystem....


This one for fictional starships is well done https://youtu.be/aTPwbVqU6lc


Very nice! You should consider hosting it on it's own domain, something like scaleoftheuniverse.art, .co, .app


Very cool. I had no idea that the diameter of Jupiter was a mere fraction of the distance of the moon from earth!


All planets in the solar system could fit side-by-side between the earth and the moon.

Astronomical distances be wild, yo.


Wow! I guess you get a little biased when looking at those artistic representations of the solar system from a young age that aren't to scale.


The other factoid though, VY Canis Majoris fits inside the orbit of Saturn... that's huge in the other direction. Especially compared with what you said.


These things are always depressing to me regarding meaning. I know the now point is to avoid pain/exist. But the scale and scifi, traveling, will it happen, even then what's the point but yeah. At least I'm busy being poor/trying to escape that at the moment.

I do pursue things, have goals, enjoy solving problems/making things but yeah... good reminder. Same for remembering that you are a bag of meat.


It's worse falling into the state of mind that no matter what you do, you're insignificant and will be forgotten, and your existence in the cosmic scale means nothing.

OTOH, it's liberating, because you know your life is yours to live, it doesn't belong to history, or some nebulous legacy. Enjoy your life, good and bad, because it's the only one you'll ever have.

The odds lucking out as a human were slim, as most lives here are microscopic and are not conscious enough to understand living.


Take solace in the fact this is a fairly peaceful era. Space while fun to fantasize about, would probably not be as "fun" in reality.

Weeks or months of travel between star systems with no internet, not fun. Oh, and we'd definitely make enemies of any alien civilizations.


How many terabytes of content do you need not to get bored? My guess is that with some adjustments, it's gonna be just fine. We somehow dealt without and endless box of content at our disposal for centuries, and some of us were even happy.


I was thinking about it, I'd probably bring the entirety of YT to keep me entertained and every media ever produced eg. movies.


On an iPhone 13 Pro / iOS 15.1.1, I get

> This version of Scale of the Universe 2 is not designed for phones. Please find the app on the iOS app store.

... but can't find your app on the app store. Any chance you could provide a link?


I get "Please find the app on the iOS app store" and "Download the Scale of the Universe iOS app!" on my Android Samsung Galaxy S8+.

I assume there is no app that will run on my phone, and that the web version might work ok if it was allowed, as some other WebGL apps do. (I don't wish to downplay the problems with WebGL or web apps generally across a variety of mobile device though. Maybe there are good reasons for blocking it.)


Oh hmm. Yeah it looks like the app isn't on the store for me either. I'm not involved in the app but I'll let my collaborator know.


I’d generally recommend not blocking mobile users. I’m not installing an app just to see if I like the idea. An “it’s even better…” pitch after using it would let me know if it’s worth the trouble.


Yeah. I’m totally not interested now I have to experience it via an app on my phone.


On an android phone this thing wants me to download the iOS app...


Oh good point. I'll update the message for android.


I would also note it seems to work very well on Android Firefox in desktop mode.


Indeed, the message for Android Firefox should be to switch to desktop mode.


Incredible... an amazing visualization. I like how you have the mine craft world in there :D


Thank you! Gotta have minecraft


Using the scroll wheel to zoom doesn't work in Firefox


Appreciate the bug report. I’ll take a look.


For any who haven't seen it, I also recommend Charles & Ray Eaemes' "Powers of Ten" https://www.youtube.com/watch?v=0fKBhvDjuy0


I like that it mentions minecraft world > earth.


It should be "中文 (繁體)" or "中文 (正體)" for the traditional Chinese, not just "中文". I'm confused a little bit since it has "中文 (简体)" (Chinese (simplified)).


Thank you, I'll be sure to fix that.


The giant green button at the bottom is just slimy -- I fell for it. No, I don't want to install your Protecto extension, whatever the frack it is. Geez.


Sorry about that, that is a google adsense ad which I don’t have control over. Need to pay for the hosting somehow.


Stick it on Netlify for free, then you don't.


Wow, that is very cool! Well done!


Appreciate it


Pretty amazing. I couldn't help but remember this yt video(1) by Carl Sagan while zooming out.

(1) https://www.youtube.com/watch?v=wupToqz1e2g


My own webgl port of Celestia, which allows zoom-out from Earth to the scale of nearest 10k stars:

https://celestiary.github.io/


This is incredible! Bravo.


I had checked it out on my phone but I just spent 20 minutes playing with it on my computer. I absolutely love it! The performance is really impressive.


Is there a way to convert this to an SVG?

Just curious what performance would be like to drag and zoom around an SVG version. I'm guessing bad...


I had that thought, but the original assets were provided to me in bitmap form. Maybe we can try that in the future though


Ah, ok.

Given the style some of the graphics would be fairly easy to convert by hand in Inkscape. But maybe some like the Sloan Great Wall would be more difficult.


Cool - just noticed some shimmering when zooming in - is mip-mapping enabled? (This might be a source of slowdown too).


Interesting, I’ll take a look at the docs. Appreciate you pointing that out!


Love it! Thanks for sharing, you're doing the science god's work, kid. You'll go far, I'm sure of it.


You have the HIV virus in there. You should add a coronavirus in there. I don't know how easy or hard that would be?


Yeah that's a good idea. The only issue is that its been translated into so many different languages that it'd be a pain to get that name/description translated to all 17 of them.


"COVID-19" should be fairly universal, probably?


Technically 'COVID-19' is the disease experienced by humans.

The virus is 'SARS-CoV2'.


What does "Total Human Height" being about the diameter of Pollux mean?? Is that a bug?


The average human height is about 1.5 meters. There are about 7.5 * 10^9 people alive, so the total height of humanity is ~1.1 * 10^10 meters.

Wikipedia says that Pollux's radius is about 9 times that of the Sun, which is about 7 * 10^8 meters. So Pollux's diameter is ~2 * 9 * 7 * 10^8 = 1.3 * 10^10 meters.

Verdict: not a bug.


Nice! Where is the music from? It feels very familiar... isn't it from Kerbal Space Program?


Yeah it is from KSP, good ear!

https://incompetech.com/music/royalty-free/most/kerbalspacep...

Oops I should really add a credit for it.


I love it! Thank you very much!!!


This is fairly spectacular and a great deal of fun. Puts your daily problems in perspective.....

:-)


It's strange that there's Ukrainian but no Russian.


Its just a matter of who volunteers to translate.


I can try... :P

edit: I see a github link, will send a pull request someday (there's quite a lot of text to translate)


I appreciate that! No pressure, but you will be credited


Nice. Is it possible to contribute to the localizations?


Absolutely. You can email us at scaleoftheuniversedev [at] gmail.com - thanks!


Not for phones, I guess.


Yeah, just kind of tricky to get everything working on a phone. My collaborator Cary's brother Michael had already built an iOS app so we didn't bother getting this working on phones.


In web assembly, do you have to build for each machine? Or each browser? Or each OS?




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: