Giter Club home page Giter Club logo

bevy_stl's Introduction

bevy_stl

Crate version

Crate license

A STL loader for bevy.

STL is a very simple format, which supports only triangular geometry (positions + normals), without any color / uv / texture information.

It is supported as an output format by most CAD software.

Alternatives

  • by default bevy can load glTF scenes, which is a much better choice if you are looking for a way to load more complex models / scenes, including materials, animations, etc.
  • bevy_obj can load Wavefront .obj files, which can carry more information than STL (such as color, material, UV coordinates)

Usage

  1. Add bevy_stl to your Cargo.toml
  2. Add bevy_stl::StlPlugin plugin to the bevy App
  3. Load STL assets by passing paths with ".stl" extension to asset_server.load(..)

Example

fn main() {
    App::new()
        .add_plugin(bevy_stl::StlPlugin)
        .add_startup_system(setup)
        // ...
        .run();
}

fn setup(commands: &mut Commands, asset_server: Res<AssetServer>, mut materials: ResMut<Assets<StandardMaterial>>) {
    commands
        .spawn(PbrBundle {
            mesh: asset_server.load("disc.stl"),
            material: materials.add(Color::rgb(0.9, 0.4, 0.3).into()),
            ..Default::default()
        })
        // ...
}

You can find a more complete example in examples/spinning_disc.rs - use cargo run --example spinning_disc --release to run it.

Optional Features

Wireframe

By default bevy_stl produces a triangle mesh (PrimitiveTopology::TriangleList). When the optional wireframe feature is enabled, an additional line mesh is produced (PrimitiveTopology::LineList).

The feature can be enabled via Cargo.toml:

[dependencies.bevy_stl]
features = ["wireframe"]

When enabled, the mesh can be accessed by appending the wireframe label to the path passed to the asset loader:

  // This returns the triangle mesh (the default):
  asset_server.load("disc.stl")

  // This returns the wireframe mesh:
  asset_server.load("disc.stl#wireframe")

bevy_stl's People

Contributors

nilclass avatar aevyrie avatar keis avatar jruiseco avatar behrenle avatar djrakita avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.