primitive meshes

This commit is contained in:
Jérôme Bousquié
2026-09-24 14:25:44 +02:00
parent 805babe53d
commit ab3f056dbb
36 changed files with 1531 additions and 808 deletions
+58
View File
@@ -0,0 +1,58 @@
//! # Mesh module — geometry sources for WSG
//!
//! This module is the single entry point for **where geometry data comes from**:
//!
//! - **`primitives`** — procedural generators (cube, sphere, torus, …), each behind a
//! feature flag so you only compile what you need.
//! - **`import`** — file loaders (OBJ, glTF), each behind a feature flag.
//!
//! All sources produce a [`Geometry`] (CPU-side vertex data: positions, normals, UVs,
//! indices). Turning that into a GPU renderable is the job of [`crate::scene::Scene::add_mesh`].
//!
//! ## Usage
//!
//! ```rust
//! use wsg_lib::mesh::cube;
//!
//! // Procedural (feature "prim-cube")
//! let geom = cube(2.0);
//! assert_eq!(geom.positions.len(), 24);
//! ```
//!
//! ## Features
//!
//! | Feature | Provides |
//! |---------|----------|
//! | `prim-cube` | `cube(size)` |
//! | `prim-sphere` | `uv_sphere(…)`, `icosphere(…)` |
//! | `prim-cylinder` | `cylinder(…)` |
//! | `prim-cone` | `cone(…)` |
//! | `prim-torus` | `torus(…)` |
//! | `prim-plane` | `plane(…)` |
//! | `all-prims` | all of the above |
//! | `import-obj` | `load_obj(path)` |
//! | `import-gltf` | `load_gltf(path)` |
pub mod primitives;
#[cfg(feature = "import-obj")]
pub mod import;
// Flat re-exports at the `wsg::mesh` level for convenience.
#[cfg(feature = "prim-cube")]
pub use primitives::cube;
#[cfg(feature = "prim-plane")]
pub use primitives::plane;
#[cfg(feature = "prim-sphere")]
pub use primitives::{icosphere, uv_sphere};
#[cfg(feature = "prim-cylinder")]
pub use primitives::cylinder;
#[cfg(feature = "prim-cone")]
pub use primitives::cone;
#[cfg(feature = "prim-torus")]
pub use primitives::torus;
#[cfg(feature = "import-obj")]
pub use import::load_obj;
#[cfg(feature = "import-gltf")]
pub use import::load_gltf;