| Crates.io | gltf-v1-json |
| lib.rs | gltf-v1-json |
| version | 0.3.0 |
| created_at | 2025-02-11 02:38:39.651768+00 |
| updated_at | 2025-07-28 23:53:38.985649+00 |
| description | JSON Package for GLTF Spec 1.0 |
| homepage | |
| repository | https://github.com/crazyjackel/asset-importer-rs |
| max_upload_size | |
| id | 1550904 |
| size | 155,355 |

gltf-v1-json provides JSON serialization and deserialization for the glTF 1.0 specification. This crate is part of the asset-importer-rs project and implements the complete glTF 1.0 JSON schema with comprehensive validation support, enabling robust parsing and generation of glTF 1.0 files.
This crate provides the essential functionality for:


The following glTF 1.0 extensions are supported through feature flags:


Add the following to your Cargo.toml:
[dependencies]
gltf-v1-json = "0.3.0"
# Or for development from source:
gltf-v1-json = { path = "../path/to/gltf-v1-json" }
# Enable specific extensions
[features]
default = []
extensions = []
extras = []
KHR_binary_glTF = []
KHR_materials_common = []

Basic JSON deserialization example:
use gltf_v1_json::{
Root,
deserialize,
serialize,
};
// Deserialize from JSON string
let json_str = r#"{
"asset": { "version": "1.0" },
"scenes": [],
"meshes": []
}"#;
let gltf: Root = deserialize::from_str(json_str)?;
// Access glTF data
println!("glTF version: {}", gltf.asset.version);
println!("Number of scenes: {}", gltf.scenes.len());
JSON serialization example:
use gltf_v1_json::{Root, serialize};
// Create a glTF structure
let mut gltf = Root::default();
gltf.asset.version = "1.0".to_string();
// Serialize to JSON
let json = serialize::to_string_pretty(&gltf)?;
println!("Generated JSON:\n{}", json);
Working with extensions:
use gltf_v1_json::{Root, deserialize};
// Deserialize with extension support
let json_with_extensions = r#"{
"asset": { "version": "1.0" },
"extensionsUsed": ["KHR_materials_common"],
"materials": [{
"name": "material1",
"extensions": {
"KHR_materials_common": {
"technique": "BLINN",
"values": {
"ambient": [0.1, 0.1, 0.1],
"diffuse": [0.8, 0.8, 0.8]
}
}
}
}]
}"#;
let gltf: Root = deserialize::from_str(json_with_extensions)?;

The crate includes a robust validation system designed to ensure glTF 1.0 specification compliance and provide detailed error reporting for debugging and development.


This project is part of the asset-importer-rs workspace and follows its licensing terms. See the main project LICENSE file for details.
Copyright (c) 2024 Jackson Levitt