How do I get started on WASM Rust with this game engine?

How do I get started on WASM Rust with this game engine?

First, I recommend following this tutorial:

This will teach you the basics of using wasm. The same principles you learn there can be applied with Babylonjs. You basically use wasm for your calculations (updating positions of objects, etc), and Babylonjs for the rendering.

Also, the section called “Rendering to Canvas Directly from Memory” is very important if you have lots of data you need to pass across the wasm/javascript boundary. For example, if you have an array with 20,000 structs with a lot of properties, you don’t want to be passing that data back and forth across the boundary otherwise your fps will tank. Put it in memory, and let javascript read from the shared wasm memory.

4 Likes

I see this is a old post but I am adding a comment too it incase someone else runs into this.

I created a very simple quick starter template in git that I use for my Rust WASM projects.
https://github.com/caperaven/crs-rust-wasm-starter

It’s not babylonjs specific but it gets the rust boiler plate out of the way.

2 Likes

I am busy with a test project to use Babylon in Rust.
I am 90% there, just still need to figure out how to use Rust delegates as the event loop for Babylon.
There is a lot there already to learn from.

The idea is to develop your code in rust and use babylonjs as the render engine.
Once done I am hoping to have multithreading included.

So, instead of trying to pass data to wasm and taking the hit for the per frame data transfer, create and manage your data in rust and call babylonjs when you want to update rendering.

Well that is the theory …

4 Likes