forked from nannou-org/nannou
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a34a603
commit 18ac4c0
Showing
20 changed files
with
697 additions
and
67 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "bevy_nannou_geom" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
bevy = { workspace = true } | ||
bevy_nannou_draw = { path = "../bevy_nannou_draw" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use std::ops::DerefMut; | ||
use bevy::prelude::*; | ||
use bevy_nannou_draw::render::ShaderModel; | ||
use crate::geom::Geometry; | ||
use crate::geom::properties::mesh::SetMesh; | ||
|
||
pub type CubeGeometry<'a, 'w, SM: ShaderModel> = Geometry<'a, 'w, Cube, SM>; | ||
|
||
#[derive(Component, Deref, DerefMut, Default, Clone)] | ||
pub struct Cube(pub Cuboid); | ||
|
||
impl From<Cube> for Mesh { | ||
fn from(value: Cube) -> Self { | ||
value.0.into() | ||
} | ||
} | ||
|
||
impl <'a, 'w, SM> CubeGeometry<'a, 'w, SM> | ||
where SM: ShaderModel + Material + Default | ||
{ | ||
pub fn x_length(mut self, length: f32) -> Self { | ||
self.primitive().half_size.x = length / 2.0; | ||
self | ||
} | ||
|
||
pub fn y_length(mut self, length: f32) -> Self { | ||
self.primitive().half_size.y = length / 2.0; | ||
self | ||
} | ||
|
||
pub fn z_length(mut self, length: f32) -> Self { | ||
self.primitive().half_size.z = length / 2.0; | ||
self | ||
} | ||
|
||
pub fn length(mut self, length: f32) -> Self { | ||
self.primitive().half_size = Vec3::splat(length / 2.0); | ||
self | ||
} | ||
|
||
pub fn dimensions(mut self, dimensions: Vec3) -> Self { | ||
self.primitive().half_size = dimensions / 2.0; | ||
self | ||
} | ||
|
||
pub fn corners(mut self, point1: Vec3, point2: Vec3) -> Self { | ||
self.primitive().half_size = (point2 - point1).abs() / 2.0; | ||
self | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use bevy_nannou_draw::render::ShaderModel; | ||
use crate::geom::Geometry; | ||
|
||
pub mod cube; |
Oops, something went wrong.