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

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

```rust fn main() { App::build() .addplugin(bevystl::StlPlugin) .addstartupsystem(setup.system()) // ... .run(); }

fn setup(commands: &mut Commands, assetserver: Res, mut materials: ResMut>) { commands .spawn(PbrBundle { mesh: assetserver.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") ```