guillaumechereau / goxel

Goxel: Free and Open Source 3D Voxel Editor
GNU General Public License v3.0
2.83k stars 226 forks source link

Plugin support #288

Open hellocatfood opened 2 years ago

hellocatfood commented 2 years ago

Please add support for people to write their own plugins for Goxel.

The benefit of this is that will allow people to write their own model format exporters e.g. #235

guillaumechereau commented 2 years ago

Yes this is something that I tried to do at some point (there is still a Lua and JS branch somewhere on GitHub). It would indeed be very nice, not just for exporters, but even maybe to implement new tools.

From my little tests I think the easiest would be to do it in js, and make all the core objects (layers, camera, etc) internally support being wrapped into js objects.

pegvin commented 2 years ago

Look into https://github.com/svaarala/duktape, it's pretty good and small too, tho lua was more "easy" which i implemented but will add duktape in near future too.

guillaumechereau commented 2 years ago

There is already a 'ducktape' branch in GitHub that I did a long time ago to add scripting support. One issue was that it was too slow in my opinion. Goxel also used to have Lua scripting support a while ago. Since I didn't see much use for it I removed it, as I don't want to bloat the program with things that nobody uses. I think I also had a look at quickjs, though the code is not online.

pegvin commented 2 years ago

Interesting, re-implement lua again then, it's simple and "fast"

hendursaga commented 2 years ago

I for one would like to see a Lua scripting API. Then I could use Fennel!

guillaumechereau commented 2 years ago

I am wondering what would the be pro and con of lua vs javascript as a plugin language. I feel like javascript is generally a better language, but lua is used a lot in video games.

pegvin commented 2 years ago

lua is easy to implement, easy to learn even aseprite (a very famous pixel art editor) uses lua for plugin system, lite-xl is a text editor completely made in lua with some awesome plugins for it written in lua.

guillaumechereau commented 1 year ago

I started to work on javascript plugin support. In the last release (0.12.0) it is now possible to do some very basic scripts for goxel. I plan to add more bindings. I tried a bit to make it work with lua but in the end I found javascript easier to work with, since I am really not familiar with lua.