#wavefront-obj #bevy #obj #mesh #assets #loader #plugin

bevy_obj

Wavefront OBJ mesh asset loader plugin for the Bevy engine

19 releases (breaking)

0.15.0 Oct 29, 2024
0.14.0 Jul 6, 2024
0.13.0 Feb 18, 2024
0.12.0 Nov 5, 2023
0.3.0 Nov 3, 2020

#149 in Game dev

Download history 99/week @ 2024-08-16 55/week @ 2024-08-23 66/week @ 2024-08-30 75/week @ 2024-09-06 89/week @ 2024-09-13 165/week @ 2024-09-20 162/week @ 2024-09-27 70/week @ 2024-10-04 84/week @ 2024-10-11 73/week @ 2024-10-18 168/week @ 2024-10-25 126/week @ 2024-11-01 75/week @ 2024-11-08 99/week @ 2024-11-15 70/week @ 2024-11-22 44/week @ 2024-11-29

313 downloads per month
Used in 6 crates (4 directly)

MIT/Apache

39KB
250 lines

bevy_obj

Crates.io

Wavefront OBJ mesh asset loader plugin for the Bevy engine.

Usage

Add the crate as a dependency:

Major and Minor version number should match bevy version.

[dependencies]
bevy = "0.15"
bevy_obj = "0.15"

Add the plugin:

use bevy::prelude::*;
use bevy_obj::ObjPlugin;

fn main() {
    App::new()
        .add_plugins((DefaultPlugins, ObjPlugin))
        .run();
}

Load an .obj file:

fn example_startup_system(asset_server: Res<AssetServer>) {
    // Load it as a singular mesh
    let mesh_handle = asset_server.load::<Mesh>("example.obj");

    // Load it as a scene with limited .mtl material support
    let scene_handle = asset_server.load::<Scene>("example.obj");

    // Or let bevy infer the type
    let mesh = Mesh3d(asset_server.load("example.obj"));
    let scene = SceneRoot(asset_server.load("example.obj"));
}

Settings

You can use load_with_settings() to modify some loader settings.

fn example_startup_system(asset_server: Res<AssetServer>) {
    // Load the model with flat normals
    let scene = SceneRoot(asset_server.load_with_settings(
        "example.obj",
        |settings: &mut bevy_obj::ObjSettings| {
            settings.force_compute_normals = true;
            settings.prefer_flat_normals = true;
        },
    ));
}

License

Licensed under either of

at your option.

Dependencies

~40–77MB
~1.5M SLoC