Skip to content

Commit

Permalink
Merge pull request #63 from ActuallyHappening/add-minimal-examples
Browse files Browse the repository at this point in the history
add: bevy_minimal.rs example
  • Loading branch information
urholaukkarinen authored Jun 9, 2024
2 parents 1c56a6c + 949874a commit 7240af4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/transform-gizmo-bevy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ bevy_log.workspace = true
bevy_window.workspace = true
bevy_transform.workspace = true

[dev-dependencies]
bevy = "0.13"

[lints]
workspace = true
49 changes: 49 additions & 0 deletions crates/transform-gizmo-bevy/examples/bevy_minimal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! A very simple example
//! See the project root's `examples` directory for more examples
use bevy::prelude::*;
use transform_gizmo_bevy::*;

fn main() {
App::new()
.add_plugins((DefaultPlugins, TransformGizmoPlugin))
.add_systems(Startup, setup)
.run();
}

fn setup(
mut commands: Commands,
mut materials: ResMut<Assets<StandardMaterial>>,
mut meshes: ResMut<Assets<Mesh>>,
) {
// camera
commands.spawn((
Camera3dBundle {
transform: Transform::from_translation(Vec3::new(1.0, 3.0, -5.0))
.looking_at(Vec3::ZERO, Vec3::Y),
..default()
},
GizmoCamera,
));

// cube
commands.spawn((
PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::GREEN),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)),
..default()
},
GizmoTarget::default(),
));

// light
commands.spawn(PointLightBundle {
point_light: PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
}

0 comments on commit 7240af4

Please sign in to comment.