👾 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 support |
📈 Benchmarks
🚀 Unparalleled performance benchmarks
🔋 Powering
💿 Install
npm i bitecs
ℹ Resources
🕹 Example
import {
createWorld,
addEntity,
defineComponent,
addComponent,
defineQuery,
defineSystem,
Types,
} from 'bitecs'
const world = createWorld()
const Vector3 = { x: Types.f32, y: Types.f32, z: Types.f32 }
const Position = defineComponent(Vector3)
const Velocity = defineComponent(Vector3)
const eid = addEntity(world)
addComponent(world, Position, eid)
addComponent(world, Velocity, eid)
const movementSystem = defineSystem((world) => {
const ents = movementQuery(world)
for (let i = 0; i < ents.length; i++) {
const eid = ents[i]
Position.x[eid] += Velocity.x[eid]
Position.y[eid] += Velocity.y[eid]
Position.z[eid] += Velocity.z[eid]
}
})
setInterval(() => {
movementSystem(world)
}, 16)