Odin bindings for Google's Draco 3D geometry compression library.
This package provides Odin bindings for decompressing Draco-compressed mesh data, commonly used in glTF files with the KHR_draco_mesh_compression extension.
- Just command runner
- Zig 0.13+ (for
zig build)
justThis will:
- Build the Draco static library with Zig
- Compile the C wrapper (
draco_c_wrapper.cc) with Zig - Install the combined
draco_wrapperlibrary intolib/draco_wrapper.lib
The built library is committed to the repository for easy use.
import draco "path/to/odin-draco"
// Create a decoder
decoder := draco.decoder_create()
defer draco.decoder_destroy(decoder)
// Decode mesh from buffer
mesh: draco.Draco_Mesh_Handle
result := draco.decode_mesh_from_buffer(decoder, data, data_size, &mesh)
defer draco.mesh_destroy(mesh)
if result.success {
// Access mesh data using draco.mesh_get_* functions
num_points := draco.mesh_get_num_points(mesh)
// ...
}See the renderer package in the parent repository for a higher-level wrapper example.
decoder_create()/decoder_destroy()- Create/destroy decoder instancesget_encoded_geometry_type()- Get geometry type without full decoding
decode_mesh_from_buffer()- Decode compressed mesh datamesh_destroy()- Destroy decoded mesh handle
mesh_get_num_points()- Get number of vertices/pointsmesh_get_num_faces()- Get number of triangular facesmesh_get_num_attributes()- Get total number of attributes
mesh_get_attribute_id_by_type()- Find first attribute by type (POSITION, NORMAL, etc.)mesh_get_attribute_id_by_type_index()- Find attribute by type and index (for multiple attributes of same type, e.g., TEXCOORD_0, TEXCOORD_1)mesh_get_num_attributes_by_type()- Count attributes of a specific typemesh_get_attribute_type()- Get attribute type (POSITION, NORMAL, etc.) from attribute IDmesh_get_attribute_num_components()- Get component count (e.g., 3 for vec3, 2 for vec2)mesh_get_attribute_data_type()- Get data type (Float32, UInt8, etc.)mesh_get_attribute_normalized()- Check if attribute values are normalizedmesh_get_attribute_data()- Extract attribute data as float32 arrays (currently only supports Float32 attributes)
mesh_get_face_indices()- Extract triangle face indices
Draco is licensed under the Apache License 2.0. See the draco submodule for details.