mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
Update README.md
This commit is contained in:
parent
f5099d585a
commit
6c47df37a4
1 changed files with 66 additions and 33 deletions
99
README.md
99
README.md
|
@ -4,73 +4,105 @@
|
||||||
|
|
||||||
[](LICENSE) [](https://wally.run/package/ukendio/jecs)
|
[](LICENSE) [](https://wally.run/package/ukendio/jecs)
|
||||||
|
|
||||||
|
|
||||||
# Jecs - Just a Stupidly Fast ECS
|
# Jecs - Just a Stupidly Fast ECS
|
||||||
|
|
||||||
A high-performance Entity Component System (ECS) for Roblox games.
|
A high-performance Entity Component System (ECS) for Roblox games, supporting both Luau and TypeScript.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- 🚀 **Blazing Fast**: Iterate over 800,000 entities at 60 frames per second
|
* **Blazing Fast:** Iterate over hundreds of thousands of entities at 60 frames per second. Benchmark results are available in the documentation.
|
||||||
- 🔗 **Entity Relationships**: First-class support for [entity relationships](docs/learn/concepts/relationships.md)
|
* **Entity Relationships:** First-class support for defining and querying relationships between entities.
|
||||||
- 🔒 **Type Safety**: Fully typed API for both [Luau](https://luau-lang.org/) and TypeScript
|
* **Type Safety:** Fully typed API for both Luau and TypeScript, enhancing code maintainability and reducing errors.
|
||||||
- 📦 **Zero Dependencies**: No external dependencies required
|
* **Zero Dependencies:** No external dependencies required, simplifying integration into your project.
|
||||||
- ⚡ **Optimized Storage**: Cache-friendly [archetype/SoA](https://ajmmertens.medium.com/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9) storage
|
* **Optimized Storage:** Cache-friendly archetype/SoA (Structure of Arrays) storage for optimal performance.
|
||||||
- ✅ **Battle-tested**: Rigorously [unit tested](https://github.com/Ukendio/jecs/actions/workflows/ci.yaml) for stability
|
* **Battle-tested:** Rigorously unit tested for stability and reliability.
|
||||||
|
* **Comprehensive Documentation:** Detailed documentation guides you through installation, usage, and advanced concepts.
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
- [Getting Started](docs/learn/overview/get-started.md)
|
* [Getting Started](docs/learn/overview/get-started.md)
|
||||||
- [API Reference](docs/api/jecs.md)
|
* [API Reference](docs/api/jecs.md) (Note: This link may need updating to reflect the actual location of the API docs if they are generated separately)
|
||||||
- [Concepts](docs/learn/concepts/)
|
* [Concepts](docs/learn/concepts/)
|
||||||
- [Examples](examples/)
|
* Entities and Components
|
||||||
- [FAQ](docs/learn/faq/common-issues.md)
|
* Queries
|
||||||
|
* Relationships
|
||||||
|
* Component Traits
|
||||||
|
* Addons
|
||||||
|
* [Examples](examples/)
|
||||||
|
* [FAQ](docs/learn/faq/common-issues.md)
|
||||||
|
* [Contributing](docs/contributing/)
|
||||||
|
|
||||||
## Quick Example
|
|
||||||
|
## Quick Example (Luau)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local world = jecs.World.new()
|
local world = jecs.World.new()
|
||||||
local pair = jecs.pair
|
|
||||||
|
|
||||||
-- Define components
|
|
||||||
local Position = world:component() :: jecs.Entity<Vector3>
|
local Position = world:component() :: jecs.Entity<Vector3>
|
||||||
local Velocity = world:component() :: jecs.Entity<Vector3>
|
local Velocity = world:component() :: jecs.Entity<Vector3>
|
||||||
|
|
||||||
-- Create an entity
|
|
||||||
local entity = world:entity()
|
local entity = world:entity()
|
||||||
world:set(entity, Position, Vector3.new(0, 0, 0))
|
world:set(entity, Position, Vector3.new(0, 0, 0))
|
||||||
world:set(entity, Velocity, Vector3.new(1, 0, 0))
|
world:set(entity, Velocity, Vector3.new(1, 0, 0))
|
||||||
|
|
||||||
-- Update system
|
-- Update system (example)
|
||||||
for id, position, velocity in world:query(Position, Velocity) do
|
for id, position, velocity in world:query(Position, Velocity) do
|
||||||
world:set(id, Position, position + velocity)
|
world:set(id, Position, position + velocity)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Quick Example (TypeScript)
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { World } from "@rbxts/jecs";
|
||||||
|
|
||||||
|
const world = new World();
|
||||||
|
const Position = world.component<Vector3>();
|
||||||
|
const Velocity = world.component<Vector3>();
|
||||||
|
|
||||||
|
const entity = world.entity();
|
||||||
|
world.set(entity, Position, new Vector3(0, 0, 0));
|
||||||
|
world.set(entity, Velocity, new Vector3(1, 0, 0));
|
||||||
|
|
||||||
|
// Update system (example)
|
||||||
|
for (const [id, position, velocity] of world.query(Position, Velocity)) {
|
||||||
|
world.set(id, Position, position.add(velocity));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
|
|
||||||
### Query Performance
|
Benchmark results demonstrating Jecs' performance are available in the documentation. These include query and insertion performance tests.
|
||||||
21,000 entities, 125 archetypes, 4 random components queried:
|
|
||||||

|
|
||||||
|
|
||||||
### Insertion Performance
|
|
||||||
Inserting 8 components to an entity and updating them over 50 times:
|
|
||||||

|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
### Using Wally
|
### Using Wally (Luau)
|
||||||
|
|
||||||
|
Add Jecs to your `wally.toml`:
|
||||||
|
|
||||||
```toml
|
```toml
|
||||||
[dependencies]
|
[dependencies]
|
||||||
jecs = "ukendio/jecs@0.2.3"
|
jecs = "ukendio/jecs@0.2.3"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using npm (roblox-ts)
|
Then run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i @rbxts/jecs
|
wally install
|
||||||
```
|
```
|
||||||
|
|
||||||
### Standalone
|
### Using npm (Roblox-ts)
|
||||||
Download `jecs.rbxm` from our [releases page](https://github.com/Ukendio/jecs/releases).
|
|
||||||
|
```bash
|
||||||
|
npm install @rbxts/jecs
|
||||||
|
```
|
||||||
|
|
||||||
|
### Standalone Installation
|
||||||
|
|
||||||
|
1. Download `jecs.rbxm` from the [releases page](https://github.com/ukendio/jecs/releases).
|
||||||
|
2. Import it into your Roblox project.
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
@ -78,10 +110,11 @@ We welcome contributions! Please see our [contribution guidelines](docs/contribu
|
||||||
|
|
||||||
## Community & Support
|
## Community & Support
|
||||||
|
|
||||||
- [Discord Community](https://discord.gg/h2NV8PqhAD)
|
* [Discord Community](https://discord.gg/h2NV8PqhAD)
|
||||||
- [GitHub Issues](https://github.com/ukendio/jecs/issues)
|
* [GitHub Issues](https://github.com/ukendio/jecs/issues)
|
||||||
- [API Documentation](https://ukendio.github.io/jecs/)
|
* [API Documentation](https://ukendio.github.io/jecs/) (Note: This link may need updating)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Jecs is [MIT licensed](LICENSE).
|
Jecs is [MIT licensed](LICENSE).
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue