-
Notifications
You must be signed in to change notification settings - Fork 13
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
Update to Bevy 0.13 #232
base: main
Are you sure you want to change the base?
Update to Bevy 0.13 #232
Changes from 4 commits
324d9d3
4ee7629
f9896c7
8405dda
b0f4b55
ee73426
910c8e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,20 @@ name = "extending_site_editor" | |
path = "examples/extending_menu.rs" | ||
|
||
[dependencies] | ||
bevy_egui = "0.23" | ||
bevy_mod_raycast = "0.16" | ||
bevy_mod_outline = "0.6" | ||
# PR merged after 0.10 but not released yet, bump to 0.10.1 once merged | ||
bevy_infinite_grid = { git = "https://github.com/ForesightMiningSoftwareCorporation/bevy_infinite_grid", rev = "86018dd" } | ||
bevy_gltf_export = { git = "https://github.com/luca-della-vedova/bevy_gltf_export", branch = "luca/transform_api"} | ||
bevy_polyline = "0.8.1" | ||
bevy_stl = "0.12" | ||
bevy_obj = { version = "0.12.1", features = ["scene"] } | ||
bevy_mod_raycast = "0.17" | ||
bevy_mod_outline = "0.7" | ||
bevy_infinite_grid = "0.12" | ||
bevy_gltf_export = { git = "https://github.com/luca-della-vedova/bevy_gltf_export", branch = "bevy_0.13"} | ||
bevy_polyline = { git = "https://github.com/luca-della-vedova/bevy_polyline", branch = "luca/bevy_0.13_panic" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
bevy_stl = "0.13" | ||
bevy_obj = { version = "0.13", features = ["scene"] } | ||
smallvec = "*" | ||
serde = { version = "1.0", features = ["derive"] } | ||
serde_yaml = "0.8.23" | ||
serde_json = "1.0" | ||
wasm-bindgen = "0.2.87" | ||
futures-lite = "1.12.0" | ||
bevy = { version = "0.12", features = ["pnm", "jpeg", "tga"] } | ||
bevy = { version = "0.13", features = ["pnm", "jpeg", "tga"] } | ||
dirs = "5.0" | ||
thread_local = "*" | ||
geo = "0.27" | ||
|
@@ -55,6 +53,9 @@ nalgebra = "0.32.5" | |
|
||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies] | ||
clap = { version = "4.0.10", features = ["color", "derive", "help", "usage", "suggestions"] } | ||
bevy_egui = "0.27" | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
console_error_panic_hook = "0.1.7" | ||
# Disable the manage_clipboard feature, depends on nightly web features | ||
bevy_egui = { version = "0.27", features = ["open_url", "default_fonts", "render"] } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ref vladbat00/bevy_egui#270, |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ use bevy_polyline::{ | |
material::PolylineMaterial, | ||
polyline::{Polyline, PolylineBundle}, | ||
}; | ||
use shape::UVSphere; | ||
|
||
#[derive(Clone, Debug, Resource)] | ||
pub struct InteractionAssets { | ||
|
@@ -228,47 +227,42 @@ impl FromWorld for InteractionAssets { | |
let mut meshes = world.get_resource_mut::<Assets<Mesh>>().unwrap(); | ||
let dagger_mesh = meshes.add(make_dagger_mesh()); | ||
let halo_mesh = meshes.add(make_halo_mesh()); | ||
let camera_control_mesh = meshes.add(Mesh::from(UVSphere { | ||
let camera_control_mesh = meshes.add(Mesh::from(Sphere { | ||
radius: 0.02, | ||
..Default::default() | ||
})); | ||
let arrow_mesh = meshes.add(make_cylinder_arrow_mesh()); | ||
let point_light_socket_mesh = meshes.add( | ||
make_cylinder(0.06, 0.02) | ||
.transform_by(Affine3A::from_translation(0.04 * Vec3::Z)) | ||
.into(), | ||
make_cylinder(0.06, 0.02).transform_by(Affine3A::from_translation(0.04 * Vec3::Z)), | ||
); | ||
let point_light_shine_mesh = meshes.add(Mesh::from(shape::UVSphere { | ||
let point_light_shine_mesh = meshes.add(Mesh::from(Sphere { | ||
radius: 0.05, | ||
..Default::default() | ||
})); | ||
let spot_light_cover_mesh = meshes.add( | ||
make_smooth_wrap( | ||
[ | ||
Circle { | ||
radius: 0.05, | ||
height: 0.0, | ||
}, | ||
Circle { | ||
radius: 0.01, | ||
height: 0.04, | ||
}, | ||
], | ||
32, | ||
) | ||
.into(), | ||
); | ||
let spot_light_cover_mesh = meshes.add(make_smooth_wrap( | ||
[ | ||
OffsetCircle { | ||
radius: 0.05, | ||
height: 0.0, | ||
}, | ||
OffsetCircle { | ||
radius: 0.01, | ||
height: 0.04, | ||
}, | ||
], | ||
32, | ||
)); | ||
let spot_light_shine_mesh = meshes.add( | ||
Mesh::from( | ||
make_bottom_circle( | ||
Circle { | ||
OffsetCircle { | ||
Comment on lines
-267
to
+261
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
radius: 0.05, | ||
height: 0.0, | ||
}, | ||
32, | ||
) | ||
.merge_with(make_top_circle( | ||
Circle { | ||
OffsetCircle { | ||
radius: 0.01, | ||
height: 0.04, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,12 +16,10 @@ | |
*/ | ||
use crate::interaction::{InteractionAssets, PickingBlockers}; | ||
use bevy::{ | ||
core_pipeline::{ | ||
clear_color::ClearColorConfig, core_3d::Camera3dBundle, tonemapping::Tonemapping, | ||
}, | ||
core_pipeline::{core_3d::Camera3dBundle, tonemapping::Tonemapping}, | ||
prelude::*, | ||
render::{ | ||
camera::{Camera, Projection, ScalingMode}, | ||
camera::{Camera, Exposure, Projection, ScalingMode}, | ||
view::RenderLayers, | ||
}, | ||
}; | ||
|
@@ -61,6 +59,22 @@ pub const XRAY_RENDER_LAYER: u8 = 5; | |
/// models in the engine without having them being visible to general cameras | ||
pub const MODEL_PREVIEW_LAYER: u8 = 6; | ||
|
||
// Creates all the layers visible in the main camera view (excluding, for example | ||
// the model preview which is on a separate view). The main lights will affect these. | ||
pub fn main_view_render_layers() -> RenderLayers { | ||
RenderLayers::from_layers(&[ | ||
GENERAL_RENDER_LAYER, | ||
PHYSICAL_RENDER_LAYER, | ||
VISUAL_CUE_RENDER_LAYER, | ||
SELECTED_OUTLINE_LAYER, | ||
HOVERED_OUTLINE_LAYER, | ||
XRAY_RENDER_LAYER, | ||
]) | ||
} | ||
|
||
/// Camera exposure, adjusted for indoor lighting, in ev100 units | ||
pub const DEFAULT_CAMERA_EV100: f32 = 3.5; | ||
|
||
/// Camera limits | ||
pub const MIN_FOV: f32 = 5.0; | ||
pub const MAX_FOV: f32 = 120.0; | ||
|
@@ -257,11 +271,12 @@ impl FromWorld for CameraControls { | |
.spawn(DirectionalLightBundle { | ||
directional_light: DirectionalLight { | ||
shadows_enabled: false, | ||
illuminance: 20000., | ||
illuminance: 50., | ||
..default() | ||
}, | ||
..default() | ||
}) | ||
.insert(main_view_render_layers()) | ||
.id(); | ||
|
||
let perspective_child_cameras = [ | ||
|
@@ -273,12 +288,15 @@ impl FromWorld for CameraControls { | |
world | ||
.spawn(Camera3dBundle { | ||
projection: Projection::Perspective(Default::default()), | ||
camera: Camera { order, ..default() }, | ||
camera_3d: Camera3d { | ||
camera: Camera { | ||
order, | ||
clear_color: ClearColorConfig::None, | ||
..default() | ||
}, | ||
tonemapping: Tonemapping::ReinhardLuminance, | ||
exposure: Exposure { | ||
ev100: DEFAULT_CAMERA_EV100, | ||
}, | ||
..default() | ||
}) | ||
.insert(VisibilityBundle { | ||
|
@@ -293,6 +311,9 @@ impl FromWorld for CameraControls { | |
.spawn(Camera3dBundle { | ||
transform: Transform::from_xyz(-10., -10., 10.).looking_at(Vec3::ZERO, Vec3::Z), | ||
projection: Projection::Perspective(Default::default()), | ||
exposure: Exposure { | ||
ev100: DEFAULT_CAMERA_EV100, | ||
}, | ||
tonemapping: Tonemapping::ReinhardLuminance, | ||
..default() | ||
}) | ||
|
@@ -316,11 +337,12 @@ impl FromWorld for CameraControls { | |
)), | ||
directional_light: DirectionalLight { | ||
shadows_enabled: false, | ||
illuminance: 20000., | ||
illuminance: 50., | ||
..default() | ||
}, | ||
..default() | ||
}) | ||
.insert(main_view_render_layers()) | ||
.id(); | ||
|
||
let ortho_projection = OrthographicProjection { | ||
|
@@ -341,13 +363,13 @@ impl FromWorld for CameraControls { | |
camera: Camera { | ||
is_active: false, | ||
order, | ||
..default() | ||
}, | ||
camera_3d: Camera3d { | ||
clear_color: ClearColorConfig::None, | ||
..default() | ||
}, | ||
projection: Projection::Orthographic(ortho_projection.clone()), | ||
exposure: Exposure { | ||
ev100: DEFAULT_CAMERA_EV100, | ||
}, | ||
tonemapping: Tonemapping::ReinhardLuminance, | ||
..default() | ||
}) | ||
|
@@ -367,6 +389,9 @@ impl FromWorld for CameraControls { | |
}, | ||
transform: Transform::from_xyz(0., 0., 20.).looking_at(Vec3::ZERO, Vec3::Y), | ||
projection: Projection::Orthographic(ortho_projection), | ||
exposure: Exposure { | ||
ev100: DEFAULT_CAMERA_EV100, | ||
}, | ||
tonemapping: Tonemapping::ReinhardLuminance, | ||
..default() | ||
}) | ||
|
@@ -382,6 +407,12 @@ impl FromWorld for CameraControls { | |
.push_children(&orthographic_child_cameras) | ||
.id(); | ||
|
||
let mut ambient_light = world | ||
.get_resource_mut::<AmbientLight>() | ||
.expect("Make sure bevy's PbrPlugin is initialized before the cameras"); | ||
|
||
ambient_light.brightness = 2.0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we made everything a lot darker than default bevy, I also had to reduce the ambient light otherwise its effect would be overwhelming the rendering and everything would look washed out. |
||
|
||
CameraControls { | ||
mode: ProjectionMode::Perspective, | ||
perspective_camera_entities: [ | ||
|
@@ -463,7 +494,7 @@ fn camera_controls( | |
|
||
// Ensure upright | ||
let forward = persp_transform.forward(); | ||
persp_transform.look_to(forward, Vec3::Z); | ||
persp_transform.look_to(*forward, Vec3::Z); | ||
} | ||
|
||
let proj = persp_proj.clone(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lights in the bevy renderer itself don't use the alpha channel (and it's unclear what alpha even means for a light color), hence changed them to be RGB