| Crates.io | draco-rs |
| lib.rs | draco-rs |
| version | 0.1.3 |
| created_at | 2025-04-23 13:28:31.217637+00 |
| updated_at | 2025-04-28 06:17:01.087151+00 |
| description | Rust-bindings to the c++ draco library, for compressing and decompressing 3D geometric meshes and point clouds. |
| homepage | |
| repository | https://github.com/soraxas/draco-rs |
| max_upload_size | |
| id | 1645513 |
| size | 3,190,871 |
Rust bindings for the forked Draco library, providing efficient compression and decompression of 3D meshes and point clouds.
Status: idiomatic Rust API will only be added on a as-needed basis. If you need to access some non-exposed draco API, call the wrapped_draco_obj.get_inner[_mut]() function to manipulate the underlying unique ptr.
Add draco-rs to your Cargo.toml:
[dependencies]
draco-rs = "x.x.x"
use draco_rs::{prelude::{*, ffi::draco::{GeometryAttribute_Type, DataType}}, pointcloud::*};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Build a point cloud with 3 components per point
let mut builder = PointCloudBuilder::new(1);
let attr_id = builder.add_attribute(GeometryAttribute_Type::POSITION, 3, DataType::DT_FLOAT32);
builder.add_point(attr_id, 0, &[0.0f32, 1.0, 2.0]);
let cloud = builder.build(false);
// Encode to a buffer
let mut encoded = cloud.to_buffer(&mut Encoder::default())?;
// note: the decoder buffer does not take ownership of the given buffer, so the buffer must be valid for the lifetime of the decode process.
let mut decoder_buffer = DecoderBuffer::from_encoder_buffer(&mut encoded);
// Decode back to a PointCloud
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(())
}
Distributed under the MIT License. See LICENSE for details.