- Notifications
You must be signed in to change notification settings - Fork87
Flexible, minimal, data-oriented ECS library for Typescript
License
NotificationsYou must be signed in to change notification settings
NateTheGreatt/bitECS
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Functional, minimal,data-oriented, ultra-high performanceECS library written using JavaScript TypedArrays.
🔮 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 |
noctjs/ecs-benchmark | ddmills/js-ecs-benchmarks |
npm i bitecs
🏁Getting Started |
📑API |
❔FAQ |
🏛Tutorial |
import{createWorld,Types,defineComponent,defineQuery,addEntity,addComponent,pipe,}from'bitecs'constVector3={x:Types.f32,y:Types.f32,z:Types.f32}constPosition=defineComponent(Vector3)constVelocity=defineComponent(Vector3)constmovementQuery=defineQuery([Position,Velocity])constmovementSystem=(world)=>{const{time:{ delta}}=worldconstents=movementQuery(world)for(leti=0;i<ents.length;i++){consteid=ents[i]Position.x[eid]+=Velocity.x[eid]*deltaPosition.y[eid]+=Velocity.y[eid]*deltaPosition.z[eid]+=Velocity.z[eid]*delta}returnworld}consttimeSystem=world=>{const{ time}=worldconstnow=performance.now()constdelta=now-time.thentime.delta=deltatime.elapsed+=deltatime.then=nowreturnworld}constpipeline=pipe(movementSystem,timeSystem)constworld=createWorld()world.time={delta:0,elapsed:0,then:performance.now()}consteid=addEntity(world)addComponent(world,Position,eid)addComponent(world,Velocity,eid)Velocity.x[eid]=1.23Velocity.y[eid]=1.23setInterval(()=>{pipeline(world)},16)
About
Flexible, minimal, data-oriented ECS library for Typescript
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published