Vertecs
Vertecs (Word contraction of Vertex and ECS) is a robust TypeScript library designed around the ECS (Entity Component System) pattern. It's tailored for game development and beyond.
🚀 Features
- Three.js Integration: Render any Three.js object seamlessly.
- Prefabs: Easily instantiate entities multiple times.
- System Dependencies: Define dependencies between systems for ordered updates.
- Networking: Built-in networking system using Websockets for real-time synchronization.
📦 Installation
npm install vertecs
🎮 Getting Started
1. Create a Component
import { Component } from "vertecs";
export default class PositionComponent extends Component {
public x: number;
public y: number;
public constructor(x: number, y: number) {
super();
this.x = x;
this.y = y;
}
}
2. Define a System
import { System } from "vertecs";
import PositionComponent from "./PositionComponent";
export default class PositionSystem extends System<[PositionComponent]> {
public constructor() {
super([PositionComponent], 60);
}
public onLoop(components: [PositionComponent][], entities: Entity[], deltaTime: number) {
for (let i = 0; i < components.length; i++) {
const [positionComponent] = components[i];
positionComponent.x += 1 * deltaTime;
console.log("Position:", positionComponent.x, positionComponent.y);
}
}
}
3. Integrate with ECS Manager
import { SystemManager, Entity, EcsManager } from "vertecs";
import { PositionComponent } from "./PositionComponent";
import { PositionSystem } from "./PositionSystem";
const ecsManager = new EcsManager();
ecsManager.addSystem(new PositionSystem());
const entity = new Entity();
entity.addComponent(new PositionComponent(0, 0));
ecsManager.addEntity(entity)
ecsManager.start(); // -> Position: .., ..
🎨 Examples
Explore the examples folder for practical implementations of Vertecs. To run:
- Clone the repository.
- Install dependencies with
npm install
. - Build examples using
npm run build:examples
. - Open the .html files in the examples folder with your browser.
🤝 Contributing
Contributions, issues and feature requests are all welcome !
To contribute :
- Fork the repository.
- Create your feature branch (git checkout -b feature/YourFeatureName).
- Commit your changes.
- Push to the branch (git push origin feature/YourFeatureName).
- Open a pull request.
Pull requests must follow the conventional commits specification.
📜 License
This project is licensed under the MIT License - see the LICENSE file for details.