Running JS physics in a webworker - part 1 - proof of concept

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • gamedev-experiments

  • This is not a step by step tutorial, I wanted to keep this article more conceptual and code-light. You should be able to follow my Spaghetti code in the project repo.

  • rapier

    2D and 3D physics engines focused on performance.

  • rapier.rs - modern physics library written in Rust. It looks good and performant, at a first glance dev experience is a lot better than box2d. Documentation gives me hope!

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • vite

    Next generation frontend tooling. It's fast!

  • I decided against using any framework to avoid unnecessary complexity. For my bundler I decided to use Vite since I was familiar with it and the provided vanilla Typescript template. It provides an easy way to import webworkers and their dependencies even from Typescript files.

  • PixiJS

    The HTML5 Creation Engine: Create beautiful digital content with the fastest, most flexible 2D WebGL renderer.

  • Pixi.js is a fairly easy to use WebGL renderer. It will show what we're doing on screen. Everything I'm doing can be replicated by copying one of the examples. All you need is to:

  • box2d-wasm

    Box2D physics engine compiled to WebAssembly. Supports TypeScript and ES modules.

  • box2dwasm - an old, still maintained C++ library compiled to WASM. The documentation is lacking and developer experience seems poor.

    I can imagine that communication with vanilla webworkers could get very complex. Comlink is something that's been on my list for a while and I'd like to try it out.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts