| Crates.io | octaindex3d |
| lib.rs | octaindex3d |
| version | 0.5.2 |
| created_at | 2025-10-12 19:48:52.722339+00 |
| updated_at | 2026-01-13 17:54:56.390006+00 |
| description | 3D Spatial Indexing and Routing System based on BCC lattice with truncated octahedral cells |
| homepage | |
| repository | https://github.com/FunKite/OctaIndex3D |
| max_upload_size | |
| id | 1879627 |
| size | 18,681,780 |
A 3D Spatial Indexing and Routing System based on BCC Lattice
Documentation | Book | Crates.io | Examples | Changelog
This release refreshes core dependencies and tooling, including GPU backends and the Rust toolchain.
wgpu 28, metal 0.33, cudarc 0.18.2criterion, serde_json, glam, rkyv, zerocopy, bech32See the full Changelog for release history.
OctaIndex3D is a high-performance 3D spatial indexing and routing library based on a Body-Centered Cubic (BCC) lattice with truncated octahedral cells.
# Try the interactive 3D maze game (fastest way to experience BCC lattice!)
cargo install octaindex3d --features cli
octaindex3d play --difficulty medium
# Or use as a library
cargo add octaindex3d
For code examples and tutorials, see the OctaIndex3D Book:
Our system is built on a Body-Centered Cubic (BCC) lattice, which offers fundamental advantages over traditional grid-based systems for 3D spatial analysis.
The BCC lattice is the optimal structure for sampling three-dimensional signals. It achieves the same level of analytical fidelity with approximately 29% fewer data points than a standard cubic grid. This translates to significant reductions in memory usage, storage costs, and processing time for large-scale datasets, without sacrificing precision.
Spatial relationships in the real world are continuous, not confined to rigid, 90-degree angles. Our system's cells have 14 neighbors, a significant increase from the 6 offered by cubic cells. This near-uniform connectivity in all directions results in:
Every cell in our system is a truncated octahedron, a shape that tiles 3D space perfectly without gaps or overlaps. This guarantees a consistent and unambiguous topology, which is critical for:
Experience the power of BCC lattice pathfinding with our interactive 3D octahedral maze game! Navigate through procedurally-generated mazes using 14-neighbor connectivity and compete against optimal A* pathfinding.
# Install the CLI (requires 'cli' feature)
cargo install octaindex3d --features cli
# Play on medium difficulty
octaindex3d play --difficulty medium
# Try a specific seed (reproducible maze)
octaindex3d play --seed 42 --size 20
# View your competitive stats
octaindex3d stats
๐ฎ 3D Octahedral Maze Game - BCC Lattice Edition
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Maze: 20ร20ร20 | Seed: 42
Start: (0, 0, 0) โ Goal: (18, 18, 18)
Optimal moves: 18 | Your moves: 19 | Efficiency: 94.7%
Position: (10, 10, 10) | Distance to goal: 13.9
Available moves: 14 (full BCC connectivity)
[Navigate with arrow keys, W/S for Z-axis, Q to quit]
The game demonstrates real-world BCC lattice performance:
For a comprehensive demonstration of the algorithms powering the game:
# Run the BCC-14 Prim's โ A* showcase
cargo run --release --example bcc14_prim_astar_demo
# Features:
# - Builds spanning tree on 549K valid BCC nodes in 131ms
# - Solves optimal path with A* in 1ms
# - Comprehensive validation (5/5 checks)
# - Dynamic seeding with reproducible results
Add to your Cargo.toml:
[dependencies]
# Minimal installation
octaindex3d = "0.5"
# Recommended (includes common features)
octaindex3d = { version = "0.5", features = ["hilbert", "parallel", "container_v2"] }
# Full-featured (for advanced use cases)
octaindex3d = { version = "0.5", features = ["hilbert", "parallel", "container_v2", "gis_geojson", "zstd"] }
# Install the interactive maze game and utilities
cargo install octaindex3d --features cli
# Run the maze game
octaindex3d play --difficulty medium
# Explore other CLI commands
octaindex3d --help
| Feature | Enabled by Default | Description | When to Use |
|---|---|---|---|
serde |
โ Yes | Serialization support | Data persistence, JSON export |
parallel |
โ Yes | Multi-threaded batch operations (Rayon) | Processing 1000+ items |
simd |
โ Yes | SIMD acceleration (BMI2, AVX2, NEON) | Performance optimization |
lz4 |
โ Yes | LZ4 compression | Container storage |
hilbert |
No | Hilbert64 space-filling curve | Better spatial locality than Morton |
container_v2 |
No | Streaming container format | Append-friendly storage, large datasets |
gis_geojson |
No | GeoJSON export (WGS84) | GIS integration (QGIS, ArcGIS) |
cli |
No | Interactive maze game & CLI utilities | Interactive use, demos |
zstd |
No | Zstd compression (slower, better ratio) | High compression needs |
pathfinding |
No | Legacy pathfinding APIs | Compatibility with v0.2.x |
gpu-metal |
No | Metal GPU acceleration (macOS) | Massive batch operations (millions) |
gpu-cuda |
No | CUDA GPU acceleration (Linux) | Massive batch operations (millions) |
gpu-vulkan |
No | Vulkan GPU acceleration (experimental) | Experimental GPU support |
Recommended combinations:
# For general use
octaindex3d = { version = "0.5", features = ["hilbert", "parallel"] }
# For GIS applications
octaindex3d = { version = "0.5", features = ["hilbert", "parallel", "gis_geojson"] }
# For data storage systems
octaindex3d = { version = "0.5", features = ["hilbert", "parallel", "container_v2", "zstd"] }
# For interactive development
octaindex3d = { version = "0.5", features = ["cli"] }
git clone https://github.com/FunKite/OctaIndex3D
cd OctaIndex3D
cargo build --release
# Run tests
cargo test
# Run benchmarks
cargo bench
# Run the maze game
cargo run --release --features cli --bin octaindex3d -- play
OctaIndex3D provides three main capability areas:
For detailed code examples and tutorials, see the OctaIndex3D Book:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Galactic128 โ
โ 128-bit global ID with frame, tier, LOD, and coordinates โ
โ โโโโโโโโโโฌโโโโโโโฌโโโโโโฌโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Frame โ Tier โ LOD โ Attr โ Coordinates (90b) โ โ
โ โ 8 bits โ 2b โ 4b โ 24b โ X, Y, Z (30b each) โ โ
โ โโโโโโโโโโดโโโโโโโดโโโโโโดโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ HRP: g3d1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Index64 โ
โ 64-bit Morton-encoded spatial index (Z-order curve) โ
โ โโโโโโฌโโโโโโโโโฌโโโโโโโฌโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Hdrโ Frame โ Tier โ LOD โ Morton Code (48 bits ) โ โ
โ โ 2b โ 8 bits โ 2b โ 4b โ 16b/axis interleaved โ โ
โ โโโโโโดโโโโโโโโโดโโโโโโโดโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ HRP: i3d1 | BMI2 PDEP/PEXT optimized โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Route64 โ
โ 64-bit signed local routing coordinates โ
โ โโโโโโฌโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Hdrโ Parity โ X, Y, Z (20 bits each, signed) โ โ
โ โ 2b โ 2b โ ยฑ524k range per axis โ โ
โ โโโโโโดโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ HRP: r3d1 | Fast neighbor lookup โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Hilbert64 โ
โ 64-bit Hilbert curve spatial index (Gray code) โ
โ โโโโโโฌโโโโโโโโโฌโโโโโโโฌโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Hdrโ Frame โ Tier โ LOD โ Hilbert Code (48 bits) โ โ
โ โ 2b โ 8 bits โ 2b โ 4b โ Better locality โ โ
โ โโโโโโดโโโโโโโโโดโโโโโโโดโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ HRP: h3d1 | Requires 'hilbert' feature โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
(x + y + z) % 2 == 0 for all lattice pointsThe fastest way to experience BCC lattice pathfinding:
# Play the interactive 3D maze game
cargo run --release --features cli --bin octaindex3d -- play --difficulty medium
# Try specific challenges
cargo run --release --features cli --bin octaindex3d -- play --seed 42 --size 30
# View your stats
cargo run --release --features cli --bin octaindex3d -- stats
Run the comprehensive showcase example demonstrating the algorithms behind the game:
cargo run --release --example bcc14_prim_astar_demo
What it demonstrates:
Sample output:
๐ BCC-14 3D Graph: Randomized Prim's Algorithm โ A* Pathfinding
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Configuration
Extent: 130ร130ร130 (2,197,000 total, 549,450 valid BCC)
Seed: 42 ๐
Start: (0, 0, 0) โ Goal: (128, 128, 128)
BUILD: Prim's Algorithm
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Carved 549,450 nodes (100.0% coverage) in 131 ms
Performance: 4,194,656 nodes/sec | 11 MB memory
Validation: โ Tree structure valid (E = N-1)
SOLVE: A* Pathfinding
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Found path: 129 hops in 1 ms
Performance: 200,000 nodes/sec
Validation: โ All edges verified on spanning tree
use octaindex3d::{Route64, path::{astar, EuclideanCost}};
let start = Route64::new(0, 0, 0, 0)?;
let goal = Route64::new(0, 10, 10, 10)?;
// Use legacy pathfinding (from v0.2.0)
use octaindex3d::CellID;
let start_cell = CellID::from_coords(0, 5, 0, 0, 0)?;
let goal_cell = CellID::from_coords(0, 5, 10, 10, 10)?;
let path = astar(start_cell, goal_cell, &EuclideanCost)?;
println!("Path length: {} cells", path.len());
use octaindex3d::layer::{Layer, Aggregation};
// Create data layer (legacy API from v0.2.0)
let mut layer = Layer::new("temperature");
for cell in cells {
layer.set(cell, temperature_value);
}
// Aggregate over region
let mean_temp = layer.aggregate(®ion_cells, Aggregation::Mean)?;
// Roll up to coarser resolution
let coarse_layer = layer.rollup(Aggregation::Mean)?;
use octaindex3d::frame::{FrameDescriptor, register_frame};
// Register custom coordinate system
let frame = FrameDescriptor {
id: 1,
name: "LocalENU".to_string(),
description: "East-North-Up local frame".to_string(),
base_unit: 1.0, // meters
origin: [0.0, 0.0, 0.0],
srid: None,
};
register_frame(frame)?;
The container format provides efficient storage for spatial data with streaming support:
[Header] [Frame 1] [Frame 2] ... [TOC] [Footer]
Features:
Use Cases:
OctaIndex3D is optimized for modern CPU architectures with support for:
OctaIndex3D now provides a autonomous 3D mapping system with all the layers needed for real-world robotics applications:
| Layer | Purpose | Lines | Features |
|---|---|---|---|
| TSDF | Surface reconstruction | 410 | Signed distance fields, mesh extraction |
| ESDF | Distance fields | 398 | Euclidean distance, gradient computation |
| Occupancy | Probabilistic mapping | 541 | Bayesian log-odds, multi-sensor fusion |
| Temporal | Dynamic environments | 319 | Time-decayed occupancy, moving objects |
| Compressed | Memory efficiency | 346 | 89x compression with RLE |
| GPU | Ray casting acceleration | 248 | Metal + CUDA support |
| ROS2 | Robotics integration | 361 | Bridge for ROS2 middleware |
| Exploration | Autonomous navigation | 407 | Frontier detection, information gain, NBV |
| Mesh Export | Visualization | 398 | PLY/OBJ/STL formats |
Total: 3,428 lines of autonomous mapping infrastructure!
We provide building blocks rather than a complete exploration planner:
โ What We Provide
detect_frontiers() - Find unexplored boundariesinformation_gain_from() - Evaluate viewpoint qualitygenerate_viewpoint_candidates() - Sample observation posesโ What You Implement
next_best_view() - Depends on robot constraintsexploration_path() - Requires your path plannermulti_robot_planner() - Application-specificThis gives you flexibility, composability, and control over your exploration strategy.
Using these primitives, you can build various exploration strategies:
For complete working examples, see Chapter 10: Robotics & Autonomous Systems.
| Feature | OctaIndex3D (BCC) | H3 (Hexagonal) | S2 (Spherical) | Octree |
|---|---|---|---|---|
| Dimensionality | 3D | 2D (Earth surface) | 2D (Sphere) | 3D |
| Cell Shape | Truncated Octahedron | Hexagon | Spherical quad | Cube |
| Neighbors | 14 (uniform) | 6 | 4-8 (variable) | 6-26 |
| Isotropy | Excellent | Good | Excellent | Poor |
| Hierarchical | Yes (8:1) | Yes (7:1) | Yes (4:1) | Yes (8:1) |
| Space-Filling Curve | Morton/Hilbert | H3 | S2 Cell | Z-order |
| Efficiency vs Cubic | +29% | N/A | N/A | Baseline |
| Best For | 3D volumes | Geospatial 2D | Global spherical | Adaptive 3D |
| Rust Native | Yes | No (C bindings) | No (C++) | Various |
When to choose OctaIndex3D:
| Platform | Architecture | Status | SIMD | GPU |
|---|---|---|---|---|
| Linux | x86_64 | โ Full | BMI2, AVX2, AVX-512 | CUDA, Vulkan |
| Linux | aarch64 | โ Full | NEON | - |
| macOS | Apple Silicon (M1+) | โ Full | NEON | Metal |
| macOS | x86_64 | โ Full | BMI2, AVX2 | - |
| Windows | x86_64 | โ Full | BMI2, AVX2 | - |
Q: What is a BCC lattice? A: A Body-Centered Cubic lattice is a 3D crystal structure where each point has one point at the center of each cube. It's the optimal structure for sampling 3D space, requiring 29% fewer points than a cubic grid for the same fidelity.
Q: How does this compare to octrees? A: While octrees partition space hierarchically, OctaIndex3D uses a regular BCC lattice with truncated octahedral cells. This provides consistent topology, isotropic neighbor relationships, and efficient space-filling curves, making it better for uniform spatial indexing and pathfinding.
Q: Can I use this for 2D applications? A: While optimized for 3D, you can use OctaIndex3D for 2D by fixing one coordinate (e.g., z=0). However, dedicated 2D libraries like H3 may be more efficient for purely 2D use cases.
Q: What are the ID types used for? A:
hilbert feature)Q: Is this suitable for real-time applications? A: Yes! OctaIndex3D is designed for high performance with SIMD acceleration, hardware Morton encoding (BMI2), and efficient neighbor lookups. The maze game demonstrates real-time pathfinding on large graphs.
Q: Do I need a special CPU for good performance? A: No. OctaIndex3D works on any 64-bit CPU. However, modern CPUs with BMI2 (Intel Haswell 2013+, AMD Zen 2017+) get hardware-accelerated Morton encoding for 5-10x faster performance on encoding operations.
Q: Should I enable the parallel feature?
A: Yes, for batch operations on datasets with 1000+ items. The parallel feature (enabled by default) uses Rayon for multi-threaded processing.
Q: What about GPU acceleration? A: GPU features are optional and experimental. They're useful for massive batch operations (millions of points) but add complexity. Start with CPU features first.
Q: How do I convert between ID types?
A: Use the From/Into traits:
let index: Index64 = galactic128.try_into()?;
let hilbert: Hilbert64 = index.try_into()?;
let route: Route64 = index.try_into()?;
Q: How do I get a cell's neighbors? A: Use the neighbor functions:
use octaindex3d::neighbors::neighbors_route64;
let neighbors = neighbors_route64(route); // Returns Vec<Route64> with 14 neighbors
Q: Can I store custom data with cells?
A: Yes, use your own HashMap or spatial data structure with IDs as keys. For legacy code, see the Layer API in the documentation.
Issue: Build fails with "feature xyz not found"
Solution: Update your Cargo.toml to use the correct feature names. See Installation for available features.
Issue: CUDA build fails Solution: CUDA support requires CUDA 12.0+ and is only available on non-Windows platforms. Ensure you have CUDA toolkit installed:
# Ubuntu/Debian
sudo apt-get install nvidia-cuda-toolkit
# Verify
nvcc --version
Issue: Metal build fails on macOS Solution: Ensure you're using a Metal-capable macOS version (10.11+). Update Xcode command-line tools:
xcode-select --install
Issue: "Parity violation" error when creating coordinates
Solution: BCC lattice points must satisfy (x + y + z) % 2 == 0. Ensure your coordinates follow this constraint:
// Valid BCC points (even sum)
Route64::new(0, 0, 0, 0)?; // 0+0+0 = 0 โ
Route64::new(0, 1, 1, 0)?; // 1+1+0 = 2 โ
Route64::new(0, 2, 3, 1)?; // 2+3+1 = 6 โ
// Invalid (odd sum)
Route64::new(0, 1, 0, 0)?; // 1+0+0 = 1 โ Error!
Issue: Morton encoding seems slow
Solution: If you have a modern CPU (Intel Haswell 2013+ or AMD Zen 2017+), ensure the simd feature is enabled (it's on by default). Check if BMI2 is being used:
# Linux
lscpu | grep bmi2
# macOS
sysctl machdep.cpu.features | grep BMI2
Issue: Container v2 files won't open
Solution: Ensure you're using the container_v2 feature. V2 containers are incompatible with v0.2.x readers:
octaindex3d = { version = "0.5", features = ["container_v2"] }
Contributions are welcome! Please see our Contributing Guide for details on:
Feel free to:
Licensed under the MIT License. See LICENSE for details.
For comprehensive technical coverage, see the OctaIndex3D Book, which provides:
The book transforms theoretical foundations into practical guidance for building production systems.
Made with โค๏ธ and Rust