Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/NateTheGreatt/bitECS
Functional, minimal, data-oriented, ultra-high performance ECS library written in JavaScript
https://github.com/NateTheGreatt/bitECS
ecs entitycomponentsystem functional game game-development game-engine gamedev high-performance particles
Last synced: about 1 month ago
JSON representation
Functional, minimal, data-oriented, ultra-high performance ECS library written in JavaScript
- Host: GitHub
- URL: https://github.com/NateTheGreatt/bitECS
- Owner: NateTheGreatt
- License: mpl-2.0
- Created: 2020-04-02T21:53:05.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-22T20:58:59.000Z (7 months ago)
- Last Synced: 2024-05-22T22:34:02.160Z (7 months ago)
- Topics: ecs, entitycomponentsystem, functional, game, game-development, game-engine, gamedev, high-performance, particles
- Language: JavaScript
- Homepage:
- Size: 1.98 MB
- Stars: 856
- Watchers: 23
- Forks: 74
- Open Issues: 37
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-game-engine-dev - bitECS - Functional, minimal, data-oriented, ultra-high performance ECS library. (Libraries / JavaScript)
- awesome-webxr-development - bitECS - Functional, minimal, data-oriented, ultra-high performance ECS library written using JavaScript TypedArrays (State Management / Visual Editor)
README
❤ ❤ ❤
bitECS
Functional, minimal, data-oriented, ultra-high performance ECS library written using JavaScript TypedArrays.## ✨ Features
| | |
| --------------------------------- | ---------------------------------------- |
| 🔮 Simple, declarative API | 🔥 Blazing fast iteration |
| 🔍 Powerful & performant queries | 💾 Serialization included |
| 🍃 Zero dependencies | 🌐 Node or browser |
| 🤏 `~5kb` minzipped | 🏷 TypeScript support |
| ❤ Made with love | 🔺 [glMatrix](https://github.com/toji/gl-matrix) support |### 📈 Benchmarks
| | |
| --------------------------------------------------------------- | ------------------------------------------------------------------------- |
| [noctjs/ecs-benchmark](https://github.com/noctjs/ecs-benchmark) | [ddmills/js-ecs-benchmarks](https://github.com/ddmills/js-ecs-benchmarks) |## 💿 Install
```
npm i bitecs
```## 📘 Documentation
| |
| ---------------- |
| 🏁 [Getting Started](https://github.com/NateTheGreatt/bitECS/blob/master/docs/INTRO.md) |
| 📑 [API](https://github.com/NateTheGreatt/bitECS/blob/master/docs/API.md) |
| ❔ [FAQ](https://github.com/NateTheGreatt/bitECS/blob/master/docs/FAQ.md) |
| 🏛 [Tutorial](https://github.com/ourcade/phaser3-bitecs-getting-started) |## 🕹 Example
```js
import {
createWorld,
Types,
defineComponent,
defineQuery,
addEntity,
addComponent,
pipe,
} from 'bitecs'const Vector3 = { x: Types.f32, y: Types.f32, z: Types.f32 }
const Position = defineComponent(Vector3)
const Velocity = defineComponent(Vector3)const movementQuery = defineQuery([Position, Velocity])
const movementSystem = (world) => {
const { time: { delta } } = world
const ents = movementQuery(world)
for (let i = 0; i < ents.length; i++) {
const eid = ents[i]
Position.x[eid] += Velocity.x[eid] * delta
Position.y[eid] += Velocity.y[eid] * delta
Position.z[eid] += Velocity.z[eid] * delta
}
return world
}const timeSystem = world => {
const { time } = world
const now = performance.now()
const delta = now - time.then
time.delta = delta
time.elapsed += delta
time.then = now
return world
}const pipeline = pipe(movementSystem, timeSystem)
const world = createWorld()
world.time = { delta: 0, elapsed: 0, then: performance.now() }const eid = addEntity(world)
addComponent(world, Position, eid)
addComponent(world, Velocity, eid)
Velocity.x[eid] = 1.23
Velocity.y[eid] = 1.23setInterval(() => {
pipeline(world)
}, 16)
```## 🔌 Powering