draco-rs
Rust bindings for the forked Draco library, providing efficient compression and decompression of 3D meshes and point clouds.
Features
- Encode and decode 3D geometry (meshes & point clouds)
- Safe, idiomatic Rust API built on autocxx
- Direct, low-overhead mapping to core Draco constructs
- Support for custom attributes and per-point data
Installation
Add draco-rs to your Cargo.toml:
[dependencies]
draco-rs = "x.x.x"
Quick Start
use draco_rs::{prelude::{*, ffi::draco::{GeometryAttribute_Type, DataType}}, pointcloud::*};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut builder = PointCloudBuilder::new(1);
let attr_id = builder.add_attribute(GeometryAttribute_Type::POSITION, 3, DataType::DT_FLOAT64);
builder.add_point(attr_id, 0, &[0.0f32, 1.0, 2.0]);
let cloud = builder.build(false);
let mut encoded = cloud.to_buffer(&mut Encoder::default())?;
let mut decoder_buffer = DecoderBuffer::from_encoder_buffer(&mut encoded);
let mut decoded = PointCloud::from_buffer(&mut Decoder::default(), &mut decoder_buffer)?;
assert_eq!(decoded.get_point_alloc::<f32, 3>(attr_id, 0), [0.0, 1.0, 2.0]);
Ok(())
}
License
Distributed under the MIT License. See LICENSE for details.