From 02b9b7c49f0a095cd70ac15557970e6d6880e231 Mon Sep 17 00:00:00 2001 From: Robin KAY Date: Mon, 8 Aug 2022 23:57:14 +0100 Subject: [PATCH] Add comments to shapes example. --- examples/shapes.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/examples/shapes.rs b/examples/shapes.rs index dafaf74..192c1d8 100644 --- a/examples/shapes.rs +++ b/examples/shapes.rs @@ -1,8 +1,11 @@ use std::f32::consts::{PI, TAU}; -use bevy::prelude::{ - shape::{Cube, Torus}, - *, +use bevy::{ + prelude::{ + shape::{Cube, Torus}, + *, + }, + window::close_on_esc, }; use bevy_mod_outline::*; @@ -15,6 +18,7 @@ fn main() { .add_plugins(DefaultPlugins) .add_plugin(OutlinePlugin) .add_startup_system(setup) + .add_system(close_on_esc) .add_system(wobble) .add_system(orbit) .run(); @@ -31,12 +35,7 @@ fn setup( mut meshes: ResMut>, mut materials: ResMut>, ) { - commands.spawn_bundle(PbrBundle { - mesh: meshes.add(Mesh::from(bevy::prelude::shape::Plane { size: 5.0 })), - material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), - ..default() - }); - + // Add cube with generated outline normals let mut cube_mesh = Mesh::from(Cube { size: 1.0 }); cube_mesh.generate_outline_normals().unwrap(); commands @@ -56,6 +55,7 @@ fn setup( }) .insert(Wobbles); + // Add torus using the regular surface normals for outlining commands .spawn_bundle(PbrBundle { mesh: meshes.add(Mesh::from(Torus { @@ -78,6 +78,13 @@ fn setup( ..default() }) .insert(Orbits); + + // Add plane, light source, and camera + commands.spawn_bundle(PbrBundle { + mesh: meshes.add(Mesh::from(bevy::prelude::shape::Plane { size: 5.0 })), + material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), + ..default() + }); commands.spawn_bundle(PointLightBundle { point_light: PointLight { intensity: 1500.0,