* refactor: reorganize package structure and decouple framework packages ## Package Structure Reorganization - Reorganized 55 packages into categorized subdirectories: - packages/framework/ - Generic framework (Laya/Cocos compatible) - packages/engine/ - ESEngine core modules - packages/rendering/ - Rendering modules (WASM dependent) - packages/physics/ - Physics modules - packages/streaming/ - World streaming - packages/network-ext/ - Network extensions - packages/editor/ - Editor framework and plugins - packages/rust/ - Rust WASM engine - packages/tools/ - Build tools and SDK ## Framework Package Decoupling - Decoupled behavior-tree and blueprint packages from ESEngine dependencies - Created abstracted interfaces (IBTAssetManager, IBehaviorTreeAssetContent) - ESEngine-specific code moved to esengine/ subpath exports - Framework packages now usable with Cocos/Laya without ESEngine ## CI Configuration - Updated CI to only type-check and lint framework packages - Added type-check:framework and lint:framework scripts ## Breaking Changes - Package import paths changed due to directory reorganization - ESEngine integrations now use subpath imports (e.g., '@esengine/behavior-tree/esengine') * fix: update es-engine file path after directory reorganization * docs: update README to focus on framework over engine * ci: only build framework packages, remove Rust/WASM dependencies * fix: remove esengine subpath from behavior-tree and blueprint builds ESEngine integration code will only be available in full engine builds. Framework packages are now purely engine-agnostic. * fix: move network-protocols to framework, build both in CI * fix: update workflow paths from packages/core to packages/framework/core * fix: exclude esengine folder from type-check in behavior-tree and blueprint * fix: update network tsconfig references to new paths * fix: add test:ci:framework to only test framework packages in CI * fix: only build core and math npm packages in CI * fix: exclude test files from CodeQL and fix string escaping security issue
141 lines
3.0 KiB
TypeScript
141 lines
3.0 KiB
TypeScript
import type { IRectangle } from '../utils/MathTypes';
|
||
import type { IRenderPrimitive } from './IRenderCollector';
|
||
|
||
/**
|
||
* Texture handle
|
||
* 纹理句柄
|
||
*/
|
||
export interface ITextureHandle {
|
||
/** Unique identifier | 唯一标识 */
|
||
readonly id: number;
|
||
/** Texture width | 纹理宽度 */
|
||
readonly width: number;
|
||
/** Texture height | 纹理高度 */
|
||
readonly height: number;
|
||
/** Is texture valid | 纹理是否有效 */
|
||
readonly isValid: boolean;
|
||
}
|
||
|
||
/**
|
||
* Font handle
|
||
* 字体句柄
|
||
*/
|
||
export interface IFontHandle {
|
||
/** Font family name | 字体名称 */
|
||
readonly family: string;
|
||
/** Is font loaded | 字体是否已加载 */
|
||
readonly isLoaded: boolean;
|
||
}
|
||
|
||
/**
|
||
* Render statistics
|
||
* 渲染统计
|
||
*/
|
||
export interface IRenderStats {
|
||
/** Draw call count | 绘制调用数 */
|
||
drawCalls: number;
|
||
/** Triangle count | 三角形数量 */
|
||
triangles: number;
|
||
/** Texture switches | 纹理切换次数 */
|
||
textureSwitches: number;
|
||
/** Batch count | 批次数量 */
|
||
batches: number;
|
||
/** Frame time in ms | 帧时间(毫秒) */
|
||
frameTime: number;
|
||
}
|
||
|
||
/**
|
||
* Render backend interface
|
||
*
|
||
* Abstract interface for graphics backend (WebGPU, WebGL, Canvas2D).
|
||
*
|
||
* 图形后端抽象接口(WebGPU、WebGL、Canvas2D)
|
||
*/
|
||
export interface IRenderBackend {
|
||
/** Backend name | 后端名称 */
|
||
readonly name: string;
|
||
|
||
/** Is backend initialized | 后端是否已初始化 */
|
||
readonly isInitialized: boolean;
|
||
|
||
/** Canvas width | 画布宽度 */
|
||
readonly width: number;
|
||
|
||
/** Canvas height | 画布高度 */
|
||
readonly height: number;
|
||
|
||
/**
|
||
* Initialize the backend
|
||
* 初始化后端
|
||
*/
|
||
initialize(canvas: HTMLCanvasElement): Promise<boolean>;
|
||
|
||
/**
|
||
* Begin a new frame
|
||
* 开始新帧
|
||
*/
|
||
beginFrame(): void;
|
||
|
||
/**
|
||
* End the current frame
|
||
* 结束当前帧
|
||
*/
|
||
endFrame(): void;
|
||
|
||
/**
|
||
* Submit render primitives for rendering
|
||
* 提交渲染图元进行渲染
|
||
*/
|
||
submitPrimitives(primitives: readonly IRenderPrimitive[]): void;
|
||
|
||
/**
|
||
* Set clip rectangle
|
||
* 设置裁剪矩形
|
||
*/
|
||
setClipRect(rect: IRectangle | null): void;
|
||
|
||
/**
|
||
* Create a texture from image data
|
||
* 从图像数据创建纹理
|
||
*/
|
||
createTexture(
|
||
source: ImageBitmap | HTMLImageElement | HTMLCanvasElement | ImageData
|
||
): ITextureHandle;
|
||
|
||
/**
|
||
* Destroy a texture
|
||
* 销毁纹理
|
||
*/
|
||
destroyTexture(texture: ITextureHandle): void;
|
||
|
||
/**
|
||
* Load a font
|
||
* 加载字体
|
||
*/
|
||
loadFont(family: string, url?: string): Promise<IFontHandle>;
|
||
|
||
/**
|
||
* Resize the backend
|
||
* 调整后端大小
|
||
*/
|
||
resize(width: number, height: number): void;
|
||
|
||
/**
|
||
* Get render statistics
|
||
* 获取渲染统计
|
||
*/
|
||
getStats(): IRenderStats;
|
||
|
||
/**
|
||
* Dispose the backend
|
||
* 销毁后端
|
||
*/
|
||
dispose(): void;
|
||
}
|
||
|
||
/**
|
||
* Backend factory function type
|
||
* 后端工厂函数类型
|
||
*/
|
||
export type RenderBackendFactory = () => IRenderBackend;
|