Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

lotus128/bevy_obj

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.17"
bevy_obj = "0.17"

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;
            settings.load_options.single_index = false;
        },
    ));
}

License

Licensed under either of

at your option.

About

Wavefront OBJ mesh asset loader plugin for the Bevy engine.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%