feat(world-streaming): 添加世界流式加载系统 (#288)

实现基于区块的世界流式加载系统,支持开放世界游戏:

运行时包 (@esengine/world-streaming):
- ChunkComponent: 区块实体组件,包含坐标、边界、状态
- StreamingAnchorComponent: 流式锚点组件(玩家/摄像机)
- ChunkLoaderComponent: 流式加载配置组件
- ChunkStreamingSystem: 区块加载/卸载调度系统
- ChunkCullingSystem: 区块可见性剔除系统
- ChunkManager: 区块生命周期管理服务
- SpatialHashGrid: 空间哈希网格
- ChunkSerializer: 区块序列化

编辑器包 (@esengine/world-streaming-editor):
- ChunkVisualizer: 区块可视化覆盖层
- ChunkLoaderInspectorProvider: 区块加载器检视器
- StreamingAnchorInspectorProvider: 流式锚点检视器
- WorldStreamingPlugin: 完整插件导出
This commit is contained in:
YHH
2025-12-06 13:56:01 +08:00
committed by GitHub
parent 3cbfa1e4cb
commit 0c03b13d74
31 changed files with 2802 additions and 0 deletions

View File

@@ -0,0 +1,61 @@
import { Component, ECSComponent, Serializable, Serialize, Property } from '@esengine/ecs-framework';
/**
* 流式锚点组件
*
* Marks an entity as a streaming anchor point.
* Chunks are loaded/unloaded based on distance to anchors.
*
* 标记实体作为流式加载锚点。通常挂载在玩家或摄像机实体上,
* 系统会根据锚点位置加载/卸载周围区块。
*/
@ECSComponent('StreamingAnchor')
@Serializable({ version: 1, typeId: 'StreamingAnchor' })
export class StreamingAnchorComponent extends Component {
/**
* 锚点权重
*
* Weight multiplier for this anchor's load radius.
* Higher values mean larger load radius around this anchor.
*/
@Serialize()
@Property({ type: 'number', label: 'Weight', min: 0.1, max: 10 })
weight: number = 1.0;
/**
* 是否启用预加载
*
* Enable directional prefetching based on movement.
*/
@Serialize()
@Property({ type: 'boolean', label: 'Enable Prefetch' })
bEnablePrefetch: boolean = true;
/**
* 上一帧位置 X
*
* Previous frame X position for velocity calculation.
*/
previousX: number = 0;
/**
* 上一帧位置 Y
*
* Previous frame Y position for velocity calculation.
*/
previousY: number = 0;
/**
* 速度 X 分量
*
* X component of velocity (units per second).
*/
velocityX: number = 0;
/**
* 速度 Y 分量
*
* Y component of velocity (units per second).
*/
velocityY: number = 0;
}