| Crates.io | gltf_opt |
| lib.rs | gltf_opt |
| version | 0.1.6 |
| created_at | 2025-12-04 03:10:17.984052+00 |
| updated_at | 2025-12-30 14:32:11.104623+00 |
| description | Optimize glb file by resizing textures and adjusting pivot points |
| homepage | |
| repository | https://github.com/AllenDang/gltf_opt |
| max_upload_size | |
| id | 1965753 |
| size | 117,056 |
A Rust library for optimizing GLB (GL Transmission Format) files by resizing textures and optionally converting them to KTX2/Basis Universal format.
This library provides functionality to optimize GLB files by:
Add this to your Cargo.toml:
[dependencies]
gltf_opt = { git = "https://github.com/AllenDang/gltf_opt" }
use gltf_opt::prelude::*;
// Assuming you have a GLB file loaded into a reader
let mut reader = /* your GLB file reader */;
// Optimize the GLB file:
// - new_texture_size: Target size for textures (e.g., 512 for 512x512)
// - remove_normal_texture: Whether to remove normal textures
// - convert_to_ktx2: Whether to convert textures to KTX2/Basis Universal format
// - center_pivot: Whether to move pivot point to bottom center
let optimized_glb = optimize(&mut reader, 512, false, true, false)?;
// Save the optimized GLB to a file
std::fs::write("optimized.glb", optimized_glb)?;
new_texture_size: The target size for resizing textures (textures will be resized to new_texture_size x new_texture_size)remove_normal_texture: If true, normal textures will be removed from the modelconvert_to_ktx2: If true, textures will be converted to KTX2 format with Basis Universal compressioncenter_pivot: If true, the model's pivot point will be moved to the bottom center by modifying vertex positionscenter_pivot option is automatically ignored to prevent incorrect deformation. Texture optimization is still applied normally.MIT
Contributions are welcome! Please feel free to submit a Pull Request.