
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
ecstc (pronounced like "ecstasy") is a pure JS Entity Component System.
ecstc works on Worlds. Worlds are composed from Components and Systems:
import {Component, System, World} from 'ecstc';
const Components = {
Position2D: {
x: {type: 'float32'},
y: {type: 'float32'},
},
You may subclass Component for even more control:
Velocity2D: class extends Component {
We'll subclass the proxy to add a method.
static proxy(Proxy) {
return class extends super.proxy(Proxy) {
applyDamping() {
this.x *= 0.5;
this.y *= 0.5;
}
};
}
We'll also define the properties like above, this time as a static class member:
static properties = {
x: {type: 'float32'},
y: {type: 'float32'},
};
},
}
const Systems = {
Move: class extends System {
constructor(world) {
super(world);
This query selects all entities with both Position2D and Velocity2D components:
this.movements = this.query(['Position2D', 'Velocity2D']);
}
We select entities matching the query, do some basic physics integration on their positions, and then invoke the applyDamping method that we defined on velocities above.
tick({delta}) {
for (const {Position2D, Velocity2D} of this.movements.select()) {
Position2D.x += Velocity2D.x * delta;
Position2D.y += Velocity2D.y * delta;
Velocity2D.applyDamping();
}
}
},
};
const world = new World({Components, Systems});
const entity = world.create({
Position2D: {x: 10, y: 10},
});
Ticking this world won't update the position of the entity since it doesn't have a velocity:
world.tick(1);
assert(entity.Position2D.x === 10);
assert(entity.Position2D.y === 10);
We'll add a velocity and then tick the world thrice, which will integrate positions and apply velocity damping each time.
entity.AddComponent('Velocity2D', {x: 5, y: -2});
world.tick(1);
assert(entity.Position2D.x === 15); // 10 + 5
assert(entity.Position2D.y === 8); // 10 - 2
world.tick(1);
assert(entity.Position2D.x === 17.5); // 15 + 2.5
assert(entity.Position2D.y === 7); // 8 - 1
world.tick(1);
assert(entity.Position2D.x === 18.75); // 17.5 + 1.25
assert(entity.Position2D.y === 6.5); // 7 - 0.5
Now the entity will no longer be selected in the system query, so its position again won't change:
entity.removeComponent('Velocity2D');
world.tick(1);
assert(entity.Position2D.x === 18.75); // same as above
assert(entity.Position2D.y === 6.5); // ''
FAQs

We found that ecstc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.