Feature/Refactor to use ecs architecture (#14)
All checks were successful
Build and Publish Docker Image / Build and Validate (push) Successful in 7s
Build and Publish Docker Image / Publish to Registry (push) Successful in 9s

Reviewed-on: #14
Co-authored-by: Juan Sebastian Montoya <juansmm@outlook.com>
Co-committed-by: Juan Sebastian Montoya <juansmm@outlook.com>
This commit is contained in:
Juan Sebastián Montoya 2025-11-26 15:39:05 -05:00 committed by Juan Sebastián Montoya
parent e0436e7769
commit cec1fccc22
23 changed files with 1709 additions and 650 deletions

View file

@ -0,0 +1,28 @@
import { System } from '../ecs/System.js';
import { Transform } from '../components/Transform.js';
import { MeshComponent } from '../components/MeshComponent.js';
/**
* RenderSystem - syncs Three.js mesh positions with Transform components
*/
export class RenderSystem extends System {
constructor(scene) {
super();
this.scene = scene;
}
update(_deltaTime) {
const entities = this.getEntities(Transform, MeshComponent);
for (const entityId of entities) {
const transform = this.getComponent(entityId, Transform);
const meshComp = this.getComponent(entityId, MeshComponent);
// Sync mesh transform with component
meshComp.mesh.position.copy(transform.position);
meshComp.mesh.rotation.copy(transform.rotation);
meshComp.mesh.scale.copy(transform.scale);
}
}
}