Back to overview

Alex Anderson Creates Web-Based Spaceship Controls

Alex chats with Kent about how he started Thorium and working on a side-project you love.

Thorium is the software that space centers use for the computer controls and the flight director controls of simulated space ship experiences!

The cool thing about Thorium is that it's entirely web-based. Alex is using React to build Thorium and a 3D universe. The 3D universe is being driven by react-three-fiber by Paul Henschel, which is a fantastic piece of software.

Alex says that if you are privileged enough to have the time and the energy and the resources to be able to do side projects, that you should go for it. He believes side projects give you a lot of benefits outside of just the enjoyment of doing them.

Work-life balance is essential, though. There was a time where Alex just completely stopped working on it for about a month and a half. And that was necessary for him to be able to recenter, refocus, and get in a good place where he could be motivated and energized about it again.

Homework

  • Set a timer for 10 minutes and write down one thing you would like to accomplish and break it down into small and simple actions that can be done over time.

Guests

Alex Anderson
Alex Anderson

Transcript

Kent C. Dodds:
Hello friends, this is your friend, Kent C. Dodds. I'm super excited to be here with my friend, Alex Anderson. Say hi Alex.

Alex Anderson:
Hi, Alex.

Kent C. Dodds:
And so that's great Alex. So you and I, actually we went through the same school program except you were behind me. When did you graduate?

Alex Anderson:
I actually graduated just this last April, so April of 2019.

Kent C. Dodds:
Yeah. Yeah, so I graduated in '14 so it was quite a ways back, but actually your brother, your older brother and I went through the program together, which is kind of fun. And yeah, so you've been working on some stuff that I think is awesome and I'm excited to talk about it, but before we get into that, I want people to get to know you a little bit and so why don't you just give us a little intro to Alex Anderson, R. Alex Anderson.

Alex Anderson:
Yes, R. Alex Anderson. My first name is a closely guarded secret and to be going by R. Alex Anderson is actually something that my drama director back in high school started doing when I was billed for any of the plays that I was in. So at the same time when I was going to high school, I was working at this Star Trek space camp for fifth ... They did fifth and sixth grade field trips and then they also did overnight camps and private programs for birthday parties or for adult groups that want to come in and fly around in spaceships.

Alex Anderson:
And that's actually where I got my start programming was developing these simulator controls for these space centers and then that just evolved from there until I learned how to do web development and React. And now I'm working for a "real" company doing "real" work. But my passion is definitely still these spaceship controls. And when I'm not doing that or any number of other things, I like to bake. I like to cook, I like to make things.

Kent C. Dodds:
Yeah, it sounds like you like to have fun.

Alex Anderson:
I do like to have fun. That is definitely a criteria of most of the things I choose to do.

Kent C. Dodds:
Yeah.

Alex Anderson:
I find the fun in it regardless of what I'm doing. Like even the most boring or monotonous thing can have some degree of fun.

Kent C. Dodds:
Oh, that's a nice outlook. Well wonderful. So the spaceship stuff is what I, in particular, wanted to bring you on to talk about because I just think it's so fascinating what you've been able to build. And I think maybe people need to get a bit more of a description because it actually took me a while to understand exactly what this is. So you have this Thorium project, this open source, next generation Star ship simulator controls. And if you go to the website it's really cool. I don't know if you are the one who designs the images that you have on or whatever, but it's like what even is this?

Kent C. Dodds:
And so can you give us an idea of what exactly are you building and how do your users use this? And I'm also curious what the motivation was to make it open source or other people using this project. All that stuff I want to know.

Alex Anderson:
Yeah. Okay. So get ready. I actually talked about this. I gave a talk at React Conf just last year and we can get a link to that in the show notes for people to get a little bit of context there. Basically this space center was started by a teacher who wanted a way to help his students grasp science and technology and STEM concepts but also have this artistic and interactive portion to it. So everybody on the crew has a position. You've got the captain, the first officer, navigator, the weapons officer, and they're all trained on how to do their jobs with these computer controls. And then they're given a mission that they need to accomplish during their time on the spaceship. So go and explore this area of space or go negotiate with these aliens or go and study this supernova that's about to happen or all kinds of other things. Hijinks ensues and hopefully if they do their jobs well and work together well, then at the end of their mission they have a mission completion and successfully completed it. Hooray.

Alex Anderson:
There's a flight director, a staff member who works at these space centers, trained behind the scenes on how everything is supposed to work on the storylines that they're supposed to tell. You can think of them like a Dungeons and Dragons game, dungeon master or just someone behind the scenes who manages everything.

Kent C. Dodds:
Yeah, sure.

Alex Anderson:
So Thorium is the software that they use for the computer controls and the flight director controls and I'm trying to add more and more show control aspects to it as well for the main view screen, for sound effects, for lighting controls, for all sorts of stuff to make it so that flight directors are able to tell all kinds of amazing stories to the crews that come do these space center experiences.

Kent C. Dodds:
Yeah. And so the crews that are coming in, like the school groups or whoever, they're interacting with your web application basically right? And and pressing buttons on ... Are these tablets that they're working on or what's the user's experience in using what you've built?

Alex Anderson:
Yeah, so that's the cool thing about Thorium. It's entirely web based, which is kind of crazy when you think about it because here I am trying to build basically a networked realtime video game in the browser, which is not without its share of problems. Most people would just reach for Unity or Unreal or something. But I just think the web is so great, cross-platform makes it really accessible. So all you have to do is just run the server on one computer and then all of the other computers connect to that server and bam, you've got a spaceship. That's part of the reason I chose that it was to make it so it was as easy to get up and running as possible. Which is one thing that the web provides.

Kent C. Dodds:
Yeah.

Alex Anderson:
As far as like the actual hardware, I haven't done a whole lot of testing, but I do know that it does work on pretty much anything. I think people have tried doing it on Raspberry Pi's with mixed success. There's some of these simulators that have only touchscreens and so the controls are designed to work in those circumstances. Most of them just have a regular computer with a keyboard and mouse.

Alex Anderson:
But I found recently I went to one of the space centers to do a simulation with my coworkers at my day job. This is not my day job. And I just decided to take a look at the specs of the computer to see what it was running on it. These were ten-year-old iMacs. I know that Macs have pretty good longevity, but 10 years. But I was impressed that it was able to run as well as it did.

Kent C. Dodds:
Yeah, and do you think that this is the kind of thing that would make sense in where lots of people are quarantined right now? Could we play this as a family at home or something? Is this something that only really makes sense in the context of a specific building that has all the decorations and whatever of being in a spaceship? Or is this something that you could have as like a collaborative game that you could just play at home?

Alex Anderson:
That's a really good question and something that I've been working on and thinking a lot about. I would say that I've definitely been focusing more on the brick and mortar space centers and you'll definitely get a much better, more polished experience that way. That being said, I think if you knew what you were doing, which is, it's a complicated piece of software so that's a big ask there. But I think that you could have a good living room simulator experience if you were to set it up right. And something that I'm working on right now is making it easier for people who ... Perhaps you're an experienced Dungeons and Dragons dungeon master. If you know what you're doing there, I want to make it so that it would be easy for you to transition over to flying Thorium flights as a flight director.

Kent C. Dodds:
Yeah, yeah. Seems like a world of opportunity awaits. Yeah, that sounds like that might be a lot of fun. There's actually this game that I really enjoy called Spaceteam.

Alex Anderson:
Oh yeah, Spaceteam's great.

Kent C. Dodds:
Yeah, it makes me think of that. So very cool. So how many simulators are running your software?

Alex Anderson:
Ooh, good question. So the space centers that I'm aware of using it full time, there are five locations in Utah and-

Kent C. Dodds:
[inaudible 00:09:21].

Alex Anderson:
Yeah. And some of them have multiple simulators. So I think it's a total of about, let me see, 1, 2, 3, 4, 5, 6, 7 , 8 , 9, 10, 11 12, 13 and then there are actually two more simulators under construction right now. So that would bring it up to 15 simulators that use my software full time. And then there are a number of hobbyists that have found it on the internet, downloaded it and use it for whatever purposes. Frankly, I don't know. They don't tell me everything that they deal with. They just do it, which is kind of cool.

Kent C. Dodds:
Yeah. Wow.

Alex Anderson:
It's been one of the most interesting things about this whole experience. I set up a Discord server, which the link's in the thoriumsim.com website. And random people just show up and say, "Hey, I found this. I think it's really cool." And we talked for a bit and they ask some questions about how to do stuff. So kind of fun seeing the reach of this.

Kent C. Dodds:
Yeah. Yeah. So the thing that prompted me to get you to chat with me about this ... Because we've talked about this in the past. But I've noticed some things that you've been working on recently with this that have just kind of blown my mind. So we've got a Twitter thread that I'll have in the show notes here of just some of the progress that you've been making on the simulator experience. And it's more than just buttons and knobs and controls to make things happen.

Kent C. Dodds:
And that's kind of what I thought it was, is just some buttons and knobs and alerts showing up and tasks to do. But I'm seeing spaceships actually flying in space and you have a throttle and yaw and joystick and acceleration and all of this physics ... Actually it's a legit game and stuff now, which is really cool. People should absolutely take a look at some of this stuff. I don't even know where you begin with this, with making 3D models and especially in the web. I don't know what you're even doing here. So do you want to tell us a little bit about this? What are your goals for having the actual spaceship flying around on the screens here and what are some of the challenges that you faced with this too?

Alex Anderson:
That's great. So the way that space centers have operated in the past has been very hand wavy where the flight director just says to the crew, "Oh, there's a ship in front of you and they're a bad ship." And maybe they'll show some videos on the main view screen in front of all of the crew that they've ripped from Star Trek episodes to depict those ships. And there is an officer, the sensors officer that has a little sonar grid that shows the position of ships relative to the cruise ship. But all of that's ephemeral. As soon as those ships leave the sensor grid, they disappear completely and the position of the simulator isn't tracked in space. It's all just up to the imagination of the crew and the flight director.

Alex Anderson:
That definitely has its benefits because it means that literally anything could happen. But at the same time it has drawbacks, especially when it comes to new flight directors that maybe don't have this library video clips that they can pull on for any ships that come in or all ... I mean basically you have to put everything together beforehand and have this package of a mission prepared so that you can show the right things at the right time.

Alex Anderson:
I wanted to make it so that you could show everything that was happening in space actually there on your main view screen. And I also wanted to make it so that there was a little bit more realism in the controls where if you launch a robotic probe into space, you'll actually be able to see that robotic probe fly off into space. Or if you have 10 ships come approach you on sensors from different angles, then you can actually see those 10 ships on your main view screen. And if you fly away, those 10 ships are still there. You can fly back and they'll still be there.

Alex Anderson:
So the biggest challenge with all of this for me has been figuring out how to model it all in a way that is realistic, but also simple enough for fifth and sixth graders to be able to understand how to use these controls and how they work. And also making it so that the flight director still has the power to tell the stories that they want.

Alex Anderson:
One thing that people sometimes don't realize is that space is really dang big. In that Twitter thread there's actually one tweet where I talked about flying towards the sun, which is 93 million miles away from earth. And that's where I started from. And I just flew at the fastest speed I possibly could that I've programmed in so far, which is one 10th the speed of light and even going at one 10th the speed of light for 10 minutes, it doesn't look like you've moved at all. Yeah. Normally it takes like eight minutes. So at one 10th you'd imagine it would take 80 minutes to get there, but even after one eighth of the time it takes to get there, it doesn't look like you've moved at all. In Star Trek-

Kent C. Dodds:
It sounds boring.

Alex Anderson:
That's super boring. In Star Trek, if you travel at literally the fastest speed that any of their ships can go, it would take you about a day to get from earth to the nearest star, Alpha Centauri. But these missions that these space centers do, take place over an hour and a half. They don't have time for that. You've got to be able to get from star to star within that time and still be home for supper.

Kent C. Dodds:
Yeah.

Alex Anderson:
So figuring out how to balance all of those different things has been the biggest challenge.

Kent C. Dodds:
Well, so what's the solution? How do you make it so ... Or do you just make it so that they have teleportation capabilities or that they can travel beyond the speed of light or what's the solution there?

Alex Anderson:
Right. And obviously you have to be able to travel faster than the speed of light. But figuring out how to put this all together, I've actually been working with the space centers themselves, with the staff members, with the directors and anybody that I can find who's willing to talk about this crazy stuff, to get their take on it.

Alex Anderson:
And I've gotten a lot of really good ideas from them, which have helped me as I've constructed this piece by piece. Yeah. It's been really interesting going through this whole process and discovering as I go, not only the things that this thing is capable of that I didn't necessarily realize before these emergent opportunities, but also the challenges that await me in the future as I go. Yeah. Interesting just taking it step by step.

Kent C. Dodds:
Yeah. Yeah. Well, and that's actually ... So I've gone deeper into the actual thing that you've built because I just think it's so fascinating. But the thing that I ... to bring it to a real takeaway for people of what I wanted to talk about here was how you've been able to build this thing that ... Honestly, I look at this and I'm like, "How do you do that?" I didn't realize that people will do this. Like of course they do this. There's some really amazing pieces of software people create. But I'm like, I know the person who made this stuff. Like it looks really incredible.

Kent C. Dodds:
So yeah, I just wanted to talk with you about how do you set out to create something that maybe at the beginning I assume you never took any classes about this or anything.

Alex Anderson:
No, I haven't.

Kent C. Dodds:
Yeah, [crosstalk 00:17:15]-

Alex Anderson:
[crosstalk 00:17:13] the Marriott School teaching classes on video game development. It's a business school [crosstalk 00:17:19] university. That's where Kent and I went to school.

Kent C. Dodds:
Yeah. I can't really see that happening. Did you envision creating something that you've created here or if you did or didn't, either way, how did you get to building something like this? Especially when it's not something you're paid for or your full time job or the thing that you do all the time. How do you get yourself from doing nothing to actually building stuff? Especially since you just barely went full time as a software engineer as well.

Alex Anderson:
Yeah. It takes a certain level of crazy to do this when it's not your full time job and I don't get paid for the work that I do on Thorium. Sometimes I get donations, but it's not a whole lot, just enough to keep the lights on for the project itself. And it really, it's been just tickling the back of my mind forever. I've been working on Thorium itself for the past almost four years now. And even before that, I've been thinking about how to build this 3D universe that crews can experience in these vast, epic stories where they fly around through space. And the technical requirements of doing that are just ... There's a lot of stuff that you've got to learn.

Alex Anderson:
So for me, I suppose that the very first thing that I did was I started experimenting, just playing around with things. And is back years and years and years still. So I learned a little bit about how 3D animation works. I did a Udemy course on Three.js and thought about how all of the different aspects of these simulations work together. Then about six months ago, after doing experiments for years and years and years, I finally wrote up everything that I wanted this 3D universe to operate, how it was supposed to work, in a RFC. That's a request for comments. And it just became the document for how everything should behave based on my understanding at that point, of course.

Alex Anderson:
And since I had it in words and writing, I could send it around to other people and get their thoughts on it and make sure that I was going in the right direction so I wasn't doing something that my users wouldn't like. And then, with that document in place, I finally sat down and according to the Twitter thread, apparently on February 22nd I started writing in a CodeSandbox, just pulling in a couple of tools and seeing what I could put out there just to get started. And that started the ball rolling.

Alex Anderson:
I also want to make sure that I point out that so much of this is not me per se, but standing on the shoulders of giants, of others that have done a lot of the work for me beforehand. So the space center folks that helps me percolate some of these ideas, React is what I use to build Thorium and I'm also using it to build this 3D universe. And that's being driven by react-three-fiber by Paul Henschel, which is just an amazing piece of software and easy to pick up and use and has just made building this a joy and delight.

Alex Anderson:
And honestly, react-three-fiber hasn't been around for that long and frankly React hasn't been around for that long either. And the fact that these tools have finally arrived and gotten to the point where I can use them in this is also part of the reason why it's taken me so long to actually do this after years and years of experiment and looking at things. Finally, the stars are aligning, literally. I'm able to finally put something together.

Alex Anderson:
And then just with that Twitter thread. Let me take a look back at the beginning of it. I start with just a grid that you can scroll around on and pan and zoom and stuff, and then I put some boxes on it, and then I put some spheres on it, and then I make it so that you can change the color of the spheres. And then finally I start putting textures on them and making them look like planets. And then a little later I start putting 3D models on that look like spaceships. It was just little bit here and a little bit there, doing a lot of research to discover things that I maybe didn't know before.

Alex Anderson:
And just over time things finally start coming together to the point where, as of today, which is the 1st of April; happy April Fool's Day; I've got my joystick and a throttle and I'm able to use the joystick and the throttle to control a ship as it flies through space around these objects, which is just really satisfying to be able to come to this point. And I know I still have a really long ways to go as far as all the features and all of the things that I want it to be able to do, but getting to this point and the fact that it works is huge relief and a big, euphoric feeling.

Kent C. Dodds:
Yeah, I can imagine. It's just really incredible what you've been able to accomplish and in doing something on your off time. How much time do you typically spend on Thorium developments every day?

Alex Anderson:
That's a good question. It depends on the day. Some days I just can't and I just say to myself, "You know? I've done enough. I'm going to take a little break," and I don't even touch it. Some days I really get in the zone and I can spend ... Like if it's a weekend, if I'm lucky enough to get in the zone on a weekend, I can spend eight hours jamming on this.

Kent C. Dodds:
Wow.

Alex Anderson:
So long as my wife is okay me spending that time on it. But yeah, I get a kick out of it. I enjoy it. The typical day I'll probably spend maybe an hour on it. I wake up really early in the morning and just get out of bed, pull up Thorium, fix some bugs or work on the 3D universe or do something for a little bit, just every single day. Some days I can only put in maybe 30 minutes before I'm like, "Okay, that's enough." So it really varies from day to day and week to week.

Kent C. Dodds:
Yeah, that makes sense. And, and it sounds like at least for this 3D portion, the code that you're writing in here, like you mentioned before, this is all in a CodeSandbox. it's not actually part of Thorium yet. That's what I'm getting. Or maybe it is now.

Alex Anderson:
Yeah. I started in CodeSandbox and then as soon as I felt good about what I had there, I pulled it out and brought it into Thorium. Thorium is very network and server centric. So the cool thing about the animations that you're seeing in the videos and the Twitter thread, all of those animations are actually being calculated on the server, the physics and everything.

Kent C. Dodds:
Wow.

Alex Anderson:
And it's just sending positions to the client 10 times a second and then the client is interpolating those values to make the smooth animations. I've tested-

Kent C. Dodds:
What are you using for that? Is there a library that you're using for those interpolations?

Alex Anderson:
No, I'm using React hooks and yeah, it's ... react-three-fiber, once again, is just an incredible abstraction on top of Three.js. It has a hook, a React hook called [useFrame 00:25:28] that lets you insert code into Three.js's Animation frame. And all I have to do is just figure out how long it's been since the last data came in from the server and do a linear interpolation. You can Google that if you don't know what it is. Basically it splits up a change over time into segments and I can pick any one of those segments and it tells me what the change is at that particular time. So if I know the time that it should be at, then I can put it in the correct place in that frame.

Alex Anderson:
So no real library. I am using GraphQL for this, but it's subscriptions that I'm using web sockets, so it's just sending that data down web sockets to get it to the client. But you don't have to use GraphQL for that. You can just use a regular web socket.

Kent C. Dodds:
Yeah, yeah. That's interesting. Yeah, and actually the whole tech that you're using for this is interesting and people can learn more about that from your talk at React Conf. It was really a fascinating talk. It's actually very well done. Good job.

Alex Anderson:
Thank you, Kent.

Kent C. Dodds:
So yeah. So with all of this, over the last few years, that you've been working on this on the side and just small and simple steps over time, there's got to be some things that you've learned about building stuff, whether it be hobby projects or even work projects, whatever the case may be, that you could give advice for people who have their own projects that they're working on. Maybe they're feeling demotivated about it or whatever the case may be. What would you say are some pieces of advice that you could give to people who are ... Maybe they don't have a project but they want to have something that they want to work on or they have something in the back of their minds, but they just haven't really taken the time to work on it?

Alex Anderson:
Yeah. Those are a lot of good questions. So I definitely believe that if you are ... Let me say this the best way possible. If you are privileged enough to have the time and the energy and the resources to be able to do side projects, then they definitely ... I believe side projects give you a lot of benefits outside of just the enjoyment of doing them. I recognize that not everyone's able to do that because of their job situation or their family situation or whatever, but if you are able to do it, I do think that you will find benefit from that. Thorium and my work have overlapped in a lot of ways where stuff that I do at work has given me inspiration for the spaceship controls and Thorium has given me inspiration for the stuff that I'm doing at work. So it helps that. It obviously helped me build a nice little community of people that are interested in the things that I'm doing and that like this thing that I'm doing. So that's kind of fun.

Alex Anderson:
When it comes to motivation, I definitely have experienced burnout with Thorium before because it is a thing that I'm doing for free. I don't have a ton of users, which is a nice thing because it means that I don't get super burned out by tons of people asking for tons of features, but I still do get a lot of requests from the users that I do have and that's a little discouraging when I'm not able to accomplish everything. There was actually a time where I just completely stopped working on it for about a month and a half, just didn't even touch it. And that was necessary for me to be able to recenter, refocus, and get in a good place where I could be motivated and energized about it again. And I think that might be necessary for some of your listeners if they are feeling discouraged about something.

Alex Anderson:
And then as far as finding something that you want to work on, I think the most important thing is just finding something that you know you'll be motivated to work on. Something that you'll enjoy sitting down working on every single time that you do it. I hear a lot of people out in the Twitter sphere, the Blogoverse, whatever, talking about how you should work on your own problems, solving your own problems or put another way, scratching your own itch. The kinds of things that are not the best that they could be in the world. You have the tools and you have the power to make those things better. Just a little bit of effort, a little bit of energy every single day, and compounding it over time as you go.

Kent C. Dodds:
That's great advice. And as it happens, that's our homework for today. So I'll just mention that now. So the homework for this episode is set a timer for 10 minutes and write down all of the things that you can think of that you want to do during that 10 minutes. And then pick one of those things that you'd like to accomplish. What you can do in a small and simple number of actions over time.

Kent C. Dodds:
So it could be a huge project that you've been wanting to work on, like maybe even a startup thing. Or it could be just this small and simple project that you can get done in a couple of weeks. But the goal here is to just try and accomplish something with small and simple actions over time.

Kent C. Dodds:
So is there anything else here at the end, Alex, that you wanted to mention to folks?

Alex Anderson:
Just that you all are awesome and amazing. You have incredible, immeasurable worth and value and I'm so excited for all of the amazing things that you're going to create and bring into this world to make it a better place.

Kent C. Dodds:
I love that Alex. Thank you. What's the best way for people to get ahold of you?

Alex Anderson:
I'm on Twitter a lot. My handle is, @ralex1993. And if you're interested in joining the Thorium spaceship community, there's a little chat link on thoriumsim.com where you can join the Discord server and hang out with a bunch of people that love spaceships.

Kent C. Dodds:
Awesome. Sounds like a fun place to be. We'll tack this on here right at the very end, but one thing that I think would be really interesting in the future of Thorium would be to take it into VR or maybe AR. Have you thought about that at all?

Alex Anderson:
I have thought about that and I think it's an interesting thing, but this 3D universe took me several years to think about and personally how to execute. I think it's going to take a bit of time before I get to that point. If anyone wants to send me an Oculus quest or something though, so that I can actually build VR support of some kind in the Thorium, I'd be down for that. But I don't have any VR gear yet myself, so ...

Kent C. Dodds:
Well, maybe it won't be too long before ... We've been in quarantine for so long that it becomes a basic necessity. [crosstalk 00:32:55] this all day and ...

Alex Anderson:
Yeah, exactly.

Kent C. Dodds:
Yeah. Well, thank you so much, Alex. It's been a pleasure to chat with you and yeah, we'll chat another time later. Thanks everyone.

Alex Anderson:
Thank you, Kent.

Kent C. Dodds:
Bye.

Alex Anderson:
Bye.

Sweet episode right?

You will love this one too.

See all episodes

Featured episode

Justin McMurdie Breaks Apps Into Micro-Services

Season 3 Episode 6 — 32:16
Justin McMurdie