A planetary body simulator with a HTML5/CSS3/JS frontend and simulated using Rust WebAssembly.

Overview

Solar Sim 🪐

A planetary body simulator with a HTML5/CSS3/JS frontend and simulated using Rust WebAssembly.

Try the latest version here!

Travis CI Build Status

Built with 🦀 🕸 by The Rust and WebAssembly Working Group

Preview of Solar Sim

About

This is a hobby project I started in 2020 as part of a project about Lagrange points for an astronomy class I took. Originally, this was written purely in JavaScript, but the performance was quite bad even on my i9 MacBook Pro and had a lot of stuttering, especially on Firefox. Almost 2 years later, I decided to return to the project to see if I could make it more useful for other people.

Now that it uses Rust WebAssembly, the performance is significantly better and uses much less CPU. I'm looking to expand the functionality by allowing users to add and remove planets, change the speed of the simulation, and maybe expand from Lagrange points to other educational topics about space, such as the Three-Body Problem.

Install

Before getting started, you will need NodeJS v16 and the Rust Toolchain.

Once you have these, begin by cloning the repo and updating rustup:

git clone https://github.com/ben9583/solar-sim.git solar-sim
cd solar-sim
rustup update

You will also need to install the requisite npm packages. Remember to be on NodeJS v16 if you use nvm.

cd website-src
npm install
cd ..

Develop

Ensure you are in the root directory of this project. Begin by creating the npm package using wasm-pack; this will create the package in ./pkg.

wasm-pack build

To start the website for development, run the following command in website-src. This will reload the website when you make a change or run wasm-pack build again.

cd website-src
npm start

Build

Finally, to make a production-ready build, use npm run build to generate a static website in website-src/dist:

cd website-src
npm run build

Links

Comments
  • A More Accurate Simulation

    A More Accurate Simulation

    When two bodies get close and start to move really fast, the simulation accuracy breaks down. This is clear because when two bodies are orbiting each other, their orbital paths should never change (ignoring gravitational wave effects, that's endgame simulation). However, if the bodies get really close, their orbits can change substantially and even launch them into escape velocities. The ultimate problem here is that the simulation timestep is too big for these scenarios. Would it be possible to either lower the global simulation time step, or figure out a way to change local timesteps when planets have high expected velocities?

    bug simulator 
    opened by ben9583 1
  • More Intuitive Body Adder

    More Intuitive Body Adder

    A body has a few properties:

    • Name
    • Mass
    • Radius
    • Position (x, y)
    • Velocity (x, y)
    • Color

    When adding a new body to the universe, the player has to manually input everything through textboxes. This is an ugly solution that makes it difficult to know where things are going and how they'll interact with other bodies. The name and mass I think are fine (except that the mass uses stupidly large units) but position and velocity should be a matter of clicking somewhere in the simulation and dragging to "slingshot" the planet. I think the radius is fine but it'd be cool to make that a visible element before the player places the body and maybe they could change it by scrolling.

    enhancement frontend 
    opened by ben9583 1
  • Release 0.7.0

    Release 0.7.0

    • Changed the cookie policy in case of being hosted on another website
    • Remove unused name field (for now)
    • Simplify drop adder by using preset sizes
    • Remove show/hide saves button
    • Fix some styling
    opened by ben9583 0
  • Release 0.6.0

    Release 0.6.0

    • Added a cookie policy
    • Fixed a critical bug that deletes more bodies than necessary when high velocities are involved
    • Added the ability to load and save configurations
    • Use cookies to maintain configurations across browsing sessions if enabled
    opened by ben9583 0
  • Release 0.5.1

    Release 0.5.1

    • Fix issue where drop adder isn't disabled when not selected
    • Move some text based elements
    • Move the debug section to above the canvas where it is more visible
    opened by ben9583 0
  • Release 0.5.0

    Release 0.5.0

    • New body adder lets users drop in planets and drag to give velocity
    • Remove bodies from simulation once they get too far away (another canvas size away)
    • Separate out current body adder into "precise adder" that allows for precise velocity and position when adding
    • Fix bug where bodies don't draw to screen when paused until unpaused

    Closes #3

    opened by ben9583 0
  • Release 0.4.1

    Release 0.4.1

    • Fix issue where checked simulation accuracy isn't used on refresh
    • Make the settings text visible again
    • Add a bit of space between the canvas and the rest of the site and give it a border
    opened by ben9583 0
  • Release 0.4.0

    Release 0.4.0

    • Added a trail quality setting that lets users set the number of particles drawn to the screen
    • Added a simulation accuracy setting that lets users set the accuracy of the simulation by choosing whether to use more or less simulation ticks per time step
    • Improve the performance of the simulation several times over through a complete refactor of the code
    • Set the default accuracy of the simulation to run 5 ticks per time step (instead of 1). This corresponds to 'medium' on the new simulation accuracy. The previous accuracy can be found at the 'low' setting
    • Improve the accuracy of the Lagrange point demonstration by using higher precision calculations

    Closes #6.

    opened by ben9583 0
  • Release 0.3.0

    Release 0.3.0

    • Adds a debug menu that shows performance for simulation and draw times
    • Remove some old print statements I forgot a while ago
    • Optimize drawing by only drawing objects within the canvas
    • Use JavaScript function requestAnimationFrame for properly drawing to screen
    opened by ben9583 0
  • Release 0.2.0

    Release 0.2.0

    New Features:

    • Adds a reset button that clears all the bodies
    • Velocity is now a configurable option in the body adder
    • Rust wasm is now completely safe (no static mutables)
    opened by ben9583 0
  • Better Input Fields

    Better Input Fields

    Right now, the buttons and textboxes that let the player interact with the simulation are hot garbage. We need to stylize those buttons and make them more usable/pretty.

    enhancement frontend 
    opened by ben9583 0
Releases(v0.7.0)
Owner
Ben Plate
Software Developer and Machine Learning Enthusiast. Junior at UC Berkeley.
Ben Plate
WebVM is a server-less virtual Linux environment running fully client-side in HTML5/WebAssembly.

WebVM This repository hosts the source code of the https://webvm.io live demo page. WebVM is a server-less virtual Linux environment running fully cli

Leaning Technologies Ltd 1.7k Jan 8, 2023
Simple To-do list build using HTML5, CSS3, JavaScript and Webpack. You can add new tasks, remove and edit them.

Simple To-do list build using HTML5, CSS3, JavaScript and Webpack. You can add new tasks, remove and edit them.

Esteban Munoz 6 Mar 5, 2022
Nutrition tracking software that uses machine learning to help you reach your body composition goals.

LogSmarter - Machine Learning Nutrition Tracker Description LogSmarter LogSmarter™ is not just another calorie counter. It is an AI nutrition coach th

Ryan Lefebvre 24 Sep 4, 2022
Storybook Addon Root Attributes to switch html, body or some element attributes (multiple) at runtime for you story

Storybook Addon Root Attributes What is this This project was inspired by le0pard/storybook-addon-root-attribute The existing library received only on

정현수 5 Sep 6, 2022
A Minecraft launcher written in Rust, with an Electron frontend.

RustMine A Minecraft launcher written in Rust, with an Electron frontend. Why? I thought it would be fun to use two of my most familiar languages, Rus

sussyimpostor 1 Oct 16, 2022
This Project is made with HTML5, CSS3, ReactJS, Axios, MetaMask, thirdweb, Rinkeby Test Network, Web 3.0 Technologies, and OpenSea API.

Abstract Collections This Project is made with HTML5, CSS3, ReactJS, Axios, MetaMask, thirdweb, Rinkeby Test Network, Web 3.0 Technologies, and OpenSe

Shobhit Gupta 34 Jan 4, 2023
A webpack based todo list with HTML5, CSS3, JS and linters

Project Name This is a project to track your daily tasks as a todo list. This project doesn't have a backend so data gets saved in you local storage.

Ritobroto Mukherjee 19 Aug 22, 2022
Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser. Read this file in Portuguese-BR here Our Website is outd

Modernizr 25.4k Jan 3, 2023
Michael Schneider 4 Oct 26, 2022
🥰 Mini world simulator is a terminal application made in JavaScript to control the world that is being generated.

Mini-world "Simulator" Mini world simulator is a terminal application made in JavaScript to control the world that is being generated. It has no other

Adrián 2 Mar 14, 2022
An api named Crypto Versus, a multiplayer versus hacking simulator. Project still in the making!

Crypto Versus A Multiplayer Versus Hacking Simulation Inspired by the Steam game Bitburner Table of content Possible ouputs for all endpoints routes /

null 3 Jan 29, 2022
A simple CLI to patch the Fitbit OS Simulator with the new SSL certificate - March 2022

patch-fitbit-simulator Only for Mac OS currently A simple CLI to patch the Fitbit OS Simulator certificate with the new SSL certificate for the Device

Brandon Him 2 Mar 28, 2022
backend-simulator to front-end

Welcome to Backend Simulator This package was created to help beginners who don't have a backend to train server-side communications. you can install

Daniel Vidal 6 Jul 11, 2022
The repository shows the compiler (simulator) of the Little Man Computer, which also contains some programs in the LMC programming language for implementing different functions.

Little Man Computer The repository shows the compiler (simulator) of the Little Man Computer, which also contains some programs in the LMC programming

Cow Cheng 2 Nov 17, 2022
Solid, AssemblyScriptified and compiled to WebAssembly

solid-as Solid as _____! Solid, AssemblyScriptified and compiled to WebAssembly (very work in progress). Installation TODO Test npm i && npm test TODO

Joe Pea 4 Jul 19, 2022
Super Mario 64 ported to JavaScript and WebAssembly via Emscripten.

SM64-JS Super Mario 64 ported to JavaScript and WebAssembly via Emscripten. REPL Takedown I was forced to take down the REPL for this project due to c

Sevenworks 12 Dec 23, 2022
A JavaScript / WebAssembly library for generating regular expressions from user-provided test cases

1. What does this library do? grex is a library that is meant to simplify the often complicated and tedious task of creating regular expressions. It d

Peter M. Stahl 164 Dec 30, 2022
SWI-Prolog WebAssembly build as a NPM package

swipl-wasm SWI-Prolog WebAssembly build as a NPM package. Please see this page for ongoing progress and information: https://swi-prolog.discourse.grou

Raivo Laanemets 9 Nov 17, 2022