Some checks failed
WIP: add iso_loader.rs — bridges the async XisoReader / synchronous GameAssets to Bevy's ECS via background threads + mpsc channels polled per frame (no main-thread blocking); UI open-iso/open-dir/file-select events → texture preview. Register IsoLoaderPlugin; wire asset_loader and the egui UI. Deps: rfd (native file dialog, workspace + viewer), futures, and bevy tonemapping_luts feature. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
98 lines
3.0 KiB
Rust
98 lines
3.0 KiB
Rust
//! # sylpheed-viewer
|
|
//!
|
|
//! Bevy-based asset viewer for Project Sylpheed: Arc of Deception.
|
|
//!
|
|
//! This crate serves as both:
|
|
//! - A **native binary** (via `main.rs`) — full desktop viewer
|
|
//! - A **WASM library** (this file) — browser viewer at `index.html`
|
|
//!
|
|
//! ## Architecture
|
|
//! - `sylpheed_formats` handles all binary parsing — no Bevy dependency
|
|
//! - This crate is the thin Bevy integration layer on top
|
|
//! - `asset_loader` bridges the two: wraps parsers as `AssetLoader` impls
|
|
//!
|
|
//! ## WASM notes
|
|
//! On the web, local file access is unavailable. Assets must be
|
|
//! pre-extracted and served over HTTP. XISO reading is native-only.
|
|
|
|
use bevy::prelude::*;
|
|
use bevy_egui::EguiPlugin;
|
|
|
|
pub mod asset_loader;
|
|
pub mod camera;
|
|
pub mod iso_loader;
|
|
pub mod ui;
|
|
|
|
// ── Application state ────────────────────────────────────────────────────────
|
|
|
|
/// Global viewer state, shared across all UI and rendering systems.
|
|
#[derive(Resource)]
|
|
pub struct ViewerState {
|
|
/// Which type of asset is currently being browsed / previewed.
|
|
pub current_mode: ViewMode,
|
|
/// Whether to render meshes in wireframe mode (toggle with F2).
|
|
pub wireframe: bool,
|
|
}
|
|
|
|
impl Default for ViewerState {
|
|
fn default() -> Self {
|
|
Self {
|
|
current_mode: ViewMode::Textures,
|
|
wireframe: false,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// The active view / asset type being inspected.
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
|
pub enum ViewMode {
|
|
/// XPR2 texture preview (Milestone 1).
|
|
#[default]
|
|
Textures,
|
|
/// 3D mesh viewer (Milestone 2+).
|
|
Mesh,
|
|
/// Audio waveform / playback (Milestone 2+).
|
|
Audio,
|
|
}
|
|
|
|
// ── App builder ──────────────────────────────────────────────────────────────
|
|
|
|
/// Build and run the viewer application.
|
|
///
|
|
/// Called from `main.rs` on native and from `wasm_bindgen` init on the web.
|
|
pub fn run() {
|
|
let mut app = App::new();
|
|
|
|
app.add_plugins(
|
|
DefaultPlugins.set(WindowPlugin {
|
|
primary_window: Some(Window {
|
|
title: "Project Sylpheed: Arc of Deception — Asset Viewer".into(),
|
|
resolution: (1280.0, 720.0).into(),
|
|
..default()
|
|
}),
|
|
..default()
|
|
}),
|
|
);
|
|
|
|
app.add_plugins(EguiPlugin);
|
|
app.add_plugins(asset_loader::SylpheedAssetPlugin);
|
|
app.add_plugins(iso_loader::IsoLoaderPlugin);
|
|
app.add_plugins(camera::OrbitCameraPlugin);
|
|
app.add_plugins(ui::ViewerUiPlugin);
|
|
|
|
app.init_resource::<ViewerState>();
|
|
|
|
// Minimal 3D scene: a directional light so meshes are visible
|
|
app.add_systems(Startup, setup_scene);
|
|
|
|
app.run();
|
|
}
|
|
|
|
fn setup_scene(mut commands: Commands) {
|
|
commands.spawn(DirectionalLight {
|
|
illuminance: 10_000.0,
|
|
shadows_enabled: true,
|
|
..default()
|
|
});
|
|
}
|