* Spatial hash for a voxel coordinate. Uses a simple Cantor-like hash * to combine 3 integers into a single number for Map lookup.
(vx: number, vy: number, vz: number)
| 46 | * to combine 3 integers into a single number for Map lookup. |
| 47 | */ |
| 48 | function voxelHash(vx: number, vy: number, vz: number): number { |
| 49 | // Offset to handle negatives (shift by large number) |
| 50 | const ox = vx + 500000; |
| 51 | const oy = vy + 500000; |
| 52 | const oz = vz + 500000; |
| 53 | // Combine with prime multipliers — collisions are rare at 10cm resolution |
| 54 | return (ox * 73856093) ^ (oy * 19349663) ^ (oz * 83492791); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Height-based coloring: blue (ground) -> cyan -> green -> yellow -> red (high). |