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:
@@ -5,6 +5,7 @@ export interface ComponentTypeInfo {
|
||||
type?: new (...args: any[]) => Component;
|
||||
category?: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
metadata?: {
|
||||
path?: string;
|
||||
fileName?: string;
|
||||
|
||||
@@ -47,4 +47,4 @@ export class FieldEditorRegistry implements IFieldEditorRegistry, IService {
|
||||
this.editors.clear();
|
||||
logger.debug('FieldEditorRegistry disposed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,4 +42,4 @@ export interface FieldMetadata {
|
||||
multiline?: boolean;
|
||||
placeholder?: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,4 +27,4 @@ export interface IPropertyRendererRegistry {
|
||||
render(value: any, context: PropertyContext): ReactElement | null;
|
||||
getAllRenderers(): IPropertyRenderer[];
|
||||
hasRenderer(value: any, context: PropertyContext): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,22 @@
|
||||
import type { IService } from '@esengine/ecs-framework';
|
||||
import { Injectable, Component } from '@esengine/ecs-framework';
|
||||
import { Injectable, Component, getPropertyMetadata } from '@esengine/ecs-framework';
|
||||
import { createLogger } from '@esengine/ecs-framework';
|
||||
|
||||
const logger = createLogger('PropertyMetadata');
|
||||
|
||||
export type PropertyType = 'number' | 'string' | 'boolean' | 'color' | 'vector2' | 'vector3' | 'enum';
|
||||
export type PropertyType = 'number' | 'integer' | 'string' | 'boolean' | 'color' | 'vector2' | 'vector3' | 'enum' | 'asset' | 'animationClips';
|
||||
|
||||
export interface PropertyAction {
|
||||
id: string;
|
||||
label: string;
|
||||
tooltip?: string;
|
||||
icon?: string;
|
||||
}
|
||||
|
||||
export interface PropertyControl {
|
||||
component: string;
|
||||
property: string;
|
||||
}
|
||||
|
||||
export interface PropertyMetadata {
|
||||
type: PropertyType;
|
||||
@@ -14,6 +26,9 @@ export interface PropertyMetadata {
|
||||
step?: number;
|
||||
options?: Array<{ label: string; value: any }>;
|
||||
readOnly?: boolean;
|
||||
fileExtension?: string;
|
||||
actions?: PropertyAction[];
|
||||
controls?: PropertyControl[];
|
||||
}
|
||||
|
||||
export interface ComponentMetadata {
|
||||
@@ -48,36 +63,21 @@ export class PropertyMetadataService implements IService {
|
||||
* 获取组件的所有可编辑属性
|
||||
*/
|
||||
public getEditableProperties(component: Component): Record<string, PropertyMetadata> {
|
||||
const metadata = this.metadata.get(component.constructor as new (...args: any[]) => Component);
|
||||
if (!metadata) {
|
||||
return this.inferProperties(component);
|
||||
}
|
||||
return metadata.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推断组件属性(当没有明确元数据时)
|
||||
*/
|
||||
private inferProperties(component: Component): Record<string, PropertyMetadata> {
|
||||
const properties: Record<string, PropertyMetadata> = {};
|
||||
const componentAsAny = component as any;
|
||||
|
||||
for (const key in component) {
|
||||
if (component.hasOwnProperty(key)) {
|
||||
const value = componentAsAny[key];
|
||||
const type = typeof value;
|
||||
|
||||
if (type === 'number') {
|
||||
properties[key] = { type: 'number' };
|
||||
} else if (type === 'string') {
|
||||
properties[key] = { type: 'string' };
|
||||
} else if (type === 'boolean') {
|
||||
properties[key] = { type: 'boolean' };
|
||||
}
|
||||
}
|
||||
// 优先使用手动注册的元数据
|
||||
const registeredMetadata = this.metadata.get(component.constructor as new (...args: any[]) => Component);
|
||||
if (registeredMetadata) {
|
||||
return registeredMetadata.properties;
|
||||
}
|
||||
|
||||
return properties;
|
||||
// 然后尝试从装饰器获取元数据
|
||||
const decoratorMetadata = getPropertyMetadata(component.constructor);
|
||||
if (decoratorMetadata) {
|
||||
return decoratorMetadata as Record<string, PropertyMetadata>;
|
||||
}
|
||||
|
||||
// 没有元数据时返回空对象
|
||||
logger.warn(`No property metadata found for component: ${component.constructor.name}`);
|
||||
return {};
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
@@ -71,4 +71,4 @@ export class PropertyRendererRegistry implements IPropertyRendererRegistry, ISer
|
||||
this.renderers.clear();
|
||||
logger.debug('PropertyRendererRegistry disposed');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ export class WindowRegistry implements IService {
|
||||
* 通知所有监听器
|
||||
*/
|
||||
private notifyListeners(): void {
|
||||
this.listeners.forEach(listener => listener());
|
||||
this.listeners.forEach((listener) => listener());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user