Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: bevy_minimal.rs example #63

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
});
}
Loading