Quecs, pronounced quicks, is an entity component sytem for JavaScript inspired by bitecs, ecsy and becsy.
const world = new World();
//define components
const Position = world.defineComponent({
x: Types.i16,
y: Types.i16,
});
const Player = world.defineComponent({});
// create entities
const {id: playerEid} = world.createEntity()
.addComponent(Position)
.addComponent(Player);
// set entity's component data
Position.x[playerEid] = 20;
Position.y[playerEid] = 10;
// define a query
const posQuery = world.defineQuery(Position);
// define a system
const moveHorizontalSystem = world => {
const eids = posQuery();
for(eid of eids) {
Position.x[eid] += 1;
}
}
//define a threaded system
const threadVerticleMoveSystem = threadedSystem([Position], (eids, [Position]) => {
for(const eid of eids) {
Position.y[eid] = 10;
}
})
// create a phase to contain the systems
const physPhase = world.createPhase('physics');
// create the pipeline
physPhase.addSystem(moveHorizontalSystem)
.addSystem(threadVerticleMoveSystem);
// run the phase
world.runPhase('physics');
- Creating entities
- Adding Components
- Remove Components
- Chain notation
- Defining Components with typed properties
- Defining Components with array properties
- Manages store size
- Single buffer for array properties
- Indexable sub views for array properties
- Define a phase
- Add systems to a phase
- Run the phase
- Define query
- Get entities from query
- Cache entities in query
- Not modifyer
- Function for threading system
- Check host environment to determine thread count and allocate worker pool
- Shared array buffers for easy worker access
- Entity subset threading (One thread runs a subset of entities against a system)
- Multi phase threading (One thread runs per Phase)