Feature/render pipeline (#232)

* refactor(engine): 重构2D渲染管线坐标系统

* feat(engine): 完善2D渲染管线和编辑器视口功能

* feat(editor): 实现Viewport变换工具系统

* feat(editor): 优化Inspector渲染性能并修复Gizmo变换工具显示

* feat(editor): 实现Run on Device移动预览功能

* feat(editor): 添加组件属性控制和依赖关系系统

* feat(editor): 实现动画预览功能和优化SpriteAnimator编辑器

* feat(editor): 修复SpriteAnimator动画预览功能并迁移CI到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(editor): 修复SpriteAnimator动画预览并迁移到pnpm

* feat(ci): 迁移项目到pnpm并修复CI构建问题

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 迁移CI工作流到pnpm并添加WASM构建支持

* chore: 移除 network 相关包

* chore: 移除 network 相关包
This commit is contained in:
YHH
2025-11-23 14:49:37 +08:00
committed by GitHub
parent b15cbab313
commit a3f7cc38b1
247 changed files with 33561 additions and 52047 deletions

View File

@@ -0,0 +1,86 @@
import { EntitySystem, Matcher, ECSSystem, Time, Entity } from '@esengine/ecs-framework';
import { SpriteAnimatorComponent } from '../SpriteAnimatorComponent';
import { SpriteComponent } from '../SpriteComponent';
/**
* 精灵动画系统 - 更新所有精灵动画
* Sprite animator system - updates all sprite animations
*/
@ECSSystem('SpriteAnimator', { updateOrder: 50 })
export class SpriteAnimatorSystem extends EntitySystem {
constructor() {
super(Matcher.empty().all(SpriteAnimatorComponent));
}
/**
* 系统初始化时调用
* Called when system is initialized
*/
protected override onInitialize(): void {
// System initialized
}
/**
* 每帧开始时调用
* Called at the beginning of each frame
*/
protected override onBegin(): void {
// Frame begin
}
/**
* 处理匹配的实体
* Process matched entities
*/
protected override process(entities: readonly Entity[]): void {
const deltaTime = Time.deltaTime;
for (const entity of entities) {
if (!entity.enabled) continue;
const animator = entity.getComponent(SpriteAnimatorComponent) as SpriteAnimatorComponent | null;
if (!animator) continue;
// Only call update if playing
if (animator.isPlaying()) {
animator.update(deltaTime);
}
// Sync current frame to sprite component (always, even if not playing)
const sprite = entity.getComponent(SpriteComponent) as SpriteComponent | null;
if (sprite) {
const frame = animator.getCurrentFrame();
if (frame) {
sprite.texture = frame.texture;
// Update UV if specified
if (frame.uv) {
sprite.uv = frame.uv;
}
}
}
}
}
/**
* 实体添加到系统时调用
* Called when entity is added to system
*/
protected override onAdded(entity: Entity): void {
const animator = entity.getComponent(SpriteAnimatorComponent) as SpriteAnimatorComponent | null;
if (animator && animator.autoPlay && animator.defaultAnimation) {
animator.play();
}
}
/**
* 实体从系统移除时调用
* Called when entity is removed from system
*/
protected override onRemoved(entity: Entity): void {
const animator = entity.getComponent(SpriteAnimatorComponent) as SpriteAnimatorComponent | null;
if (animator) {
animator.stop();
}
}
}