Tiny ECS + Http Server

While building flix (and a number of other projects) I wanted a way to manage objects in an ECS manner at runtime. Defold’s game objects are built around this idea, but I was looking for something a little agnostic and with some interesting features.

I found Tiny ECS here:

Its a great little lib. Has some nice documentation and more importantly has some of the key features I was looking for. For clarity these were:

  • Generic tables as objects (no userdata etc)
  • Easy to make collections (they use System filters)
  • Able to iterate or execute specific updates on an entity
  • Small and easy to implement

As it stands, if you need a good ECS lib for lua, this is a great little toolkit. I then decided to take defnet (with some of my own modification :wink: ) and make a http server backend for it.
Thus when you are running Tiny ECS you can popup a webpage, and view whats happening to your world, systems and entities. I am also adding ability to modify alot of the ECS at runtime as well.

Extracting it all out of flix and making an example has been a bit messy. Some good things that happened though, I found a tun of bugs and design issues which I fixed :slight_smile:
However, some code will still need to be updated (specifically on the modification side). Its usable enough right now for people to play with and Ive started this diary so as to track any updates I do and any questions people might have if they want to use it. (or dare to) :slight_smile:

I will try to get most of the features from flix into it if possible. The animation for instance, I really want to get in, but thats on the end of my todo list atm :slight_smile:

Ignore all the placeholder html pages. They should be updated in the coming days. Except for the anim and movie pages - I might remove them to stop any confusion)

Happy to hear thoughts and ideas on it. Its turning into a very useful tool for me. I’ll try to make some bigger examples too, since thats where it becomes most useful.

14 Likes

That looks really useful! Great work with the webpage as well!

Thanks. appreciate it. The webpage is based on a free admin template (u know usual bootstrap type things :slight_smile: ). It did need a little bit of love/hacking of course. And still a fair bit to add. Should have a few updates to finish off the main stuff today.

Btw thanks @britzl or the Defnet tools. That is what is driving the http server backend. Its a little modified (in the route handling) but was reasonably quick and easy to use for serving webpages.

1 Like

I was thinking of an offline app with a webview embed. Http Server is something can help me archive that. It seems now I can bring html5 games onto Defold app.

Hi, this isnt really that? Its a http server - yes. But you use Google chrome or firefox to access and address. In this case it is: 127.0.0.1:9190 (this is configurable). So its not really running in Defold.

You can certainly do some weird things though. For example you could create a basic Tiny ECS server (with no app graphics), then serve a Defold game application from it and play it in your favourite browser :slight_smile: … its a little long winded to do that though :slight_smile:

I should note. I do have a Webview native extension that does create sort of an electron type application environment.
GitHub - dlannan/autonews: A simple auto news grabber and organizer. (this is very prototype like and only runs on win atm. It can run on OSX and linux too - but its missing some core components).
I havent updated this in a while and I have a much more stable version in my local repos here. I can look at getting that updated if there is interest in it.

1 Like

Great stuff! I’ve played around a bit with Explorer for Flecs ECS (demo), which does essentially the same thing. Among other things, it allows the user to query/filter entities just like systems do — quite handy.

I’ve thought of writing something similar, that also displays the hierarchy of game objects, like what Unity’s Inspector panel’s tree view does. It’s not too uncommon that I set the wrong parent, lose a node, disable another by mistake etc. Having a tree view would make it relatively easy to spot these issues.

3 Likes

Exactly why I made this :slight_smile:
My recent flix project only loads assets at runtime (not prebuilt) so it is difficult to manage and modify.
I was originally going to use Flecs + sokol but there are a bunch of issues going this route (spent a couple of days on that effort :slight_smile: ). This tool is heavily inspired from it, and a number of other tools I have built in the past too. The main goal was to make it quite standalone, so then it could be used for all sorts of things.

The displaying and control of a scene hierarchy is one of the key parts that will be added (once I have the ozz animation sorted).

I suspect you could tweak this to be used in a multitude of ways, and feel free to do it. its MIT license… so go nuts :slight_smile:

3 Likes

Added Performance view: FPS (in secs) and Memory use which I think is in objects collected (will check later).


Added System Filter controls. Can now enable/disable your filters as needed and enable/disable default http server entity update filter.

Updates to settings page. Still need to add a few things here to complete. Should finish the Cameras, Worlds and Effects tomorrow.

Dashboard has been updated as well (need to populate logs still)

6 Likes

Ok. As with all things software, the simple things are never simple :slight_smile:
Im currently seeing an odd problem with using acquire_camera_focus at runtime. Where it doesnt seem to be acquiring the right camera (even though the go url Im sending is definitely correct). It seem as if the url is getting incorrectly mapped to an index. Im not really sure how this is possible.

The url is a string, so maybe it isnt converting to the same hash at runtime (which would seem very unlikely). Heres an example of whats happening in vid:


You can check out the latest from the repo to see the effect. Ive tried changing the camera info in the render script too, and that isnt working as well. I think I need a break.

If anyone has had something like this before or sees a stupid dave (me) bug in the repo please let me know. I’ll get back onto this tomorrow.

< update > Added a third camera. It gets even weirder.

3 Likes

For reference @Ackle on Discord helped solve the problem (Really appreciate the help). I needed to post “release_camera_focus” on the previous camera. So now it seems to be working well.

4 Likes

All cameras acquire focus automatically now and all of them send their view and projection. If you only want one of them to send messages you need to disable the rest of them.

1 Like

Ahh! Thanks @britzl - that would explain it. Hence why the release_camera_focus works.
I hope to update to 1.8.1 next week possibly, since the enable/disable seems to be a nice api along with the cameras methods (get all cameras etc).

3 Likes

Ok. This is mostly gtg. Added a little @britzl addon :slight_smile: … lumiere for camera effects.


I did need to mod lumiere for some depth render issues. So its not included as a package. Maybe at a later date defnet and lumiere can be properly handled as normal dependencies.

There is a bit to add for world and some other additions, these will come in as I go back to flix and get that rolling along again. Feel free to use and tweak as you need. Any questions, drop them here.

3 Likes

Added some very simple documentation for this.

2 Likes