Skip to main content

Crate gltf_reader

Crate gltf_reader 

Source
Expand description

A simple glTF 2.0 reader using serde and serde_json. This crate is pretty much a 1:1 implementation of the glTF schema in Rust. It is purely structural and performs no validation of the glTF asset.

The structures try to borrow from the glTF JSON as much as possible. While not zero-copy, this crate is way more memory efficient than other glTF readers. You can still obtain an owned copy of any structure through into_owned methods, though.

All of the types implement Deserialize, which in theory allow them to be deserialized from any format. However, the only supported format intended is JSON through serde_json - anything else has no guarantees of working.

You can easily parse a glTF JSON string with Root::from_str, which is just a wrapper around serde_json::from_str.

§no-std

This is a no-std crate. It does, however, still require alloc.

Re-exports§

pub use serde_json;

Modules§

json
JSON types that show up in the parsed glTF structure.

Structs§

Accessor
A typed view into a buffer view that contains raw binary data.
AlphaMode
The alpha rendering mode of a material.
Animation
A keyframe animation.
AnimationSampler
An animation sampler combines timestamps with a sequence of output values and defines an interpolation algorithm.
Asset
Metadata about a glTF asset.
Attribute
A vertex attribute semantic.
Buffer
A buffer points to binary geometry, animation, or skins.
BufferView
A view into a buffer generally representing a subset of the buffer.
BufferViewTarget
A hint of the intended GPU buffer type to use with a buffer view.
Camera
A camera’s projection.
CameraType
Type of camera projection.
Channel
An animation channel combines an animation sampler with a target property being animated.
ChannelTarget
The descriptor of an animated property.
ComponentType
Data type of an accessor’s components.
ElementType
Data type of an accessor’s elements.
Extensions
JSON object with extension-specific objects.
Extras
Application-specific data.
Filter
Sampling filter.
Idx
A glTF index. Since pratically all structures in the crate have a lifetime that doesn’t matter for this type, it’s simply set to static - in practice, just ignore it.
Image
Image data used to create a texture.
Interpolation
Interpolation algorithm.
Material
The material appearence of a primitive.
Mesh
A set of primitives to be rendered.
MimeType
The image’s media type.
Mode
The topology type of a set primitives to render.
Node
A node in the node hierarchy.
NormalTextureInfo
Reference to a normal texture.
OcclusionTextureInfo
Reference to an occlusion texture.
Orthographic
An orthographic camera containing properties to create an orthographic projection matrix.
PbrMetallicRoughness
A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.
Perspective
A perspective camera containing properties to create a perspective projection matrix.
Primitive
A set of primitives to be rendered.
Property
The name of a node’s TRS property to animate, or the weights of the Morph Targets it instantiates.
Root
The root object of a glTF asset.
Sampler
Texture sampler properties for filtering and wrapping modes.
Scene
The root nodes of a scene.
Skin
Joints and matrices defining a skin.
Sparse
Sparse storage of accessor values that deviate from their initialization value.
SparseIndices
Sparse storage of accessor values that deviate from their initialization value.
SparseValues
An object pointing to a buffer view containing the deviating accessor values.
Texture
A texture and it’s sampler.
TextureInfo
Reference to a texture.
Wrap
Wrapping mode.

Enums§

AlphaModeEnum
glTF known alpha modes.
AttributeEnum
glTF known attribute semantics.
BufferViewTargetEnum
glTF known targets for buffer views.
CameraTypeEnum
glTF known types of camera projection.
ComponentTypeEnum
glTF known data types of an accessor’s components.
ElementTypeEnum
glTF known data types of an accessor’s elements.
FilterEnum
glTF known sampling filters.
InterpolationEnum
glTF known interpolation algorithms.
MimeTypeEnum
glTF known mime types.
ModeEnum
glTF known primitive topologies.
PropertyEnum
glTF known animation properties.
WrapEnum
glTF known wrapping modes.