| 15 | * 提供世界流式加载功能的运行时模块。 |
| 16 | */ |
| 17 | export class WorldStreamingModule implements IRuntimeModule { |
| 18 | private _chunkManager: ChunkManager | null = null; |
| 19 | |
| 20 | get chunkManager(): ChunkManager | null { |
| 21 | return this._chunkManager; |
| 22 | } |
| 23 | |
| 24 | registerComponents(registry: IComponentRegistry): void { |
| 25 | registry.register(ChunkComponent); |
| 26 | registry.register(StreamingAnchorComponent); |
| 27 | registry.register(ChunkLoaderComponent); |
| 28 | } |
| 29 | |
| 30 | registerServices(services: ServiceContainer): void { |
| 31 | this._chunkManager = new ChunkManager(); |
| 32 | services.registerInstance(ChunkManager, this._chunkManager); |
| 33 | } |
| 34 | |
| 35 | createSystems(scene: IScene, _context: SystemContext): void { |
| 36 | const streamingSystem = new ChunkStreamingSystem(); |
| 37 | if (this._chunkManager) { |
| 38 | streamingSystem.setChunkManager(this._chunkManager); |
| 39 | } |
| 40 | scene.addSystem(streamingSystem); |
| 41 | scene.addSystem(new ChunkCullingSystem()); |
| 42 | } |
| 43 | |
| 44 | onSystemsCreated(_scene: IScene, _context: SystemContext): void { |
| 45 | // No post-creation setup needed |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | export const worldStreamingModule = new WorldStreamingModule(); |
nothing calls this directly
no outgoing calls
no test coverage detected