ugltf

Crates.iougltf
lib.rsugltf
version0.0.1-beta
created_at2026-01-09 11:24:30.477532+00
updated_at2026-01-09 11:24:30.477532+00
descriptionA small zero-copy zero-dependency lenient glTF parser, and also a JSON parser.
homepagehttps://codeberg.org/monomere/ugltf
repositoryhttps://codeberg.org/monomere/ugltf
max_upload_size
id2031944
size43,365
monomere (monomere)

documentation

README

ugltf

A small fully zero-copy zero-dependency lenient glTF parser, and also a JSON parser.

Will also be no_std in the near future.

Example usage:

let glb_data = std::fs::read("myfile.glb")?;

let glb = ugltf::Glb::read(&glb_data)?;

// We need mutability for the JSON part because of zero-copy.
let (json_data, bin_data) = glb_data.split_at_mut(
	glb.bin.unwrap().offset
);

let gltf_root = ugltf::ujson::parse(
	&mut json_data[glb.json.offset..]
)?;

let gltf_doc: ugltf::Document = ugltf::FromJson::from_json(&gltf_root);

for model in gltf_doc.models() {
	// ...
}

A reader for primitives similar to the gltf-rs one is also provided.

let reader = doc.primitive_reader(
	primitive,
	|buffer| Some(&buffers[buffer.as_raw()])
);

// We need 32-bit indices, even though the buffer might be 16-bit.
let indices = (0..reader.index_count())
	.map(|index| indices.at(index).unwrap())
	.collect::<Vec<_>>();

let vertices = (0..reader.position_count())
	.map(|index| {
			let position = positions.at(index).unwrap();
			let normal = normals.at(index).unwrap();
			let tangent = tangents.at(index).unwrap();
			let texcoord = texcoords.at(index).unwrap();
			MeshVertex {
				position: vek::Vec3::from(position.to_array()),
				normal: vek::Vec3::from(normal.to_array()),
				tangent: vek::Vec4::from(tangent.,to_array()),
				texcoord: vek::Vec2::from(texcoord.to_array()),
			}
	})
	.collect::<Vec<_>>();
Commit count: 1

cargo fmt