mod3d_gltf/lib.rs
1/// A GLB file contains a 12-byte header; a chunk 0 (JSON); an optional
2/// chunk 1 (binary data)
3///
4/// The 12-byte header is 0x46546C67_u32 ; 0x00000002_u32; byte_length_u32
5///
6/// byte_length_u32 must equal the byte size of the GLB file content
7///
8/// Chunk 0 has an 8-byte header that is byte_length_u32; 0x4E4F534A_u32,
9/// followed by data
10///
11/// byte_length_u32 must equal the byte size of the data - must be a
12/// multiple of 4 bytes
13///
14/// Chunk 1 (optional) has an 8-byte header that is byte_length_u32;
15/// 0x004E4942_32, followed by data
16///
17/// byte_length_u32 must equal the byte size of the data - must be a
18/// multiple of 4 bytes
19///
20///
21/// A function is required that takes a GLB file and returns a Gltf Json
22/// Value and invokes a callback on the chunk 1 file data to get an
23/// Option<Vec<u8>> of chunk 1
24///
25/// A function is required that takes a Json file and returns a Gltf Json
26/// Value
27///
28/// A method on the Gltf Json Value is required that takes invokes
29/// callbacks for each buffer data in the file
30///
31/// A method on the Gltf Json Value is required that turns it into a Gltf
32/// descriptor
33///
34/// Methods are required on the Gltf descriptor that access the
35/// scenes; the default scene; the nodes by name; the skeletons; etc.
36///
37/// Methods are required that build an Object from a named node
38///
39/// GLTF notes
40///
41/// A GLTF file contains zero, one or more Scenes. If it has zero scenes
42/// then it is a 'library' of meshes or whatever; this is supported here.
43///
44/// Each scene consists of an array of *root* nodes (that is, nodes thare
45/// are never the children of other nodes). The same node may appear in
46/// more than one scene.
47///
48/// The GLTF file contains an array of nodes, but they actually form a set
49/// of node hierarchies. Each hierarchy has a single root and no cycles.
50/// Each node is part of a single hierarchy. The hierarchy is indicated by
51/// each parent node listing its children nodes by Gltf file node array
52/// index.
53///
54/// A node may have a transformation associated with it; if it does, then
55/// everything 'inside' the node uses the a coordinate system that is the
56/// transformation applied to its parent coordinate system. The parent
57/// coordinate system of a root node is the identity coordinate system.
58/// Except when a node is a *skinned mesh* - i.e. it explicitly has a
59/// *skin* field and hence also a *mesh* field; then its coordinate system
60/// is the identity coordinate system, with the (posed) joints having to
61/// provide any mapping of the mesh's coordinates to render coordinates.
62///
63/// A node *can* be a skinned mesh and a camera and a joint in a skeleton;
64/// the spec does not preclude this.
65///
66/// A Gltf skin defines a collection of nodes as a skeleton; these nodes
67/// must have a common ancestor in the node hierarchy (hence they must
68/// always be part of the same scene, since each node is part of a single
69/// tree and a scene contains trees). Optionally the gltf file specifies
70/// some idea of which common ancestor is the 'root' of the skeleton, but
71/// this is meaningless if it is not specified to also be a joint.
72///
73/// A Gltf file allows for a single pose for any one skeleton, as the pose
74/// is that specified by the joints that are in the skin. Since a skinned
75/// mesh is only positioned (in Gltf) by the positions of the associated
76/// joints, a skinned mesh cannot be instantiated into render space at more
77/// than one location in a scene.
78mod error;
79pub use error::{Error, Result};
80
81mod types;
82pub use types::*;
83
84mod traits;
85pub use traits::Named;
86
87#[cfg(feature = "serde_json")]
88mod glb;
89#[cfg(feature = "serde_json")]
90pub use glb::glb_load;
91
92mod asset;
93mod buffer_usage;
94mod buffers_accessors;
95mod image;
96mod material;
97mod node;
98mod primitives_meshes;
99mod scene;
100mod texture;
101
102#[cfg(feature = "serde")]
103mod deserialize;
104#[cfg(feature = "serde")]
105mod serialize;
106
107pub use asset::GltfAsset;
108pub(crate) use buffer_usage::BufferUsage;
109pub use buffers_accessors::{GltfAccessor, GltfBuffer, GltfBufferView};
110pub use image::GltfImage;
111pub use material::GltfMaterial;
112pub use node::GltfNode;
113pub use primitives_meshes::{GltfMesh, GltfPrimitive};
114pub use scene::GltfScene;
115pub use texture::{GltfTexture, GltfTextureInfo};
116
117mod utils;
118pub use utils::{buf_parse_fail, try_buf_parse_base64};
119
120mod gltf;
121pub use gltf::Gltf;
122
123mod object_data;
124pub use object_data::ObjectData;
125mod od_use;
126pub(crate) use od_use::ODUses;