jamieowen / threeflow.js

132 stars 9 forks source link

Compile Sunflow to WebAssembly? #10

Closed mrdoob closed 1 year ago

mrdoob commented 3 years ago

Would it be possible to compile Sunflow to WebAssembly so this library can run all in browser?

jamieowen commented 3 years ago

@mrdoob Good question!

I'm no java expert, but I think it might be possible, there's some fairly active Java -> WebAssembly compilers out there. https://github.com/i-net-software/JWebAssembly https://www.leaningtech.com/pages/cheerpj.html

And the source looks like it has no other major dependencies, other than the 'Janino compiler'. Which I think is only for runtime compiling of java scene files ( not the text based .sc file which I used ) https://github.com/fpsunflower/sunflow

There's a clear entry point from which the CLI works with ( which a WASM entry point would likely replace/mimic ): https://github.com/fpsunflower/sunflow/blob/master/src/SunflowGUI.java

This all maps to the main render API that is supplied a 'Display' class for switching out screen / file renderers ( which could perhaps be adapted to WASM IO ) https://github.com/fpsunflower/sunflow/blob/master/src/org/sunflow/SunflowAPI.java

Probably all easier said than done though! :)

May be one for the todo list!

mrdoob commented 3 years ago

I think I would need another month-long lockdown to learn all this 😅