davidpeicho / ecstra Goto Github PK
View Code? Open in Web Editor NEWFast & Flexible EntityComponentSystem (ECS) for JavaScript & TypeScript
License: MIT License
Fast & Flexible EntityComponentSystem (ECS) for JavaScript & TypeScript
License: MIT License
Recently I've been working on an ecsy-three type project in my free time and there are some economic changes that would be needed in this library to improve overall support.
I was trying to add coverage to ava (in this project) but was not able to set it up as I'm far more familiar with jest/mocha. Would you accept a PR for replacing ava? If you intend to stick with ava, do you have suggestions for coverage with typescript?
Update / Rendering are often different in several way:
I am not sure yet if this concept exists, but it would be nice to be able to feed a World
into a RendererWorld
or something.
Let's imagine a simple cases like:
The DOC.md is mentioning some nice and useful features, that the version I got from NPM (0.0.2) does not seem to have, like
Property 'onEntityAdded' does not exist on type 'Query<Entity>'.ts(2339)
seems not to be defined. Also there are some other changes to the NPM version, like different names of decorators.
When is it coming out?
I just switched from ecsy to ecstra. And I like it so far :-)
Need some help? I plan to build my next game with ecstra, if that works out. :-)
Right now, it's a bit "slow" to add / remove component. Adding / Removing a bunch of components will trigger multiple archetype transfer.
It would be great to have a batch addition / removal without creating temporary allocations when possible. It might be tricky to do.
Instead of creating "reactive queries" that sort entities based on added/removed components, I think I will modify the Query
class to process queries with extra selectors:
Added()
→ query only process the entity when it's the first tick the component is addedRemoved()
→ query only process the entity when the componet has been removed at this tickModified()
→ query only process the entity when the componet has been modified at this tickMost likely should sort component by constructor name as currently the order component are add probably with effect the hash.
See both in docs. Guessing there was a name change and didn't do a full sweep.
Hi, I talked to you on reddit the other day about the benchmarks. I put your benchmark code from here to jsbench.
I ran into a few problems:
registerComponent
on World
doesn't exist, it's named register
instead. If you've made any significant changes since, this would influence the result greatly.I hope you find this useful. Feel free to close this 😃
It appears you are treating entity name and time as a special case. I've found having a global "singleton" entity with a TimeConponent advantageous as systems can conditional manipulate time given events. Same with the createEntity(name) is possibly better suited to a NameComponent{name:string}
. It makes things like stats generation much easier if there is no special case and the system is generic as possible.
When the max number of component type is reached, the world shouldn't crash but should re-compute All ids. Obviously, it's not the best case for performance, but people should be aware that declaring the good count is better.
The library should be created with a Node.JS benchmark that could also be used as a profiler to ensure the speed is never going down (except when accepted).
It looks like the community still needs deferred removal. I think a good way to go for that, would be to implement CommandBuffer in the same way other ECS work.
Commands contain semantic about how to apply the its state onto the world. We would need command such as:
RemoveComponentCommand
RemoveEntityCommand
Later on, this can go even further with other types of commands.
CommandBuffer's contain a set of command to apply. For instance, an entire group of system could register command in a single buffer that will later be applied.
The key here is to let the user choose when to apply the commands. We could create default basic command buffers:
Using command buffers would make the implementation simple. There is no need for the internals to track what is removed and when to remove it.
With an implementation like that, it seems impossible for someone to remove in a deferred fashion a component / entity. For me, it doesn't make sense to remove something deferred when not executing the world, but maybe some people have use cases for that?
Turns out #21 raised a really good point. If deferred removal is done only when ticking, then resources might leak (exemple with WebGL object allocated in systems). Command buffers should then be exposed to users outside of systems as well! The good thing is that it shouldn't be hard to implement
It seems that the Ecsy repo is dead at this point whereas this library is being updated regularly. On the other hand, Ecsy already has a decent number of features as well as bindings to many other libraries and dev tools. I'm working on an experimental game that will probably requiring swapping out large sections of the codebase in the future since there's certain features of my project that I'm still unsure on how they will work or if they will work. So I'm looking for a library that will provide maximum architectural flexibility but I don't need it to have tons of features. I realize that neither project has reached a stable release, but how complete would you say this library is compared to Ecsy? Thanks!
When interacting with WebGL there is init/destroying of external buffers. Having events fire when a query changes inclusion of an entity is must for decoupled systems.
TS decorators will help TS users create component without using manually the Properties
static attribute.
Is there an init
method equivalent for System?
For JS users, it's quite annoying to do:
Properties: {
prop: new MyProperty()
};
When it could only be MyProperty()
. This change is small but makes sense.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.