Crates.io | bevy_plane_cut |
lib.rs | bevy_plane_cut |
version | 0.2.0 |
source | src |
created_at | 2024-06-07 23:39:56.733354 |
updated_at | 2024-07-05 09:58:44.233901 |
description | A plane cut material for bevy |
homepage | |
repository | https://github.com/shanecelis/bevy_plane_cut |
max_upload_size | |
id | 1265320 |
size | 154,215 |
A plane cut material for the bevy game engine.
Install the crate.
cargo add bevy_plane_cut
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(bevy_plane_cut::PlaneCutPlugin)
.run();
}
use bevy::{
prelude::*,
color::palettes::basic,
pbr::ExtendedMaterial,
};
use bevy_plane_cut::*;
fn setup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<PlaneCutMaterial>>) {
commands.spawn(MaterialMeshBundle {
mesh: meshes.add(Sphere::new(1.0)),
material: materials.add(ExtendedMaterial {
base: StandardMaterial {
base_color: basic::RED.into(),
..default()
},
extension: PlaneCutExt {
plane: Vec4::new(-1.0, 1.0, -2.0, 0.0),
color: Color::linear_rgb(0.0, 0.0, 0.7),
shaded: true,
space: Space::World,
},
}),
..default()
});
}
Run the "simple" example like so:
cargo run --example simple
This will show a red sphere with a light rotating around it and blue plane cut.
simple
- A red sphere with a plane cut.simple_screenspace
- A red sphere with a plane cut in screen space.moving_cut
- A red sphere with a plane cut moving in and out.simple_deferred
- same as simple but using deferred renderer.
NOTE: This one does not look right on my macOS machine.deferred
- A red sphere rendered with deferred renderer. This has no plane
cut at all and it still does not look right. I'm using macOS, so I'd be
curious if it looks correct on other platforms.two_cuts
- This is a material that has been extended by PlaneCutExt
twice.
However, it has a bug. See two_cuts.rs
example for more details. PRs welcome!bevy_plane_cut | bevy |
---|---|
0.2 | 0.14 |
0.1 | 0.13 |
This crate is licensed under the MIT License or the Apache License 2.0. The examples are licensed under the CC0 license.
Clipping a Model with a Plane by Ronja taught me the technique many years ago.
Extending Materials in Bevy 0.12 with Material Extension by Chris Biscardi showed off how cool ExtendedMaterial
is.
Thanks to robtfm who wrote the original extended_material.rs example in bevy.