mesh_tools/
lib.rs

1//! # mesh-tools: A Rust library for exporting glTF/GLB files
2//!
3//! This library provides a high-level API for creating and exporting 3D models in the
4//! [glTF](https://www.khronos.org/gltf/) (GL Transmission Format) standard, which is a 
5//! JSON-based format for 3D scenes and models, widely used for efficient transmission and loading 
6//! of 3D content.
7//!
8//! ## Key Features
9//! 
10//! - Create and manipulate 3D geometry (vertices, normals, UVs, indices)
11//! - Generate primitive shapes (boxes, spheres, planes, cylinders, etc.)
12//! - Define materials with physically-based rendering (PBR) properties
13//! - Support for textures and image data
14//! - Create complex hierarchical scenes with node parent-child relationships
15//! - Export models in both glTF (JSON+binary) and GLB (single binary) formats
16//!
17//! ## Basic Usage
18//!
19//! ```rust
20//! use mesh_tools::GltfBuilder;
21//!
22//! // Create a new glTF builder
23//! let mut builder = GltfBuilder::new();
24//!
25//! // Create a simple box mesh
26//! let box_mesh = builder.create_box(1.0);
27//!
28//! // Add a node referencing the mesh
29//! let node = builder.add_node(
30//!     Some("Box".to_string()),
31//!     Some(box_mesh),
32//!     None, // Default position
33//!     None, // Default rotation
34//!     None, // Default scale
35//! );
36//!
37//! // Create a scene containing the node
38//! builder.add_scene(Some("Main Scene".to_string()), Some(vec![node]));
39//!
40//! // Export to GLB format
41//! builder.export_glb("output.glb").unwrap();
42//! ```
43//!
44//! See the examples directory for more complex usage scenarios.
45
46// Public modules
47pub mod texture;     // Texture and image handling
48pub mod primitives;  // Geometry generation primitives
49pub mod error;       // Error types and results
50pub mod models;      // glTF data model definitions
51pub mod constants;   // glTF format constants
52pub mod material;    // Material creation and management
53pub mod mesh;        // Mesh creation and manipulation
54pub mod builder;     // Main GltfBuilder implementation
55
56// Internal implementation modules
57mod builder_primitives;  // Implementations for primitive shape creation
58mod builder_texture;     // Implementations for texture handling
59mod builder_material;    // Implementations for material handling
60
61// Re-exports
62pub use error::{GltfError, Result};
63pub use models::*;
64pub use builder::GltfBuilder;
65pub use builder_primitives::Triangle;
66
67// Constants re-exports
68pub use constants::accessor_type;
69pub use constants::buffer_view_target;
70pub use constants::component_type;
71pub use constants::sampler_filter;
72pub use constants::sampler_wrap;
73pub use constants::alpha_mode;
74pub use constants::primitive_mode;