performance-at-scale
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePerformance at Scale
大规模场景下的性能优化
Spatial indexing and world streaming for large-scale building systems.
适用于大型建造系统的空间索引与世界流技术。
Quick Start
快速开始
javascript
import { SpatialHashGrid } from './scripts/spatial-hash-grid.js';
import { Octree } from './scripts/octree.js';
// Uniform distribution - use hash grid
const grid = new SpatialHashGrid(10);
grid.insert(piece, piece.position);
const nearby = grid.queryRadius(position, 15);
// Clustered bases - use octree
const octree = new Octree(bounds, { maxDepth: 8 });
octree.insert(piece);
const inBox = octree.queryBox(min, max);javascript
import { SpatialHashGrid } from './scripts/spatial-hash-grid.js';
import { Octree } from './scripts/octree.js';
// Uniform distribution - use hash grid
const grid = new SpatialHashGrid(10);
grid.insert(piece, piece.position);
const nearby = grid.queryRadius(position, 15);
// Clustered bases - use octree
const octree = new Octree(bounds, { maxDepth: 8 });
octree.insert(piece);
const inBox = octree.queryBox(min, max);Reference
参考文档
See for detailed guidance on:
references/performance-at-scale.md- Spatial partitioning selection (when to use grid vs octree)
- Chunk loading strategies
- Instancing and LOD
- Memory management
详见获取以下内容的详细指导:
references/performance-at-scale.md- 空间分区选择(何时使用网格 vs 八叉树)
- 区块加载策略
- 实例化与LOD
- 内存管理
Scripts
脚本文件
- - O(1) queries for uniform distribution
scripts/spatial-hash-grid.js - - Adaptive queries for clustered objects
scripts/octree.js - - World streaming for large maps
scripts/chunk-manager.js - - Benchmarking utilities
scripts/performance-profiler.js
- - 适用于均匀分布场景的O(1)复杂度查询
scripts/spatial-hash-grid.js - - 适用于聚集对象的自适应查询
scripts/octree.js - - 面向大型地图的世界流技术
scripts/chunk-manager.js - - 基准测试工具集
scripts/performance-profiler.js
Selection Guide
选型指南
| Pieces | Distribution | Use |
|---|---|---|
| <1,000 | Any | Array |
| 1-5k | Uniform | SpatialHashGrid |
| 1-5k | Clustered | Octree |
| 5k+ | Any | ChunkManager + Octree per chunk |
| 部件数量 | 分布情况 | 推荐使用 |
|---|---|---|
| <1,000 | 任意分布 | Array |
| 1-5k | 均匀分布 | SpatialHashGrid |
| 1-5k | 聚集分布 | Octree |
| 5k+ | 任意分布 | ChunkManager + 单区块Octree |