| Crates.io | draco_decoder |
| lib.rs | draco_decoder |
| version | 0.0.17 |
| created_at | 2025-08-10 14:53:00.282728+00 |
| updated_at | 2026-01-18 02:57:05.086763+00 |
| description | a draco decoder on rust (wip) |
| homepage | https://github.com/jiangheng90/draco_decoder |
| repository | https://github.com/jiangheng90/draco_decoder |
| max_upload_size | |
| id | 1788975 |
| size | 4,135,082 |
draco_decoder is a Rust library for decoding Draco compressed meshes. It provides native and WebAssembly (WASM) support with efficient bindings to the official Draco C++ library.
Native:
The native part uses cxx to create safe and ergonomic FFI bindings that directly connect to Draco's C++ decoding library. This allows efficient and zero-copy mesh decoding in native environments.
WASM:
For WebAssembly targets, draco_decoder leverages the official Draco Emscripten build. It uses a JavaScript Worker to run the Draco decoder asynchronously, enabling non-blocking mesh decoding in the browser. The JavaScript implementation is available in a separate repository:
https://github.com/jiangheng90/draco_decoder_js.git
This design provides a unified Rust API while seamlessly switching between native and WASM implementations under the hood.
install essential for draco build
cargo build
⚠️ Warning: This crate currently work in progress, I have not tested on many devices of building. now on windows it only support build on MSVC, and it may have some build issues.
use draco_decoder::{DracoDecodeConfig, AttributeDataType, decode_mesh};
// some async wrapper
let mut config = DracoDecodeConfig::new(vertex_count, index_count);
// Add attributes to decode (dimention and data type)
config.add_attribute(dim, AttributeDataType::Float32);
config.add_attribute(dim, AttributeDataType::Float32);
// Your Draco-encoded binary mesh data
let data: &[u8] = /* your Draco encoded data here */;
// Asynchronously decode the mesh data
let buf = decode_mesh(data, &config).await;
// wrapper end
The performance of draco_decoder has been measured under different environments:
| Environment | Typical Decoding Time |
|---|---|
| Native (Release Build) | 3 ms – 7 ms |
| WebAssembly (WASM) | 30 ms – 50 ms |