Skip to main content

oxihuman_viewer/
lib.rs

1// Copyright (C) 2026 COOLJAPAN OU (Team KitaSan)
2// SPDX-License-Identifier: Apache-2.0
3
4//! Real-time viewer for OxiHuman meshes.
5//!
6//! This crate provides the data structures and (when the `webgpu` feature is
7//! enabled) the wgpu render loop for previewing morphed human meshes in a
8//! window or headless surface. The public API is intentionally thin: most
9//! downstream consumers will use the [`Viewer`] facade and the
10//! [`ViewerConfig`] configuration struct.
11//!
12//! # Architecture
13//!
14//! - [`Scene`] / [`SceneNode`] — a lightweight scene graph with transforms and lights.
15//! - [`RenderPipelineDescriptor`] — describes vertex layout, blend state, depth/stencil, and cull mode.
16//! - [`CameraState`] — orbit camera with pan/zoom.
17//! - [`MeshUploadBuffer`] — staging buffer for GPU mesh data.
18//! - [`Viewer`] — top-level render loop (stub; wgpu integration in Phase 2).
19//!
20//! # Feature flags
21//!
22//! | Flag | Effect |
23//! |---|---|
24//! | `webgpu` (default off) | Enables full wgpu rendering via `wgpu` crate |
25
26pub mod material;
27pub mod pipeline;
28pub mod scene;
29
30pub use material::{
31    color_to_hex, lerp_material, material_to_gltf_json, Color4, MaterialLibrary, PbrMaterial,
32};
33pub use pipeline::{
34    default_mesh_pipeline, pipeline_summary, standard_vertex_layout, transparent_pipeline,
35    validate_pipeline, vertex_format_size, wireframe_pipeline, BlendFactor, BlendState,
36    CompareFunction, CullMode, DepthStencilState, IndexFormat, PrimitiveTopology,
37    RenderPipelineDescriptor, VertexAttribute, VertexBufferLayout, VertexFormat,
38};
39pub use scene::{
40    default_scene, mat4_identity, mat4_multiply, Light, LightKind, NodeContent, Scene, SceneNode,
41    Transform,
42};
43
44pub mod camera;
45pub mod gpu;
46pub mod lighting_presets;
47pub mod render_loop;
48pub mod scene_state;
49pub mod screenshot;
50
51pub use camera::CameraState;
52pub use gpu::MeshUploadBuffer;
53pub use lighting_presets::LightingPreset;
54pub use render_loop::Viewer;
55pub use scene_state::{ViewerConfig, ViewerStats};
56pub use screenshot::{ImageBuffer, ScreenshotCapture};
57
58// ── Phase 2 modules: event loop, morph updater, LOD v2, render stats v3 ──────
59
60pub mod event_loop;
61pub mod lod_manager_v2;
62pub mod morph_updater;
63pub mod render_stats_v3;
64
65pub use event_loop::{
66    headless_window_state, tick_headless, FrameTiming, InputState, OrbitCameraController,
67    WindowState,
68};
69pub use lod_manager_v2::{
70    build_lod_chain, default_lod_configs, DrawParams, LodConfig, LodLevelV2, LodManagerV2, LodMesh,
71    LodTransition, Mesh,
72};
73pub use morph_updater::{zero_positions, MorphSlider, MorphTargetDeltas, MorphUpdater};
74pub use render_stats_v3::{FrameTimer, RenderStatsSnapshot, RenderStatsV3};
75
76include!("_mods_part1.rs");
77include!("_mods_part2.rs");
78include!("_mods_part3.rs");
79include!("_mods_part4.rs");