bevy_plane_cut

Crates.iobevy_plane_cut
lib.rsbevy_plane_cut
version0.2.0
sourcesrc
created_at2024-06-07 23:39:56.733354
updated_at2024-07-05 09:58:44.233901
descriptionA plane cut material for bevy
homepage
repositoryhttps://github.com/shanecelis/bevy_plane_cut
max_upload_size
id1265320
size154,215
Shane Celis (shanecelis)

documentation

README

bevy_plane_cut

Maintenance CI crates-io api-docs

A plane cut material for the bevy game engine.

simple example

Install

Install the crate.

cargo add bevy_plane_cut

Usage

Add Plugin to App

use bevy::prelude::*;
fn main() {
    App::new()
        .add_plugins(bevy_plane_cut::PlaneCutPlugin)
        .run();
}

Add Material to Object

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()
    });
}

Examples

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.

Not Working Examples

simple_deferred

  • 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!

Compatibility

bevy_plane_cut bevy
0.2 0.14
0.1 0.13

License

This crate is licensed under the MIT License or the Apache License 2.0. The examples are licensed under the CC0 license.

Acknowlegments

Commit count: 23

cargo fmt