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,139 @@
.chunk-visualizer {
position: absolute;
pointer-events: none;
z-index: 100;
}
.chunk-visualizer-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
.chunk-grid-cell {
position: absolute;
box-sizing: border-box;
border: 1px solid rgba(100, 149, 237, 0.3);
transition: background-color 0.2s ease;
}
.chunk-grid-cell.loaded {
background-color: rgba(100, 149, 237, 0.1);
border-color: rgba(100, 149, 237, 0.5);
}
.chunk-grid-cell.loading {
background-color: rgba(255, 193, 7, 0.2);
border-color: rgba(255, 193, 7, 0.6);
animation: chunk-loading-pulse 1s ease-in-out infinite;
}
.chunk-grid-cell.unloading {
background-color: rgba(255, 87, 34, 0.2);
border-color: rgba(255, 87, 34, 0.5);
}
.chunk-grid-cell.failed {
background-color: rgba(244, 67, 54, 0.2);
border-color: rgba(244, 67, 54, 0.6);
}
.chunk-grid-cell.anchor-chunk {
border-color: rgba(76, 175, 80, 0.8);
border-width: 2px;
}
@keyframes chunk-loading-pulse {
0%, 100% { opacity: 0.5; }
50% { opacity: 1; }
}
.chunk-coord-label {
position: absolute;
top: 2px;
left: 2px;
font-size: 10px;
color: rgba(255, 255, 255, 0.6);
font-family: monospace;
pointer-events: none;
}
.anchor-marker {
position: absolute;
width: 12px;
height: 12px;
border-radius: 50%;
background-color: rgba(76, 175, 80, 0.8);
border: 2px solid #4caf50;
transform: translate(-50%, -50%);
z-index: 101;
}
.anchor-marker::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 4px;
height: 4px;
background-color: white;
border-radius: 50%;
transform: translate(-50%, -50%);
}
.load-radius-indicator {
position: absolute;
border: 2px dashed rgba(76, 175, 80, 0.5);
border-radius: 4px;
pointer-events: none;
}
.unload-radius-indicator {
position: absolute;
border: 1px dashed rgba(255, 87, 34, 0.3);
border-radius: 4px;
pointer-events: none;
}
.chunk-stats-panel {
position: absolute;
top: 8px;
right: 8px;
background: rgba(30, 30, 30, 0.9);
border: 1px solid #3e3e42;
border-radius: 4px;
padding: 8px 12px;
font-size: 11px;
color: #cccccc;
pointer-events: auto;
min-width: 140px;
}
.chunk-stats-panel h4 {
margin: 0 0 6px 0;
font-size: 12px;
color: #ffffff;
border-bottom: 1px solid #3e3e42;
padding-bottom: 4px;
}
.chunk-stats-row {
display: flex;
justify-content: space-between;
margin: 2px 0;
}
.chunk-stats-row .label {
color: #888888;
}
.chunk-stats-row .value {
font-family: monospace;
}
.chunk-stats-row .value.loaded { color: #64b5f6; }
.chunk-stats-row .value.loading { color: #ffc107; }
.chunk-stats-row .value.pending { color: #ff9800; }