Crates.io | bevy_stl |
lib.rs | bevy_stl |
version | |
source | src |
created_at | 2020-12-25 08:22:21.506347 |
updated_at | 2024-12-07 09:34:00.687959 |
description | STL loader for bevy, based on stl_io |
homepage | |
repository | https://github.com/nilclass/bevy_stl |
max_upload_size | |
id | 327118 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
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.
bevy_stl
to your Cargo.toml
bevy_stl::StlPlugin
plugin to the bevy App
asset_server.load(..)
fn main() {
App::new()
.add_plugins(bevy_stl::StlPlugin)
.add_systems(Startup, setup)
// ...
.run();
}
fn setup(commands: Commands, asset_server: Res<AssetServer>, mut materials: ResMut<Assets<StandardMaterial>>) {
commands.spawn((
Mesh3d(asset_server.load("disc.stl")),
MeshMaterial3d(Color::rgb(0.9, 0.4, 0.3).into()),
));
}
You can find a more complete example in examples/spinning_disc.rs
- use cargo run --example spinning_disc --release
to run it.
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")