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:
151
packages/rendering/mesh-3d/src/MeshComponent.ts
Normal file
151
packages/rendering/mesh-3d/src/MeshComponent.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* MeshComponent - 3D mesh rendering component.
|
||||
* MeshComponent - 3D 网格渲染组件。
|
||||
*/
|
||||
|
||||
import { Component, ECSComponent, Property, Serializable, Serialize } from '@esengine/ecs-framework';
|
||||
import { SortingLayers, type ISortable } from '@esengine/engine-core';
|
||||
import type { IGLTFAsset, IMeshData } from '@esengine/asset-system';
|
||||
|
||||
/**
|
||||
* 3D Mesh component for rendering GLTF models.
|
||||
* 用于渲染 GLTF 模型的 3D 网格组件。
|
||||
*
|
||||
* Requires TransformComponent for positioning and MeshRenderSystem for rendering.
|
||||
* 需要 TransformComponent 进行定位,MeshRenderSystem 进行渲染。
|
||||
*/
|
||||
@ECSComponent('Mesh', { requires: ['Transform'] })
|
||||
@Serializable({ version: 1, typeId: 'Mesh' })
|
||||
export class MeshComponent extends Component implements ISortable {
|
||||
/**
|
||||
* 模型资产 GUID
|
||||
* Model asset GUID
|
||||
*
|
||||
* Stores the unique identifier of the GLTF/GLB/OBJ/FBX model asset.
|
||||
* 存储 GLTF/GLB/OBJ/FBX 模型资产的唯一标识符。
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'asset', label: 'Model', assetType: 'any', extensions: ['.gltf', '.glb', '.obj', '.fbx'] })
|
||||
public modelGuid: string = '';
|
||||
|
||||
/**
|
||||
* 运行时网格数据(从资产加载)
|
||||
* Runtime mesh data (loaded from asset)
|
||||
*/
|
||||
public meshAsset: IGLTFAsset | null = null;
|
||||
|
||||
/**
|
||||
* 当前活动的网格索引(用于多网格模型)
|
||||
* Active mesh index (for multi-mesh models)
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'integer', label: 'Mesh Index', min: 0 })
|
||||
public meshIndex: number = 0;
|
||||
|
||||
/**
|
||||
* 是否投射阴影
|
||||
* Whether to cast shadows
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'boolean', label: 'Cast Shadows' })
|
||||
public castShadows: boolean = true;
|
||||
|
||||
/**
|
||||
* 是否接收阴影
|
||||
* Whether to receive shadows
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'boolean', label: 'Receive Shadows' })
|
||||
public receiveShadows: boolean = true;
|
||||
|
||||
/**
|
||||
* 可见性
|
||||
* Visibility
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'boolean', label: 'Visible' })
|
||||
public visible: boolean = true;
|
||||
|
||||
/**
|
||||
* 排序层(用于透明物体排序)
|
||||
* Sorting layer (for transparent object sorting)
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({
|
||||
type: 'enum',
|
||||
label: 'Sorting Layer',
|
||||
options: ['Background', 'Default', 'Foreground', 'WorldOverlay', 'UI', 'ScreenOverlay', 'Modal']
|
||||
})
|
||||
public sortingLayer: string = SortingLayers.Default;
|
||||
|
||||
/**
|
||||
* 层内排序顺序
|
||||
* Order in layer
|
||||
*/
|
||||
@Serialize()
|
||||
@Property({ type: 'integer', label: 'Order In Layer' })
|
||||
public orderInLayer: number = 0;
|
||||
|
||||
/**
|
||||
* 材质覆盖 GUID 列表(可选)
|
||||
* Material override GUIDs (optional)
|
||||
*/
|
||||
@Serialize()
|
||||
public materialOverrides: string[] = [];
|
||||
|
||||
/**
|
||||
* 运行时材质 ID 列表
|
||||
* Runtime material IDs
|
||||
*/
|
||||
public runtimeMaterialIds: number[] = [];
|
||||
|
||||
/**
|
||||
* 运行时纹理 ID 列表
|
||||
* Runtime texture IDs
|
||||
*/
|
||||
public runtimeTextureIds: number[] = [];
|
||||
|
||||
/**
|
||||
* 资产是否已加载
|
||||
* Whether asset is loaded
|
||||
*/
|
||||
public get isLoaded(): boolean {
|
||||
return this.meshAsset !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前网格数据
|
||||
* Get current mesh data
|
||||
*/
|
||||
public get currentMesh(): IMeshData | null {
|
||||
if (!this.meshAsset || !this.meshAsset.meshes.length) return null;
|
||||
const index = Math.min(this.meshIndex, this.meshAsset.meshes.length - 1);
|
||||
return this.meshAsset.meshes[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有网格数据
|
||||
* Get all mesh data
|
||||
*/
|
||||
public get allMeshes(): IMeshData[] {
|
||||
return this.meshAsset?.meshes ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置组件
|
||||
* Reset component
|
||||
*/
|
||||
reset(): void {
|
||||
this.modelGuid = '';
|
||||
this.meshAsset = null;
|
||||
this.meshIndex = 0;
|
||||
this.castShadows = true;
|
||||
this.receiveShadows = true;
|
||||
this.visible = true;
|
||||
this.sortingLayer = 'Default';
|
||||
this.orderInLayer = 0;
|
||||
this.materialOverrides = [];
|
||||
this.runtimeMaterialIds = [];
|
||||
this.runtimeTextureIds = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user