myth/lib.rs
1//! # Myth - A High-Performance WebGPU Rendering Engine
2//!
3//! Myth-Engine is a modern 3D rendering engine built with Rust and wgpu.
4//! It provides a flexible, high-performance foundation for real-time graphics applications.
5//!
6//! ## Quick Start
7//!
8//! ```rust,ignore
9//! use myth::prelude::*;
10//!
11//! struct MyApp;
12//!
13//! impl AppHandler for MyApp {
14//! fn init(engine: &mut Engine, window: &dyn Window) -> Self {
15//! let scene = engine.scene_manager.create_active();
16//! let geometry = Geometry::new_box(1.0, 1.0, 1.0);
17//! let material = Material::new_unlit(Vec4::new(1.0, 0.5, 0.2, 1.0));
18//! let mesh = Mesh::new(
19//! engine.assets.geometries.add(geometry),
20//! engine.assets.materials.add(material),
21//! );
22//! scene.add_mesh(mesh);
23//! let camera = Camera::new_perspective(60.0, 16.0/9.0, 0.1);
24//! let cam_node = scene.add_camera(camera);
25//! scene.active_camera = Some(cam_node);
26//! MyApp
27//! }
28//!
29//! fn update(&mut self, engine: &mut Engine, _: &dyn Window, frame: &FrameState) {
30//! // Update logic here
31//! }
32//! }
33//!
34//! fn main() -> myth::errors::Result<()> {
35//! App::new().with_title("My 3D App").run::<MyApp>()
36//! }
37//! ```
38//!
39//! ## Feature Flags
40//!
41//! | Feature | Default | Description |
42//! |---------|---------|-------------|
43//! | `winit` | **yes** | Window management via winit |
44//! | `gltf` | **yes** | glTF 2.0 model loading |
45//! | `http` | **yes** | HTTP asset loading (native only) |
46//! | `gltf-meshopt` | no | Meshopt decompression for glTF |
47//! | `debug_view` | no | Render graph debug view targets |
48//! | `rdg_inspector` | no | Render graph inspector |
49//!
50
51// ============================================================================
52// Sub-crate re-exports (facade modules matching the old monolith paths)
53// ============================================================================
54
55/// Error types and `Result` alias.
56pub mod errors {
57 pub use myth_core::errors::*;
58}
59
60/// Scene graph – nodes, cameras, lights, transforms.
61pub use myth_scene as scene;
62
63/// GPU resource definitions – geometry, material, texture, mesh, etc.
64pub use myth_resources as resources;
65
66/// Animation system – clips, mixers, tracks, skeletal / morph-target.
67pub use myth_animation as animation;
68
69/// Asset loading – server, storage, glTF loaders.
70pub use myth_assets as assets;
71
72/// Renderer internals – core, graph, pipeline.
73pub use myth_render as renderer;
74
75/// Application framework – engine, handlers, windowing.
76#[cfg(feature = "winit")]
77pub use myth_app as app;
78
79/// Engine core without windowing (always available even without `winit`).
80pub mod engine {
81 pub use myth_app::engine::*;
82}
83
84// ============================================================================
85// Local utilities (re-exports from sub-crates)
86// ============================================================================
87
88pub mod utils {
89 pub use myth_app::OrbitControls;
90 pub use myth_core::utils::FpsCounter;
91 pub mod fps_counter {
92 pub use myth_core::utils::FpsCounter;
93 }
94}
95
96// ============================================================================
97// Math module – re-exported glam types
98// ============================================================================
99
100pub mod math {
101 pub use glam::*;
102}
103
104// ============================================================================
105// Render module – high-level rendering API alias
106// ============================================================================
107
108pub mod render {
109 pub use myth_render::graph::{FrameComposer, RenderState};
110 pub use myth_render::renderer::Renderer;
111 pub use myth_render::settings::{RenderPath, RendererInitConfig, RendererSettings};
112
113 /// Low-level GPU context access.
114 pub mod core {
115 pub use myth_render::core::ResourceManager;
116 pub use myth_render::core::WgpuContext;
117 pub use myth_render::core::{BindingResource, Bindings, ResourceBuilder};
118 }
119}
120
121// ============================================================================
122// Prelude – common imports for everyday use
123// ============================================================================
124
125pub mod prelude {
126 // Application
127 #[cfg(feature = "winit")]
128 pub use myth_app::winit::App;
129 pub use myth_app::{AppHandler, Window};
130 pub use myth_app::{Engine, FrameState};
131
132 // Scene graph
133 pub use myth_core::{NodeHandle, SkeletonKey, Transform};
134 pub use myth_scene::camera::ProjectionType;
135 pub use myth_scene::{
136 BackgroundMapping, BackgroundMode, BackgroundSettings, Camera, Light, LightKind, Node,
137 Scene, SceneLogic, SceneNode,
138 };
139
140 // Resources
141 pub use myth_resources::{
142 AlphaMode, BloomSettings, FxaaQuality, FxaaSettings, Geometry, Image, Material,
143 MaterialType, Mesh, PhongMaterial, PhysicalMaterial, Side, SsaoSettings, TaaSettings,
144 Texture, TextureSlot, UnlitMaterial,
145 };
146
147 // Assets
148 pub use myth_assets::ColorSpace;
149 pub use myth_assets::SceneExt;
150 #[cfg(feature = "gltf")]
151 pub use myth_assets::loaders::gltf::GltfLoader;
152 pub use myth_assets::{AssetServer, GeometryHandle, MaterialHandle, TextureHandle};
153
154 // Animation
155 pub use myth_animation::{
156 AnimationAction, AnimationClip, AnimationEvent, AnimationMixer, ClipBinding, FiredEvent,
157 LoopMode, Rig,
158 };
159
160 // Math
161 pub use glam::{Affine3A, EulerRot, Mat3, Mat4, Quat, Vec2, Vec3, Vec4};
162
163 // Utilities
164 pub use myth_app::OrbitControls;
165
166 // Renderer
167 #[cfg(feature = "debug_view")]
168 pub use myth_render::graph::DebugViewTarget;
169 pub use myth_render::graph::FrameComposer;
170 pub use myth_render::settings::{
171 AntiAliasingMode, RenderPath, RendererInitConfig, RendererSettings,
172 };
173}
174
175// ============================================================================
176// Top-level re-exports for convenience
177// ============================================================================
178
179// Application
180#[cfg(feature = "winit")]
181pub use myth_app::winit::App;
182pub use myth_app::{AppHandler, Window};
183pub use myth_app::{Engine, FrameState};
184
185// Scene
186pub use myth_core::{NodeHandle, Transform};
187pub use myth_scene::{
188 BackgroundMapping, BackgroundMode, BackgroundSettings, Camera, Light, Node, Scene,
189};
190
191// Resources
192pub use myth_resources::primitives::{
193 PlaneOptions, SphereOptions, create_box, create_plane, create_sphere,
194};
195pub use myth_resources::{
196 AlphaMode, AntiAliasingMode, Attribute, FxaaQuality, FxaaSettings, Geometry, Image,
197 IndexFormat, Material, MaterialTrait, MaterialType, Mesh, PhongMaterial, PhysicalMaterial,
198 RenderableMaterialTrait, ShaderDefines, Side, TaaSettings, Texture, TextureSlot,
199 TextureTransform, ToneMappingMode, ToneMappingSettings, UnlitMaterial, VertexFormat,
200};
201
202// Assets
203pub use myth_assets::{AssetServer, GeometryHandle, MaterialHandle, TextureHandle};
204pub use myth_assets::{ColorSpace, GeometryQuery, ResolveGeometry, ResolveMaterial, SceneExt};
205
206// Animation
207pub use myth_animation::{
208 AnimationAction, AnimationClip, AnimationEvent, AnimationMixer, AnimationSystem, Binder,
209 ClipBinding, FiredEvent, InterpolationMode, LoopMode, Rig, Track, TrackBinding, TrackData,
210 TrackMeta,
211};
212
213// Renderer
214pub use myth_render::Renderer;
215pub use myth_render::graph::FrameComposer;
216pub use myth_render::settings::{RenderPath, RendererInitConfig, RendererSettings};
217
218// Errors
219pub use myth_core::{AssetError, Error, PlatformError, RenderError, Result};
220
221// Utilities
222pub use myth_app::OrbitControls;
223pub use myth_core::utils::interner;