Yellow-Dog-Man / Resonite-Issues

Issue repository for Resonite.
https://resonite.com
139 stars 2 forks source link

WebAssembly support for general dynamic scripting & custom functionality #1211

Open Frooxius opened 9 months ago

Frooxius commented 9 months ago

Is your feature request related to a problem? Please describe.

Currently the only way to create dynamic content in Resonite is using the ProtoFlux scripting language. This, while powerful, can be in some cases limiting, particularly when creating complex programs, but also from the perspective of tooling, creating programs (which has to be done visually instead of typing), porting existing code and experience from other languages.

Describe the solution you'd like

To provide generalized support for scripting, we plan to integrate the WebAssembly (WASM for short) standard into Resonite. This will involve providing an interface/API for the WASM modules to create new components in-game, with specializations for various other types of components:

WASM has following major advantages for Resonite:

We will also likely provide tooling for some popular languages (e.g. C/C++ and Rust) to get things started, but will leave others left to the community contributions.

Additionally, one particular challenge will be a system for resolving dependencies for WASM modules - e.g. when multiple WASM modules reference a common shared library. This will be provided by additional/separate system (I will make issue on this also).

Major part of our work will be defining the ABI/API for interfacing with the FrooxEngine, which will be important to ensure the long term stability and compatibility of the modules.

At the time of writing this, the runtime we plan to use is Wasmtime, given it's good C# support, very active development and support from large organizations.

Describe alternatives you've considered

We were considering integrating a specific scripting language, such as Lua or Python, however this would be much more limited and would require users to use that specific language.

With WASM, those languages can still be used, but the support is not limited to just those specific languages.

Additional Context

There was existing issue created on this. However given the large impact of this feature and it's scope, I've made this official issue, since the goal is to focus on high-level benefits and support, rather than very low level specifics (which will come when this is actually prioritized): https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/573

NukiRaccoon commented 9 months ago

This would've been great when I was working on Handless Helper, as ProtoFlux lacks an elegant analog for Functions ans Function Calls.

As someone who has taught numerous programming languages, including JavaScript, this would definitely be something I would use to build some reusable libraries and complicated systems, and I know I'm not the only one with programming experience.

Frooxius commented 9 months ago

Functions and libraries will come to ProtoFlux first in form of nested nodes.