first step to 0.13

This commit is contained in:
rewin
2024-03-14 23:15:30 +03:00
parent 75dcd9b8d9
commit dbf512bb0c
16 changed files with 100 additions and 86 deletions
+1 -4
View File
@@ -1,8 +1,5 @@
use bevy::{ use bevy::{
math::Affine3A, ecs::entity::{EntityHashMap, EntityHashSet}, math::Affine3A, prelude::*, render::{mesh::skinning::SkinnedMesh, view::NoFrustumCulling}
prelude::*,
render::{mesh::skinning::SkinnedMesh, view::NoFrustumCulling},
utils::{EntityHashMap, EntityHashSet},
}; };
use space_editor::space_prefab::editor_registry::EditorRegistryExt; use space_editor::space_prefab::editor_registry::EditorRegistryExt;
+5 -5
View File
@@ -1,6 +1,6 @@
use bevy::{ use bevy::{
ecs::{ ecs::{
query::{ReadOnlyWorldQuery, WorldQuery}, query::{QueryData, QueryFilter, WorldQuery},
system::Command, system::Command,
}, },
prelude::*, prelude::*,
@@ -30,7 +30,7 @@ impl Plugin for BvhPlugin {
// module's `SceneState`) to manage the order/frequency at // module's `SceneState`) to manage the order/frequency at
// which these systems run instead of just running them all // which these systems run instead of just running them all
// every frame // every frame
.add_systems(Update, spawn_test_bvh.run_if(resource_exists::<TestBvh>())) .add_systems(Update, spawn_test_bvh.run_if(resource_exists::<TestBvh>))
.add_systems( .add_systems(
PostUpdate, PostUpdate,
(compute_inverse_bindposes, apply_deferred, animate_bvh) (compute_inverse_bindposes, apply_deferred, animate_bvh)
@@ -143,7 +143,7 @@ pub fn animate_bvh(
} }
} }
fn lerp_frames<T: ReadOnlyWorldQuery>( fn lerp_frames<T: QueryFilter>(
joint_query: &mut Query<JointQuery, T>, joint_query: &mut Query<JointQuery, T>,
current_joint: Entity, current_joint: Entity,
bvh: &studio_bvh::Bvh, bvh: &studio_bvh::Bvh,
@@ -226,8 +226,8 @@ pub struct BvhAnimCompleteEvent;
#[derive(Debug, Component, Reflect)] #[derive(Debug, Component, Reflect)]
pub struct BvhJoint(usize); pub struct BvhJoint(usize);
#[derive(Debug, WorldQuery)] #[derive(Debug, QueryData)]
#[world_query(mutable)] #[query_data(mutable)]
pub struct JointQuery { pub struct JointQuery {
pub name: &'static Name, pub name: &'static Name,
pub joint: &'static BvhJoint, pub joint: &'static BvhJoint,
+2 -2
View File
@@ -309,8 +309,8 @@ fn do_pan(
}; };
// Pan along local XY plane, with the distance scaled by the radius // Pan along local XY plane, with the distance scaled by the radius
let up = xform.up(); let up = xform.up().xyz();
let left = xform.left(); let left = xform.left().xyz();
let delta = (pan.y * up + pan.x * left) * controller.radius; let delta = (pan.y * up + pan.x * left) * controller.radius;
// Update camera translation and focus point // Update camera translation and focus point
+19 -22
View File
@@ -4,12 +4,7 @@ use bevy::{prelude::*, window::PrimaryWindow};
use bevy_inspector_egui::{bevy_egui::EguiPlugin, DefaultInspectorConfigPlugin}; use bevy_inspector_egui::{bevy_egui::EguiPlugin, DefaultInspectorConfigPlugin};
use bevy_mod_picking::debug::DebugPickingMode; use bevy_mod_picking::debug::DebugPickingMode;
use space_editor::{ use space_editor::{
prelude::EditorCameraMarker, prelude::*, space_editor_ui::{tools::gizmo::GizmoToolPlugin, EditorGizmoConfigPlugin, EditorPluginGroup}
space_editor_ui::{
bottom_menu::BottomMenuPlugin, tools::gizmo::GizmoToolPlugin, EditorDefaultCameraPlugin,
EditorGizmoConfigPlugin, EditorPickingPlugin, EditorPluginGroup, EditorUiCore,
ShowEditorUi,
},
}; };
use crate::{ use crate::{
@@ -32,13 +27,16 @@ pub struct DebugPlugin;
impl Plugin for DebugPlugin { impl Plugin for DebugPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.insert_resource(DebugMode(false)) app.insert_resource(DebugMode(false))
.insert_resource(State::new(DebugPickingMode::Disabled)) .insert_resource(DebugPickingMode::Disabled)
.insert_resource(GizmoConfig { .add_systems(Startup, |mut config_store: ResMut<GizmoConfigStore>| {
enabled: true, let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
depth_bias: -0.1, *config = GizmoConfig {
line_perspective: false, enabled: true,
line_width: 2., depth_bias: -0.1,
..default() line_perspective: false,
line_width: 2.,
..default()
};
}) })
.add_systems( .add_systems(
Update, Update,
@@ -46,7 +44,7 @@ impl Plugin for DebugPlugin {
toggle_debug_mode, toggle_debug_mode,
update_debug_picking_mode update_debug_picking_mode
.run_if(is_editor) .run_if(is_editor)
.run_if(resource_changed::<DebugMode>()), .run_if(resource_changed::<DebugMode>),
update_gizmo_line_thickness, update_gizmo_line_thickness,
(draw_world_axes, draw_debug_points, draw_skeletal_joints) (draw_world_axes, draw_debug_points, draw_skeletal_joints)
.after(CameraMotionSystem) .after(CameraMotionSystem)
@@ -70,15 +68,13 @@ impl Plugin for DebugPlugin {
.disable::<BottomMenuPlugin>() .disable::<BottomMenuPlugin>()
.disable::<GizmoToolPlugin>() .disable::<GizmoToolPlugin>()
.disable::<EditorGizmoConfigPlugin>() .disable::<EditorGizmoConfigPlugin>()
.set(space_editor::prelude::SelectedPlugin { .disable::<space_editor::prelude::SelectedPlugin>(),
show_selected_wireframe: false,
}),
); );
app.add_systems(Update, sync_editor_camera); app.add_systems(Update, sync_editor_camera);
app.add_systems( app.add_systems(
Update, Update,
update_editor_ui_mode.run_if(resource_changed::<DebugMode>()), update_editor_ui_mode.run_if(resource_changed::<DebugMode>),
); );
} }
} }
@@ -104,12 +100,12 @@ fn update_editor_ui_mode(
fn update_debug_picking_mode( fn update_debug_picking_mode(
r_debug: Res<DebugMode>, r_debug: Res<DebugMode>,
mut s_debug_picking: ResMut<NextState<DebugPickingMode>>, mut s_debug_picking: ResMut<DebugPickingMode>,
) { ) {
s_debug_picking.set(match **r_debug { *s_debug_picking = match **r_debug {
true => DebugPickingMode::Normal, true => DebugPickingMode::Normal,
false => DebugPickingMode::Disabled, false => DebugPickingMode::Disabled,
}); };
} }
pub fn is_debug_mode(r_debug: Res<DebugMode>) -> bool { pub fn is_debug_mode(r_debug: Res<DebugMode>) -> bool {
@@ -117,10 +113,11 @@ pub fn is_debug_mode(r_debug: Res<DebugMode>) -> bool {
} }
fn update_gizmo_line_thickness( fn update_gizmo_line_thickness(
mut config: ResMut<GizmoConfig>, mut config_store: ResMut<GizmoConfigStore>,
q_window: Query<&Window, (Changed<Window>, With<PrimaryWindow>)>, q_window: Query<&Window, (Changed<Window>, With<PrimaryWindow>)>,
) { ) {
if let Ok(scale_factor) = q_window.get_single().map(|win| win.scale_factor() as f32) { if let Ok(scale_factor) = q_window.get_single().map(|win| win.scale_factor() as f32) {
let (config, _) = config_store.config_mut::<DefaultGizmoConfigGroup>();
config.line_width = 2. * scale_factor; config.line_width = 2. * scale_factor;
} }
} }
+5 -3
View File
@@ -1,8 +1,7 @@
use std::time::Duration; use std::time::Duration;
use bevy::{ use bevy::{
app::{AppExit, ScheduleRunnerPlugin}, app::{AppExit, ScheduleRunnerPlugin}, core_pipeline::Skybox, prelude::*
prelude::*,
}; };
use space_editor::prelude::{EditorEvent, EditorPrefabPath}; use space_editor::prelude::{EditorEvent, EditorPrefabPath};
use wgpu::Extent3d; use wgpu::Extent3d;
@@ -74,7 +73,10 @@ pub fn start_headless(
app.add_systems( app.add_systems(
Startup, Startup,
move |mut cmd: Commands, mut ew: EventWriter<EditorEvent>| { move |mut cmd: Commands, mut ew: EventWriter<EditorEvent>| {
cmd.insert_resource(SkyboxId(skybox.clone())); cmd.insert_resource(Skybox {
image : skybox.clone(),
brightness: 1.0
});
ew.send(EditorEvent::Load(EditorPrefabPath::File(scene.clone()))) ew.send(EditorEvent::Load(EditorPrefabPath::File(scene.clone())))
}, },
); );
+1 -2
View File
@@ -1,6 +1,5 @@
use bevy::{ use bevy::{
prelude::*, ecs::entity::{EntityHashMap, EntityHashSet}, prelude::*
utils::{EntityHashMap, EntityHashSet},
}; };
/// Find the parent entity of `target`. Returns `None` if `target` has no /// Find the parent entity of `target`. Returns `None` if `target` has no
+13 -13
View File
@@ -90,7 +90,7 @@ impl From<Selection> for Action {
// TODO: Make the bindings of raw device inputs to InputActions configurable // TODO: Make the bindings of raw device inputs to InputActions configurable
fn translate_selection_events(keyboard: Res<Input<KeyCode>>, mut input: EventWriter<InputAction>) { fn translate_selection_events(keyboard: Res<ButtonInput<KeyCode>>, mut input: EventWriter<InputAction>) {
if keyboard.just_pressed(KeyCode::Escape) { if keyboard.just_pressed(KeyCode::Escape) {
input.send(InputAction(Lifecycle::Start, Selection::Clear.into())); input.send(InputAction(Lifecycle::Start, Selection::Clear.into()));
} else if keyboard.just_released(KeyCode::Escape) { } else if keyboard.just_released(KeyCode::Escape) {
@@ -110,7 +110,7 @@ fn translate_selection_events(keyboard: Res<Input<KeyCode>>, mut input: EventWri
} }
} }
fn translate_debug_toggle(keyboard: Res<Input<KeyCode>>, mut input: EventWriter<InputAction>) { fn translate_debug_toggle(keyboard: Res<ButtonInput<KeyCode>>, mut input: EventWriter<InputAction>) {
if keyboard.pressed(KeyCode::ControlLeft) || keyboard.pressed(KeyCode::ControlRight) { if keyboard.pressed(KeyCode::ControlLeft) || keyboard.pressed(KeyCode::ControlRight) {
if keyboard.just_pressed(KeyCode::Grave) { if keyboard.just_pressed(KeyCode::Grave) {
input.send(InputAction(Lifecycle::Start, Action::ToggleDebug)); input.send(InputAction(Lifecycle::Start, Action::ToggleDebug));
@@ -122,8 +122,8 @@ fn translate_debug_toggle(keyboard: Res<Input<KeyCode>>, mut input: EventWriter<
fn translate_dcc_camera_events( fn translate_dcc_camera_events(
mouse_motion: Res<LastFrameMouseDelta>, mouse_motion: Res<LastFrameMouseDelta>,
mouse_buttons: Res<Input<MouseButton>>, mouse_buttons: Res<ButtonInput<MouseButton>>,
keyboard: Res<Input<KeyCode>>, keyboard: Res<ButtonInput<KeyCode>>,
mut input: EventWriter<InputAction>, mut input: EventWriter<InputAction>,
) { ) {
let delta = mouse_motion.get(); let delta = mouse_motion.get();
@@ -227,12 +227,12 @@ fn translate_dcc_camera_events(
fn translate_fps_camera_events( fn translate_fps_camera_events(
mut mouse_wheel: EventReader<MouseWheel>, mut mouse_wheel: EventReader<MouseWheel>,
keyboard: Res<Input<KeyCode>>, keyboard: Res<ButtonInput<KeyCode>>,
mut input: EventWriter<InputAction>, mut input: EventWriter<InputAction>,
) { ) {
// Camera Translation (FPS-like) // Camera Translation (FPS-like)
use KeyCode::*; use KeyCode::*;
let wasd_keys = [W, A, S, D, E, Q]; let wasd_keys = [KeyCode::W, KeyCode::A, KeyCode::S, KeyCode::D, KeyCode::E, KeyCode::Q];
let wasd_keys_set = wasd_keys.into_iter().collect::<HashSet<_>>(); let wasd_keys_set = wasd_keys.into_iter().collect::<HashSet<_>>();
// A little unfortunate that `get_pressed()` doesn't just return a reference // A little unfortunate that `get_pressed()` doesn't just return a reference
@@ -247,12 +247,12 @@ fn translate_fps_camera_events(
let mut mvmt = Vec3::ZERO; let mut mvmt = Vec3::ZERO;
#[rustfmt::skip] { #[rustfmt::skip] {
if wasd_keys_pressed.contains(&W) { mvmt.z -= 1.; } if wasd_keys_pressed.contains(&KeyCode::W) { mvmt.z -= 1.; }
if wasd_keys_pressed.contains(&A) { mvmt.x -= 1.; } if wasd_keys_pressed.contains(&KeyCode::A) { mvmt.x -= 1.; }
if wasd_keys_pressed.contains(&S) { mvmt.z += 1.; } if wasd_keys_pressed.contains(&KeyCode::S) { mvmt.z += 1.; }
if wasd_keys_pressed.contains(&D) { mvmt.x += 1.; } if wasd_keys_pressed.contains(&KeyCode::D) { mvmt.x += 1.; }
if wasd_keys_pressed.contains(&E) { mvmt.y += 1.; } if wasd_keys_pressed.contains(&KeyCode::E) { mvmt.y += 1.; }
if wasd_keys_pressed.contains(&Q) { mvmt.y -= 1.; } if wasd_keys_pressed.contains(&KeyCode::Q) { mvmt.y -= 1.; }
}; };
let mvmt = mvmt.normalize_or_zero(); let mvmt = mvmt.normalize_or_zero();
@@ -333,7 +333,7 @@ fn read_mouse_delta(
} }
// TODO: Make it configurable // TODO: Make it configurable
fn send_undo_event(mut events: EventWriter<UndoRedo>, keyboard: Res<Input<KeyCode>>) { fn send_undo_event(mut events: EventWriter<UndoRedo>, keyboard: Res<ButtonInput<KeyCode>>) {
if keyboard.pressed(KeyCode::ControlLeft) if keyboard.pressed(KeyCode::ControlLeft)
&& keyboard.just_pressed(KeyCode::Z) && keyboard.just_pressed(KeyCode::Z)
&& !keyboard.pressed(KeyCode::ShiftLeft) && !keyboard.pressed(KeyCode::ShiftLeft)
+2 -3
View File
@@ -1,9 +1,9 @@
use bevy::{ use bevy::{
core_pipeline::{clear_color::ClearColorConfig, fxaa::Fxaa}, core_pipeline::fxaa::Fxaa,
prelude::*, prelude::*,
render::view::RenderLayers, render::view::RenderLayers,
}; };
use space_editor::space_editor_ui::NotShowCamera; use space_editor::space_editor_ui::camera_plugin::NotShowCamera;
use crate::MainCamera; use crate::MainCamera;
@@ -24,7 +24,6 @@ pub(super) fn spawn_gizmo_camera(
GizmoCamera, GizmoCamera,
Camera3dBundle { Camera3dBundle {
camera_3d: Camera3d { camera_3d: Camera3d {
clear_color: ClearColorConfig::None,
..default() ..default()
}, },
camera: Camera { camera: Camera {
+5 -5
View File
@@ -46,8 +46,8 @@ impl Plugin for GizmoPlugin {
app.add_systems( app.add_systems(
PreUpdate, PreUpdate,
spawn_gizmo_camera.run_if( spawn_gizmo_camera.run_if(
any_with_component::<MainCamera>() any_with_component::<MainCamera>
.and_then(not(any_with_component::<GizmoCamera>())), .and_then(not(any_with_component::<GizmoCamera>)),
), ),
); );
app.add_systems( app.add_systems(
@@ -55,11 +55,11 @@ impl Plugin for GizmoPlugin {
( (
despawn_existing_gizmo.run_if( despawn_existing_gizmo.run_if(
resource_changed_or_removed::<Selection>() resource_changed_or_removed::<Selection>()
.or_else(resource_changed::<TransformMode>()), .or_else(resource_changed::<TransformMode>),
), ),
spawn_gizmo.after(despawn_existing_gizmo).run_if( spawn_gizmo.after(despawn_existing_gizmo).run_if(
resource_exists::<Selection>() resource_exists::<Selection>
.and_then(not(any_with_component::<TransformGizmo>())), .and_then(not(any_with_component::<TransformGizmo>)),
), ),
(update_target_global_trasform, sync_gizmo_transform) (update_target_global_trasform, sync_gizmo_transform)
.chain() .chain()
+1 -1
View File
@@ -12,7 +12,7 @@ impl Plugin for MixamoPlugin {
Update, Update,
( (
import_mixamo_scene, import_mixamo_scene,
tick_mixamo_import.run_if(resource_exists::<MixamoImport>()), tick_mixamo_import.run_if(resource_exists::<MixamoImport>),
tick_scene_spawning.run_if(in_state(MixamoState::Spawning)), tick_scene_spawning.run_if(in_state(MixamoState::Spawning)),
start_mixamo_anim.run_if(in_state(MixamoState::Processing)), start_mixamo_anim.run_if(in_state(MixamoState::Processing)),
), ),
+24 -4
View File
@@ -3,7 +3,7 @@ use bevy::{
core_pipeline::{ core_pipeline::{
bloom::{BloomCompositeMode, BloomPrefilterSettings, BloomSettings}, bloom::{BloomCompositeMode, BloomPrefilterSettings, BloomSettings},
fxaa::Fxaa, fxaa::Fxaa,
tonemapping::Tonemapping, tonemapping::Tonemapping, Skybox,
}, },
gltf::Gltf, gltf::Gltf,
math::vec2, math::vec2,
@@ -43,7 +43,7 @@ impl Plugin for ScenePlugin {
app.insert_resource(ClearColor(Color::hsl(0.0, 0.0, 0.25))) app.insert_resource(ClearColor(Color::hsl(0.0, 0.0, 0.25)))
.insert_resource(Msaa::Off) .insert_resource(Msaa::Off)
.add_state::<SceneState>() .init_state::<SceneState>()
.add_event::<LoadLibraryObjectEvent>() .add_event::<LoadLibraryObjectEvent>()
.add_event::<LoadSceneEvent>() .add_event::<LoadSceneEvent>()
.add_event::<ImportSceneEvent>() .add_event::<ImportSceneEvent>()
@@ -72,6 +72,9 @@ impl Plugin for ScenePlugin {
app.add_systems(Update, tag_scene_elements); app.add_systems(Update, tag_scene_elements);
app.init_resource::<SkyboxHolder>();
app.add_systems(Update, attach_skybox);
//Auto loading screen //Auto loading screen
//Register handles on which we will look to show loading screen //Register handles on which we will look to show loading screen
app.init_resource::<LoadingQueue>(); app.init_resource::<LoadingQueue>();
@@ -95,13 +98,30 @@ impl Plugin for ScenePlugin {
wasm::dispatch_object_load_request, wasm::dispatch_object_load_request,
wasm::notify_state_changes wasm::notify_state_changes
.map(bevy::utils::error) .map(bevy::utils::error)
.run_if(resource_changed::<State<SceneState>>()), .run_if(resource_changed::<State<SceneState>>),
wasm::notify_loading_queue_changes.map(bevy::utils::error), wasm::notify_loading_queue_changes.map(bevy::utils::error),
), ),
); );
} }
} }
#[derive(Resource, Default)]
pub struct SkyboxHolder(pub Option<Skybox>);
fn attach_skybox(
mut cmd: Commands,
mut skybox_holder: ResMut<SkyboxHolder>,
mut q_camera: Query<Entity, (With<Camera3d>, Without<Skybox>)>
) {
let Some(skybox) = skybox_holder.0.as_ref() else {
return;
};
for entity in q_camera.iter_mut() {
cmd.entity(entity).insert(skybox.clone());
}
}
fn minimal_scene_setup(mut cmd: Commands) { fn minimal_scene_setup(mut cmd: Commands) {
cmd.spawn(( cmd.spawn((
Name::new("Directional Light"), Name::new("Directional Light"),
@@ -436,7 +456,7 @@ fn frame_scene_in_view(
// Project each corner onto the camera plane // Project each corner onto the camera plane
let v = p - plane_origin; let v = p - plane_origin;
let proj = p - v.project_onto_normalized(plane_normal); let proj = p - v.project_onto_normalized(plane_normal.xyz());
cmd.spawn(DebugPoint { cmd.spawn(DebugPoint {
point: proj, point: proj,
+4 -4
View File
@@ -51,15 +51,15 @@ impl Plugin for ScreenShotPlugin {
) )
//Render Graph Additions //Render Graph Additions
.add_render_graph_node::<ViewNodeRunner<ScreenCaptureNode>>( .add_render_graph_node::<ViewNodeRunner<ScreenCaptureNode>>(
core_3d::graph::NAME, core_3d::graph::Core3d,
ScreenCaptureNode::NAME, ScreenCaptureNode::NAME,
) )
.add_render_graph_edges( .add_render_graph_edges(
core_3d::graph::NAME, core_3d::graph::Core3d,
&[ &[
core_3d::graph::node::TONEMAPPING, core_3d::graph::Node3d::Tonemapping,
ScreenCaptureNode::NAME, ScreenCaptureNode::NAME,
core_3d::graph::node::END_MAIN_PASS_POST_PROCESSING, core_3d::graph::Node3d::EndMainPassPostProcessing,
], ],
); );
} }
+7 -3
View File
@@ -16,9 +16,9 @@ impl Plugin for SkyboxPlugin {
app.add_systems( app.add_systems(
Update, Update,
( (
load_skybox.run_if(resource_exists_and_changed::<SkyboxId>()), load_skybox.run_if(resource_exists_and_changed::<SkyboxId>),
spawn_skybox spawn_skybox
.run_if(resource_exists::<SkyboxAssets>()) .run_if(resource_exists::<SkyboxAssets>)
.run_if(skybox_assets_loaded), .run_if(skybox_assets_loaded),
), ),
); );
@@ -98,10 +98,14 @@ fn spawn_skybox(
// Add components to the scene camera // Add components to the scene camera
cmd.entity(q_camera.single()).insert(( cmd.entity(q_camera.single()).insert((
Skybox(skybox_assets.cubemap.clone()), Skybox {
image : skybox_assets.cubemap.clone(),
brightness: 1.0
},
EnvironmentMapLight { EnvironmentMapLight {
diffuse_map: skybox_assets.env_diffuse.clone(), diffuse_map: skybox_assets.env_diffuse.clone(),
specular_map: skybox_assets.env_specular.clone(), specular_map: skybox_assets.env_specular.clone(),
intensity: 1.0,
}, },
)); ));
+4 -4
View File
@@ -38,22 +38,22 @@ fn read_command_system(mut commands: Commands, mut change_event: EventWriter<New
match cmd { match cmd {
BlockingCommand::Cube => { BlockingCommand::Cube => {
new_entity new_entity
.insert(MeshPrimitivePrefab::Cube(1.0)) .insert(MeshPrimitive3dPrefab::Cube(1.0))
.insert(Name::new("Cube")); .insert(Name::new("Cube"));
} }
BlockingCommand::Sphere => { BlockingCommand::Sphere => {
new_entity new_entity
.insert(MeshPrimitivePrefab::Sphere(SpherePrefab { r: 1.0 })) .insert(MeshPrimitive3dPrefab::Sphere(SpherePrefab { r: 1.0 }))
.insert(Name::new("Sphere")); .insert(Name::new("Sphere"));
} }
BlockingCommand::Torus => { BlockingCommand::Torus => {
new_entity new_entity
.insert(MeshPrimitivePrefab::Torus(TorusPrefab::default())) .insert(MeshPrimitive3dPrefab::Torus(TorusPrefab::default()))
.insert(Name::new("Torus")); .insert(Name::new("Torus"));
} }
BlockingCommand::Cylinder => { BlockingCommand::Cylinder => {
new_entity new_entity
.insert(MeshPrimitivePrefab::Cylinder(CylinderPrefab::default())) .insert(MeshPrimitive3dPrefab::Cylinder(CylinderPrefab::default()))
.insert(Name::new("Cylinder")); .insert(Name::new("Cylinder"));
} }
}; };
+5 -5
View File
@@ -1,6 +1,5 @@
use bevy::{ use bevy::{
diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, a11y::accesskit::TextAlign, diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}, prelude::*
prelude::*,
}; };
use crate::debug::DebugMode; use crate::debug::DebugMode;
@@ -14,7 +13,7 @@ impl Plugin for FpsCounterPlugin {
.add_systems(Update, update) .add_systems(Update, update)
.add_systems( .add_systems(
Update, Update,
update_visibility.run_if(resource_exists_and_changed::<DebugMode>()), update_visibility.run_if(resource_exists_and_changed::<DebugMode>),
); );
} }
} }
@@ -31,11 +30,12 @@ fn layout(mut cmd: Commands) {
..default() ..default()
}, },
) )
.with_text_alignment(TextAlignment::Right) .with_text_justify(JustifyText::Right)
.with_style(Style { .with_style(Style {
position_type: PositionType::Absolute, position_type: PositionType::Absolute,
right: Val::Px(16.), right: Val::Px(16.),
bottom: Val::Px(16.), bottom: Val::Px(16.),
..default() ..default()
}); });
@@ -53,7 +53,7 @@ fn update(
diag: Res<DiagnosticsStore>, diag: Res<DiagnosticsStore>,
mut counter: Query<&mut Text, With<FramerateCounter>>, mut counter: Query<&mut Text, With<FramerateCounter>>,
) { ) {
if let Some(fps_diag) = diag.get(FrameTimeDiagnosticsPlugin::FPS) { if let Some(fps_diag) = diag.get(&FrameTimeDiagnosticsPlugin::FPS) {
let fps = if let Some(fps_smoothed) = fps_diag.smoothed() { let fps = if let Some(fps_smoothed) = fps_diag.smoothed() {
fps_smoothed fps_smoothed
} else { } else {
+2 -6
View File
@@ -10,11 +10,7 @@ use bevy::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json::*; use serde_json::*;
use space_editor::{ use space_editor::{
space_editor_ui::{ space_editor_ui::{editor_tab::{EditorTab, EditorTabName}, ui_plugin::EditorUiAppExt}, space_prefab::component::MeshPrimitive3dPrefab,
editor_tab::{EditorTab, EditorTabName},
EditorUiAppExt,
},
space_prefab::component::MeshPrimitivePrefab,
}; };
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
@@ -60,7 +56,7 @@ impl Plugin for InspectorPlugin {
app.register_inspect::<Transform>(); app.register_inspect::<Transform>();
app.register_inspect::<Name>(); app.register_inspect::<Name>();
app.register_inspect::<MeshPrimitivePrefab>(); app.register_inspect::<MeshPrimitive3dPrefab>();
//register standart material //register standart material
{ {