2025-02-19 18:35:02 +00:00
< div align = "center" >
< img src = "assets/image-5.png" width = "240" alt = "Jecs Logo" / >
2025-02-19 18:46:57 +00:00
2025-02-19 18:31:27 +00:00
# Jecs
2025-02-19 18:35:02 +00:00
### Just a Stupidly Fast Entity Component System
2025-02-19 18:46:57 +00:00
[](LICENSE)
2025-02-19 18:31:27 +00:00
[](https://wally.run/package/ukendio/jecs)
< / div >
2024-11-23 03:42:54 +00:00
2025-02-19 18:31:27 +00:00
## ✨ Features
2024-11-23 03:42:54 +00:00
2025-02-19 18:35:02 +00:00
- 🚀 **Blazing Fast:** Iterate over 800,000 entities at 60 FPS
- 🔗 **Entity Relationships:** First-class support for [entity relationships ](https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c )
- 📝 **Type Safety:** Fully typed [Luau ](https://luau-lang.org/ ) API
2025-02-19 18:31:27 +00:00
- 🎯 **Zero Dependencies:** Simple integration with no external dependencies
2025-02-19 18:35:02 +00:00
- ⚡ **Optimized Storage:** Cache-friendly [archetype/SoA ](https://ajmmertens.medium.com/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9 ) storage
- ✅ **Battle-tested:** [Rigorously tested ](https://github.com/Ukendio/jecs/actions/workflows/ci.yaml ) for stability
## 🚀 Example Usage
2024-11-23 03:42:54 +00:00
```lua
local world = jecs.World.new()
2025-02-19 18:35:02 +00:00
local pair = jecs.pair
2025-02-19 18:46:57 +00:00
local Position = world:component() :: jecs.Id< Vector3 >
local Velocity = world:component() :: jecs.Id< Vector3 >
2024-11-23 03:42:54 +00:00
2025-02-19 18:35:02 +00:00
-- These components and functions are actually already builtin
-- but have been illustrated for demonstration purposes
local ChildOf = world:component()
local Name = world:component()
2025-02-19 18:46:57 +00:00
local entity = world:entity()
world:set(entity, Position, Vector3.new(0, 0, 0))
world:set(entity, Velocity, Vector3.new(1, 0, 0))
2025-02-19 16:10:38 +00:00
2025-02-19 18:35:02 +00:00
local function parent(entity)
return world:target(entity, ChildOf)
2025-02-19 18:46:57 +00:00
-- Update system (example)
for id, position, velocity in world:query(Position, Velocity) do
world:set(id, Position, position + velocity)
2024-11-23 03:42:54 +00:00
end
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
local function getName(entity)
return world:get(entity, Name)
end
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
local alice = world:entity()
world:set(alice, Name, "alice")
2024-11-23 03:42:54 +00:00
2025-02-19 18:35:02 +00:00
local bob = world:entity()
world:add(bob, pair(ChildOf, alice))
world:set(bob, Name, "bob")
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
local sara = world:entity()
world:add(sara, pair(ChildOf, alice))
world:set(sara, Name, "sara")
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
print(getName(parent(sara)))
for e in world:query(pair(ChildOf, alice)) do
print(getName(e), "is the child of alice")
end
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
-- Output
-- "alice"
-- bob is the child of alice
-- sara is the child of alice
2024-11-23 03:42:54 +00:00
```
2025-02-19 18:35:02 +00:00
## ⚡ Performance
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
### Query Performance
21,000 entities, 125 archetypes, 4 random components queried:

*Benchmark source: /benches/visual/query.luau*
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
### Insertion Performance
Inserting 8 components to an entity and updating them over 50 times:

*Benchmark source: /benches/visual/insertions.luau*
2024-11-23 03:42:54 +00:00
2025-02-19 18:35:02 +00:00
## 📖 Documentation
2025-02-19 16:10:38 +00:00
2025-02-19 18:35:02 +00:00
- [Getting Started ](docs/learn/overview/get-started.md )
- [API Reference ](docs/api/jecs.md )
- [Examples ](examples/ )
- [Common Issues ](docs/learn/faq/common-issues.md )
2025-02-19 16:10:38 +00:00
2025-02-19 18:35:02 +00:00
## 🤝 Contributing
2025-02-19 16:10:38 +00:00
2025-02-19 18:35:02 +00:00
Please read our [Contributing Guidelines ](CONTRIBUTING.md ) before submitting pull requests.
2025-02-19 16:10:38 +00:00
2025-02-19 18:35:02 +00:00
## 💬 Community
2025-02-19 16:10:38 +00:00
2025-02-19 18:35:02 +00:00
- Join our [Discord ](https://discord.gg/h2NV8PqhAD )
- Report issues on [GitHub ](https://github.com/ukendio/jecs/issues )
2025-02-19 18:25:43 +00:00
2025-02-19 18:35:02 +00:00
## 📄 License
2025-02-19 18:26:50 +00:00
2025-02-19 18:46:57 +00:00
Jecs is licensed under the MIT License - see the [LICENSE ](LICENSE ) file for details.
```