performance-at-scale

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Performance 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
references/performance-at-scale.md
for detailed guidance on:
  • 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

脚本文件

  • scripts/spatial-hash-grid.js
    - O(1) queries for uniform distribution
  • scripts/octree.js
    - Adaptive queries for clustered objects
  • scripts/chunk-manager.js
    - World streaming for large maps
  • scripts/performance-profiler.js
    - Benchmarking utilities
  • scripts/spatial-hash-grid.js
    - 适用于均匀分布场景的O(1)复杂度查询
  • scripts/octree.js
    - 适用于聚集对象的自适应查询
  • scripts/chunk-manager.js
    - 面向大型地图的世界流技术
  • scripts/performance-profiler.js
    - 基准测试工具集

Selection Guide

选型指南

PiecesDistributionUse
<1,000AnyArray
1-5kUniformSpatialHashGrid
1-5kClusteredOctree
5k+AnyChunkManager + Octree per chunk
部件数量分布情况推荐使用
<1,000任意分布Array
1-5k均匀分布SpatialHashGrid
1-5k聚集分布Octree
5k+任意分布ChunkManager + 单区块Octree