diff --git a/Cargo.toml b/Cargo.toml index d98250b..7249d0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ [workspace.package] authors = ["IDEDARY"] - version = "0.2.2" + version = "0.2.3" edition = "2021" license = "MIT OR Apache-2.0" repository = "https://github.com/bytestring-net/bevy-lunex" @@ -26,8 +26,8 @@ [workspace.dependencies] - bevy_lunex = { path = "crates/bevy_lunex", version = "0.2.2" } - lunex_engine = { path = "crates/lunex_engine", version = "0.2.2" } + bevy_lunex = { path = "crates/bevy_lunex", version = "0.2.3" } + lunex_engine = { path = "crates/lunex_engine", version = "0.2.3" } colored = { version = "^2.1" } indexmap = { version = "^2.1" } diff --git a/README.md b/README.md index 280d704..637c9ed 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,7 @@ For production ready example/template check out [`Bevypunk source code`](https:/ | Bevy | Bevy Lunex | |--------|-----------------| -| 0.14.0 | 0.2.0 - 0.2.2 | +| 0.14.0 | 0.2.0 - 0.2.3 | | 0.13.2 | 0.1.0 | | 0.12.1 | 0.0.10 - 0.0.11 | | 0.12.0 | 0.0.7 - 0.0.9 | diff --git a/crates/bevy_lunex/README.md b/crates/bevy_lunex/README.md index 280d704..637c9ed 100644 --- a/crates/bevy_lunex/README.md +++ b/crates/bevy_lunex/README.md @@ -89,7 +89,7 @@ For production ready example/template check out [`Bevypunk source code`](https:/ | Bevy | Bevy Lunex | |--------|-----------------| -| 0.14.0 | 0.2.0 - 0.2.2 | +| 0.14.0 | 0.2.0 - 0.2.3 | | 0.13.2 | 0.1.0 | | 0.12.1 | 0.0.10 - 0.0.11 | | 0.12.0 | 0.0.7 - 0.0.9 | diff --git a/crates/lunex_engine/src/core/compute.rs b/crates/lunex_engine/src/core/compute.rs index fbff9cb..ffdac17 100644 --- a/crates/lunex_engine/src/core/compute.rs +++ b/crates/lunex_engine/src/core/compute.rs @@ -110,7 +110,7 @@ impl UiNodeComputeTrait for UiNode { }; // Adding depth - node_data.rectangle.pos.z = depth + node_data.depth_bias; + node_data.rectangle.pos.z = (depth + node_data.depth_bias)*absolute_scale; node_data.rectangle } else { return; }; diff --git a/crates/lunex_engine/src/core/traits.rs b/crates/lunex_engine/src/core/traits.rs index 2cbf700..d5a897a 100644 --- a/crates/lunex_engine/src/core/traits.rs +++ b/crates/lunex_engine/src/core/traits.rs @@ -265,16 +265,26 @@ impl UiNodeDataTrait for UiNode { /// Trait that abstracts over [`NodeTreeInitTrait`] to provide tailored /// implementations for the primitive in layouting context. pub trait UiNodeTreeInitTrait { - /// Creates new [`UiTree`]. - fn new(name: impl Borrow) -> Self; + /// Creates new [`UiTree`] configured for 2D enviroment. + fn new2d(name: impl Borrow) -> Self; + /// Creates new [`UiTree`] configured for 3D enviroment. + fn new3d(name: impl Borrow) -> Self; } impl UiNodeTreeInitTrait for UiTree { - fn new(name: impl Borrow) -> Self { + fn new2d(name: impl Borrow) -> Self { let mut tree: UiTree = NodeTreeInitTrait::new(name); tree.add_topdata(MasterData::default()); tree.add_data(NodeData::default()); tree } + fn new3d(name: impl Borrow) -> Self { + let mut tree: UiTree = NodeTreeInitTrait::new(name); + let mut md = MasterData::default(); + md.abs_scale = 0.001; + tree.add_topdata(md); + tree.add_data(NodeData::default()); + tree + } } diff --git a/docs/src/advanced/abstraction/components.md b/docs/src/advanced/abstraction/components.md index 96e86dd..9269a3d 100644 --- a/docs/src/advanced/abstraction/components.md +++ b/docs/src/advanced/abstraction/components.md @@ -39,7 +39,7 @@ fn build_route(mut commands: Commands, assets: Res, query: Query::from(UiTree::new("CustomButton")), + UiTreeBundle::::from(UiTree::new2d("CustomButton")), // Now spawn the UI as children )).with_children(|ui| { diff --git a/docs/src/advanced/abstraction/routes.md b/docs/src/advanced/abstraction/routes.md index 7b213b3..07c1c2a 100644 --- a/docs/src/advanced/abstraction/routes.md +++ b/docs/src/advanced/abstraction/routes.md @@ -32,7 +32,7 @@ fn build_route(mut commands: Commands, assets: Res, query: Query::from(UiTree::new("MyRoute")), + UiTreeBundle::::from(UiTree::new2d("MyRoute")), MovableByCamera, )).with_children(|ui| { diff --git a/docs/src/installation.md b/docs/src/installation.md index af6971f..ebbfbc0 100644 --- a/docs/src/installation.md +++ b/docs/src/installation.md @@ -6,7 +6,7 @@ Add the following to your `Cargo.toml`: ```toml [dependencies] -bevy_lunex = { version = "0.2.2" } +bevy_lunex = { version = "0.2.3" } ``` Alternatively, you can use the latest bleeding edge version from the Git repository: diff --git a/docs/src/quick_start.md b/docs/src/quick_start.md index 919d2d5..40100eb 100644 --- a/docs/src/quick_start.md +++ b/docs/src/quick_start.md @@ -49,7 +49,7 @@ commands.spawn(( MovableByCamera, // This is our UI system - UiTreeBundle::::from(UiTree::new("Hello UI!")), + UiTreeBundle::::from(UiTree::new2d("Hello UI!")), )).with_children(|ui| { // Here we will spawn our UI as children diff --git a/examples/mesh2d/src/main.rs b/examples/mesh2d/src/main.rs index c43bd27..dc2d66a 100644 --- a/examples/mesh2d/src/main.rs +++ b/examples/mesh2d/src/main.rs @@ -24,7 +24,7 @@ fn setup(mut cmd: Commands, mut materials: ResMut>) { // Spawn UiTree cmd.spawn(( UiTreeBundle:: { - tree: UiTree::new("MyUiSystem"), + tree: UiTree::new2d("MyUiSystem"), ..default() }, MovableByCamera, diff --git a/examples/minimal/src/main.rs b/examples/minimal/src/main.rs index b4c0f1f..aeed0d5 100644 --- a/examples/minimal/src/main.rs +++ b/examples/minimal/src/main.rs @@ -24,7 +24,7 @@ fn setup(mut cmd: Commands, assets: Res) { // Spawn UiTree cmd.spawn(( UiTreeBundle:: { - tree: UiTree::new("MyUiSystem"), + tree: UiTree::new2d("MyUiSystem"), ..default() }, MovableByCamera, diff --git a/examples/worldspace/src/boilerplate.rs b/examples/worldspace/src/boilerplate.rs index e95757c..1f6a68d 100644 --- a/examples/worldspace/src/boilerplate.rs +++ b/examples/worldspace/src/boilerplate.rs @@ -45,7 +45,7 @@ pub fn rotate_playercam(mut mouse_motion_events: EventReader, mouse pub fn zoom_playercam(mut mouse_wheel_events: EventReader, mut query: Query<&mut PlayerCam>) { let delta: f32 = mouse_wheel_events.read().map(|e| e.y).sum(); for mut camera in &mut query { - camera.distance += -delta*25.0; + camera.distance += -delta * camera.distance/25.0; } } diff --git a/examples/worldspace/src/main.rs b/examples/worldspace/src/main.rs index 47e41a3..6b0ed55 100644 --- a/examples/worldspace/src/main.rs +++ b/examples/worldspace/src/main.rs @@ -26,7 +26,7 @@ fn setup( Camera3dBundle::default(), PlayerCam { orbit: Vec3::new(0.0, 0.0, 0.0), - distance: 800.0, + distance: 2.0, sensitivity: Vec2::splat(0.1), } )); @@ -37,8 +37,8 @@ fn setup( // Spawn the floating Ui panel commands.spawn(( UiTreeBundle:: { - transform: Transform::from_xyz(-400.0, 300.0, 0.0 + (300.0 * x as f32)), - tree: UiTree::new("PanelWidget"), + transform: Transform::from_xyz(-0.4, 0.3, 0.0 + (0.3 * x as f32)), + tree: UiTree::new3d("PanelWidget"), ..default() }, )).with_children(|ui| {