bevy_obj/
lib.rs

1#[cfg(feature = "mesh")]
2pub mod mesh;
3#[cfg(feature = "scene")]
4pub mod scene;
5
6mod util;
7
8use bevy::app::{App, Plugin};
9use bevy::asset::AssetApp;
10use serde::{Deserialize, Serialize};
11
12const EXTENSIONS: &[&str; 2] = &["obj", "OBJ"];
13
14/// Adds support for OBJ asset loading
15#[derive(Default)]
16pub struct ObjPlugin;
17
18impl Plugin for ObjPlugin {
19    fn build(&self, app: &mut App) {
20        #[cfg(feature = "mesh")]
21        app.init_asset_loader::<mesh::ObjLoader>();
22        #[cfg(feature = "scene")]
23        app.init_asset_loader::<scene::ObjLoader>();
24    }
25}
26
27/// OBJ asset loader settings
28#[derive(Default, Serialize, Deserialize)]
29pub struct ObjSettings {
30    /// Force compute the normals even if the mesh contains normals
31    pub force_compute_normals: bool,
32    /// Prefer flat normals over smooth normals when computing them
33    pub prefer_flat_normals: bool,
34}