cleanup skybox/ar-toggle
This commit is contained in:
parent
7a3d38fc78
commit
efc840b031
71
src/world.rs
71
src/world.rs
|
@ -1,8 +1,5 @@
|
|||
use crate::{actor, nature};
|
||||
use bevy::prelude::*;
|
||||
//use bevy::core_pipeline::Skybox;
|
||||
//use bevy::asset::LoadState;
|
||||
//use bevy::render::render_resource::{TextureViewDescriptor, TextureViewDimension};
|
||||
use bevy::pbr::CascadeShadowConfigBuilder;
|
||||
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
|
||||
use bevy_xpbd_3d::prelude::*;
|
||||
|
@ -11,11 +8,6 @@ use std::f32::consts::PI;
|
|||
const ASTEROID_SIZE: f32 = 100.0;
|
||||
const STARS_MAX_MAGNITUDE: f32 = 5.5;
|
||||
|
||||
//const SKYBOX_BRIGHTNESS: f32 = 300.0;
|
||||
//const SKYBOX_BRIGHTNESS_AR: f32 = 100.0;
|
||||
|
||||
//const ASSET_CUBEMAP: &str = "textures/cubemap-fs8.png";
|
||||
//const ASSET_CUBEMAP_AR: &str = "textures/out.png";
|
||||
const ASSET_ASTEROID1: &str = "models/asteroid.glb#Scene0";
|
||||
const ASSET_ASTEROID2: &str = "models/asteroid2.glb#Scene0";
|
||||
pub fn asset_name_to_path(name: &str) -> &'static str {
|
||||
|
@ -37,8 +29,6 @@ pub struct WorldPlugin;
|
|||
impl Plugin for WorldPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(Startup, setup);
|
||||
//app.add_systems(Update, asset_loaded.after(load_cubemap_asset));
|
||||
//app.add_systems(Update, swap_world_on_ar_toggle);
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
app.add_plugins(MaterialPlugin::<RingMaterial>::default());
|
||||
//app.add_plugins(PhysicsDebugPlugin::default());
|
||||
|
@ -67,23 +57,6 @@ impl Material for RingMaterial {
|
|||
#[derive(Component)]
|
||||
pub struct Star;
|
||||
|
||||
//#[derive(Resource)]
|
||||
//pub struct WorldState {
|
||||
// is_loaded: bool,
|
||||
// entities_viewn_through_ar: bool,
|
||||
// cubemap_handle: Handle<Image>,
|
||||
// cubemap_ar_handle: Handle<Image>,
|
||||
//}
|
||||
//impl WorldState {
|
||||
// pub fn get_cubemap_handle(&self) -> Handle<Image> {
|
||||
// if self.entities_viewn_through_ar {
|
||||
// self.cubemap_ar_handle.clone()
|
||||
// } else {
|
||||
// self.cubemap_handle.clone()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
pub fn setup(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
|
@ -91,14 +64,6 @@ pub fn setup(
|
|||
mut materials_custom: ResMut<Assets<RingMaterial>>,
|
||||
asset_server: Res<AssetServer>,
|
||||
) {
|
||||
// let cubemap_handle = asset_server.load(ASSET_CUBEMAP);
|
||||
// commands.insert_resource(WorldState {
|
||||
// is_loaded: false,
|
||||
// entities_viewn_through_ar: settings.hud_active,
|
||||
// cubemap_handle: asset_server.load(ASSET_CUBEMAP),
|
||||
// cubemap_ar_handle: asset_server.load(ASSET_CUBEMAP_AR),
|
||||
// });
|
||||
|
||||
// Generate a bunch of asteriods
|
||||
let maxdist = 4;
|
||||
for i in -maxdist..maxdist {
|
||||
|
@ -190,7 +155,6 @@ pub fn setup(
|
|||
mesh: meshes.add(Mesh::from(Cylinder::new(ring_radius, 1.0))),
|
||||
transform: Transform::from_xyz(300000.0, -1000.0, 500000.0)
|
||||
.with_rotation(Quat::from_rotation_z(1f32.to_radians())),
|
||||
//transform: Transform::from_xyz(300000.0, 0.0, 500000.0)),
|
||||
material: materials_custom.add(RingMaterial {
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
ring_radius: ring_radius,
|
||||
|
@ -216,38 +180,3 @@ pub fn setup(
|
|||
..default()
|
||||
});
|
||||
}
|
||||
|
||||
//pub fn swap_world_on_ar_toggle(
|
||||
// asset_server: Res<AssetServer>,
|
||||
// mut images: ResMut<Assets<Image>>,
|
||||
// mut worldstate: ResMut<WorldState>,
|
||||
// mut skyboxes: Query<&mut Skybox>,
|
||||
// settings: Res<settings::Settings>,
|
||||
//) {
|
||||
// if settings.hud_active != worldstate.entities_viewn_through_ar {
|
||||
// worldstate.is_loaded = false;
|
||||
// worldstate.entities_viewn_through_ar = settings.hud_active;
|
||||
// }
|
||||
// if !worldstate.is_loaded && asset_server.load_state(&worldstate.get_cubemap_handle()) == LoadState::Loaded {
|
||||
// let cubemap_handle = &worldstate.get_cubemap_handle();
|
||||
// let image = images.get_mut(cubemap_handle).unwrap();
|
||||
// if image.texture_descriptor.array_layer_count() == 1 {
|
||||
// image.reinterpret_stacked_2d_as_array(image.height() / image.width());
|
||||
// image.texture_view_descriptor = Some(TextureViewDescriptor {
|
||||
// dimension: Some(TextureViewDimension::Cube),
|
||||
// ..default()
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// for mut skybox in &mut skyboxes {
|
||||
// skybox.image = cubemap_handle.clone();
|
||||
// skybox.brightness = if settings.hud_active {
|
||||
// SKYBOX_BRIGHTNESS_AR
|
||||
// } else {
|
||||
// SKYBOX_BRIGHTNESS
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// worldstate.is_loaded = true;
|
||||
// }
|
||||
//}
|
||||
|
|
Loading…
Reference in a new issue