refactor: reorganize package structure and decouple framework packages (#338)
* 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
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Material asset loader.
|
||||
* 材质资产加载器。
|
||||
*/
|
||||
|
||||
import {
|
||||
AssetType,
|
||||
IAssetContent,
|
||||
IAssetParseContext
|
||||
} from '@esengine/asset-system';
|
||||
import type { IAssetLoader, AssetContentType } from '@esengine/asset-system';
|
||||
import { Material } from '../Material';
|
||||
|
||||
/**
|
||||
* Material asset data structure.
|
||||
* 材质资产数据结构。
|
||||
*/
|
||||
export interface IMaterialAssetData {
|
||||
/** Material instance. | 材质实例。 */
|
||||
material: Material;
|
||||
/** Material definition data. | 材质定义数据。 */
|
||||
definition: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Material file loader.
|
||||
* 材质文件加载器。
|
||||
*/
|
||||
export class MaterialLoader implements IAssetLoader<IMaterialAssetData> {
|
||||
readonly supportedType = AssetType.Material;
|
||||
readonly supportedExtensions = ['.mat'];
|
||||
readonly contentType: AssetContentType = 'text';
|
||||
|
||||
/**
|
||||
* Parse material from content.
|
||||
* 从内容解析材质。
|
||||
*/
|
||||
async parse(content: IAssetContent, context: IAssetParseContext): Promise<IMaterialAssetData> {
|
||||
if (!content.text) {
|
||||
throw new Error('Material content is empty');
|
||||
}
|
||||
|
||||
const data = JSON.parse(content.text);
|
||||
|
||||
// Support wrapper format: { material: {...} }
|
||||
const materialDef = data.material || data;
|
||||
|
||||
// Create material from definition.
|
||||
const material = Material.fromDefinition(materialDef);
|
||||
|
||||
return {
|
||||
material,
|
||||
definition: materialDef
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose material asset.
|
||||
* 释放材质资产。
|
||||
*/
|
||||
dispose(_asset: IMaterialAssetData): void {
|
||||
// Material cleanup if needed.
|
||||
}
|
||||
}
|
||||
87
packages/engine/material-system/src/loaders/ShaderLoader.ts
Normal file
87
packages/engine/material-system/src/loaders/ShaderLoader.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Shader asset loader.
|
||||
* 着色器资产加载器。
|
||||
*/
|
||||
|
||||
import {
|
||||
AssetType,
|
||||
IAssetContent,
|
||||
IAssetParseContext
|
||||
} from '@esengine/asset-system';
|
||||
import type { IAssetLoader, AssetContentType } from '@esengine/asset-system';
|
||||
import { Shader } from '../Shader';
|
||||
import type { ShaderDefinition } from '../types';
|
||||
|
||||
/**
|
||||
* Shader asset data structure.
|
||||
* 着色器资产数据结构。
|
||||
*/
|
||||
export interface IShaderAssetData {
|
||||
/** Shader instance. | 着色器实例。 */
|
||||
shader: Shader;
|
||||
/** Shader definition data. | 着色器定义数据。 */
|
||||
definition: ShaderDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shader file format.
|
||||
* 着色器文件格式。
|
||||
*
|
||||
* ```json
|
||||
* {
|
||||
* "version": 1,
|
||||
* "shader": {
|
||||
* "name": "CustomShader",
|
||||
* "vertexSource": "...",
|
||||
* "fragmentSource": "...",
|
||||
* "uniforms": { ... }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export interface ShaderFileFormat {
|
||||
version: number;
|
||||
shader: ShaderDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shader file loader.
|
||||
* 着色器文件加载器。
|
||||
*/
|
||||
export class ShaderLoader implements IAssetLoader<IShaderAssetData> {
|
||||
readonly supportedType = AssetType.Shader;
|
||||
readonly supportedExtensions = ['.shader'];
|
||||
readonly contentType: AssetContentType = 'text';
|
||||
|
||||
/**
|
||||
* Parse shader from content.
|
||||
* 从内容解析着色器。
|
||||
*/
|
||||
async parse(content: IAssetContent, context: IAssetParseContext): Promise<IShaderAssetData> {
|
||||
if (!content.text) {
|
||||
throw new Error('Shader content is empty');
|
||||
}
|
||||
|
||||
const data = JSON.parse(content.text) as ShaderFileFormat;
|
||||
|
||||
if (!data.shader) {
|
||||
throw new Error('Invalid shader file: missing shader definition');
|
||||
}
|
||||
|
||||
const shaderDef = data.shader;
|
||||
const shader = Shader.fromDefinition(shaderDef);
|
||||
|
||||
return {
|
||||
shader,
|
||||
definition: shaderDef
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose shader asset.
|
||||
* 释放着色器资产。
|
||||
*/
|
||||
dispose(_asset: IShaderAssetData): void {
|
||||
// Shader cleanup if needed.
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user