Skip to content

Commit

Permalink
Orbit Control works (by keys)
Browse files Browse the repository at this point in the history
  • Loading branch information
-karlos- committed Jan 14, 2024
1 parent cab63db commit e227842
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
5 changes: 1 addition & 4 deletions src/f4control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ fn _player_look(
}
}

fn setup(
mut control_values: ResMut<ControlValues>,
starting_values: Res<crate::StartingValues>,
) {
fn setup(mut control_values: ResMut<ControlValues>, starting_values: Res<crate::StartingValues>) {
// set up accroding to lat/lon relative to Earth center
control_values.up = starting_values.planetary_position.normalize().as_vec3();
control_values.speed = 100.0;
Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ pub fn main() {
let mut xr = false;

for arg in &args {
if arg.is_empty() {continue;}; // to skipp unneeded & in the browser URL
if arg.is_empty() {
continue; // skip unneeded & in the browser URL
};
let (k, v) = arg
.split_once('=')
.expect("arguments must be `key=value` pairs");
Expand Down
24 changes: 6 additions & 18 deletions src/player.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::prelude::*;
use bevy::ecs::system::SystemParam;
use bevy::prelude::*;
use bevy::render::render_resource::{Extent3d, TextureDimension, TextureFormat};
use big_space::{FloatingOrigin, FloatingOriginSettings};
use glam::DVec3;
Expand All @@ -10,11 +10,11 @@ use crate::compass::OpenXRTrackingRoot;
use bevy_oxr::xr_input::trackers::OpenXRTrackingRoot;

use crate::compass::Compass;
use crate::geocoord::{GeoCoord,EARTH_RADIUS};
use crate::geocoord::{GeoCoord, EARTH_RADIUS};
use crate::geoview::GeoView;
use crate::GalacticGrid;
use crate::GalacticTransform;
use crate::GalacticTransformOwned;
use crate::GalacticGrid;

#[derive(SystemParam)]
/// A helper argument for bevy systems that obtains the main player's position.
Expand Down Expand Up @@ -208,9 +208,8 @@ fn uv_debug_texture() -> Image {
)
}


pub fn setup_player_controls(
mut commands: Commands,
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut images: ResMut<Assets<Image>>,
mut materials: ResMut<Assets<StandardMaterial>>,
Expand All @@ -220,7 +219,6 @@ pub fn setup_player_controls(
let (grid, _): (GalacticGrid, _) =
space.translation_to_grid(starting_values.planetary_position);


let material = materials.add(StandardMaterial {
base_color_texture: Some(images.add(uv_debug_texture())),
..default()
Expand All @@ -246,7 +244,6 @@ pub fn setup_player_controls(
InheritedVisibility::default(),
Control,
grid,

FogSettings {
color: Color::rgba(0.35, 0.48, 0.66, 1.0),
directional_light_color: Color::rgba(1.0, 0.95, 0.85, 0.5),
Expand All @@ -257,7 +254,6 @@ pub fn setup_player_controls(
Color::rgb(0.8, 0.844, 1.0), // atmospheric inscattering color (light gained due to scattering from the sun)
),
},

));
camera.add_child(sphere);
if !starting_values.xr {
Expand All @@ -266,21 +262,13 @@ pub fn setup_player_controls(
// FIXME: attach the camera bundle to the world, so when we move the world, the player is automatically moved with it.
// We'll need this when the player moves very far or teleports to another place, as we need to ensure we don't go into
// regions where the floating point numbers become imprecise.

}



pub struct Plugin;

impl bevy::prelude::Plugin for Plugin {
fn build(&self, app: &mut App) {

app
.init_resource::<ControlValues>()
.add_systems(Startup, setup_player_controls)
;


app.init_resource::<ControlValues>()
.add_systems(Startup, setup_player_controls);
}
}

0 comments on commit e227842

Please sign in to comment.