mirror of
https://github.com/bevyengine/bevy
synced 2024-11-24 21:53:07 +00:00
Migrate cameras to required components (#15641)
# Objective Yet another PR for migrating stuff to required components. This time, cameras! ## Solution As per the [selected proposal](https://hackmd.io/tsYID4CGRiWxzsgawzxG_g#Combined-Proposal-1-Selected), deprecate `Camera2dBundle` and `Camera3dBundle` in favor of `Camera2d` and `Camera3d`. Adding a `Camera` without `Camera2d` or `Camera3d` now logs a warning, as suggested by Cart [on Discord](https://discord.com/channels/691052431525675048/1264881140007702558/1291506402832945273). I would personally like cameras to work a bit differently and be split into a few more components, to avoid some footguns and confusing semantics, but that is more controversial, and shouldn't block this core migration. ## Testing I ran a few 2D and 3D examples, and tried cameras with and without render graphs. --- ## Migration Guide `Camera2dBundle` and `Camera3dBundle` have been deprecated in favor of `Camera2d` and `Camera3d`. Inserting them will now also insert the other components required by them automatically.
This commit is contained in:
parent
ac9b0c848c
commit
25bfa80e60
241 changed files with 871 additions and 970 deletions
|
@ -346,7 +346,7 @@ android_shared_stdcxx = ["bevy_internal/android_shared_stdcxx"]
|
||||||
# Enable detailed trace event logging. These trace events are expensive even when off, thus they require compile time opt-in
|
# Enable detailed trace event logging. These trace events are expensive even when off, thus they require compile time opt-in
|
||||||
detailed_trace = ["bevy_internal/detailed_trace"]
|
detailed_trace = ["bevy_internal/detailed_trace"]
|
||||||
|
|
||||||
# Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.
|
# Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method for your `Camera2d` or `Camera3d`.
|
||||||
tonemapping_luts = ["bevy_internal/tonemapping_luts", "ktx2", "zstd"]
|
tonemapping_luts = ["bevy_internal/tonemapping_luts", "ktx2", "zstd"]
|
||||||
|
|
||||||
# Include SMAA Look Up Tables KTX2 Files
|
# Include SMAA Look Up Tables KTX2 Files
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![expect(deprecated)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
core_2d::graph::Core2d,
|
core_2d::graph::Core2d,
|
||||||
tonemapping::{DebandDither, Tonemapping},
|
tonemapping::{DebandDither, Tonemapping},
|
||||||
|
@ -17,12 +19,25 @@ use bevy_render::{
|
||||||
};
|
};
|
||||||
use bevy_transform::prelude::{GlobalTransform, Transform};
|
use bevy_transform::prelude::{GlobalTransform, Transform};
|
||||||
|
|
||||||
|
/// A 2D camera component. Enables the 2D render graph for a [`Camera`].
|
||||||
#[derive(Component, Default, Reflect, Clone, ExtractComponent)]
|
#[derive(Component, Default, Reflect, Clone, ExtractComponent)]
|
||||||
#[extract_component_filter(With<Camera>)]
|
#[extract_component_filter(With<Camera>)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default)]
|
||||||
|
#[require(
|
||||||
|
Camera,
|
||||||
|
DebandDither,
|
||||||
|
CameraRenderGraph(|| CameraRenderGraph::new(Core2d)),
|
||||||
|
OrthographicProjection(OrthographicProjection::default_2d),
|
||||||
|
Frustum(|| OrthographicProjection::default_2d().compute_frustum(&GlobalTransform::from(Transform::default()))),
|
||||||
|
Tonemapping(|| Tonemapping::None),
|
||||||
|
)]
|
||||||
pub struct Camera2d;
|
pub struct Camera2d;
|
||||||
|
|
||||||
#[derive(Bundle, Clone)]
|
#[derive(Bundle, Clone)]
|
||||||
|
#[deprecated(
|
||||||
|
since = "0.15.0",
|
||||||
|
note = "Use the `Camera2d` component instead. Inserting it will now also insert the other components required by it automatically."
|
||||||
|
)]
|
||||||
pub struct Camera2dBundle {
|
pub struct Camera2dBundle {
|
||||||
pub camera: Camera,
|
pub camera: Camera,
|
||||||
pub camera_render_graph: CameraRenderGraph,
|
pub camera_render_graph: CameraRenderGraph,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#![expect(deprecated)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
core_3d::graph::Core3d,
|
core_3d::graph::Core3d,
|
||||||
tonemapping::{DebandDither, Tonemapping},
|
tonemapping::{DebandDither, Tonemapping},
|
||||||
|
@ -15,12 +17,22 @@ use bevy_render::{
|
||||||
use bevy_transform::prelude::{GlobalTransform, Transform};
|
use bevy_transform::prelude::{GlobalTransform, Transform};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
/// Configuration for the "main 3d render graph".
|
/// A 3D camera component. Enables the main 3D render graph for a [`Camera`].
|
||||||
/// The camera coordinate space is right-handed x-right, y-up, z-back.
|
///
|
||||||
|
/// The camera coordinate space is right-handed X-right, Y-up, Z-back.
|
||||||
/// This means "forward" is -Z.
|
/// This means "forward" is -Z.
|
||||||
#[derive(Component, Reflect, Clone, ExtractComponent)]
|
#[derive(Component, Reflect, Clone, ExtractComponent)]
|
||||||
#[extract_component_filter(With<Camera>)]
|
#[extract_component_filter(With<Camera>)]
|
||||||
#[reflect(Component, Default)]
|
#[reflect(Component, Default)]
|
||||||
|
#[require(
|
||||||
|
Camera,
|
||||||
|
DebandDither(|| DebandDither::Enabled),
|
||||||
|
CameraRenderGraph(|| CameraRenderGraph::new(Core3d)),
|
||||||
|
Projection,
|
||||||
|
Tonemapping,
|
||||||
|
ColorGrading,
|
||||||
|
Exposure
|
||||||
|
)]
|
||||||
pub struct Camera3d {
|
pub struct Camera3d {
|
||||||
/// The depth clear operation to perform for the main 3d pass.
|
/// The depth clear operation to perform for the main 3d pass.
|
||||||
pub depth_load_op: Camera3dDepthLoadOp,
|
pub depth_load_op: Camera3dDepthLoadOp,
|
||||||
|
@ -139,6 +151,10 @@ pub enum ScreenSpaceTransmissionQuality {
|
||||||
/// The camera coordinate space is right-handed x-right, y-up, z-back.
|
/// The camera coordinate space is right-handed x-right, y-up, z-back.
|
||||||
/// This means "forward" is -Z.
|
/// This means "forward" is -Z.
|
||||||
#[derive(Bundle, Clone)]
|
#[derive(Bundle, Clone)]
|
||||||
|
#[deprecated(
|
||||||
|
since = "0.15.0",
|
||||||
|
note = "Use the `Camera3d` component instead. Inserting it will now also insert the other components required by it automatically."
|
||||||
|
)]
|
||||||
pub struct Camera3dBundle {
|
pub struct Camera3dBundle {
|
||||||
pub camera: Camera,
|
pub camera: Camera,
|
||||||
pub camera_render_graph: CameraRenderGraph,
|
pub camera_render_graph: CameraRenderGraph,
|
||||||
|
|
|
@ -45,6 +45,7 @@ pub mod experimental {
|
||||||
/// The core pipeline prelude.
|
/// The core pipeline prelude.
|
||||||
///
|
///
|
||||||
/// This includes the most common types in this crate, re-exported for your convenience.
|
/// This includes the most common types in this crate, re-exported for your convenience.
|
||||||
|
#[expect(deprecated)]
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
|
|
|
@ -59,11 +59,11 @@ pub struct MotionBlurBundle {
|
||||||
/// camera.
|
/// camera.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_core_pipeline::{core_3d::Camera3dBundle, motion_blur::MotionBlur};
|
/// # use bevy_core_pipeline::{core_3d::Camera3d, motion_blur::MotionBlur};
|
||||||
/// # use bevy_ecs::prelude::*;
|
/// # use bevy_ecs::prelude::*;
|
||||||
/// # fn test(mut commands: Commands) {
|
/// # fn test(mut commands: Commands) {
|
||||||
/// commands.spawn((
|
/// commands.spawn((
|
||||||
/// Camera3dBundle::default(),
|
/// Camera3d::default(),
|
||||||
/// MotionBlur::default(),
|
/// MotionBlur::default(),
|
||||||
/// ));
|
/// ));
|
||||||
/// # }
|
/// # }
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline {
|
||||||
error!(
|
error!(
|
||||||
"AgX tonemapping requires the `tonemapping_luts` feature.
|
"AgX tonemapping requires the `tonemapping_luts` feature.
|
||||||
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
|
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
|
||||||
or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`."
|
or use a different `Tonemapping` method for your `Camera2d`/`Camera3d`."
|
||||||
);
|
);
|
||||||
shader_defs.push("TONEMAP_METHOD_AGX".into());
|
shader_defs.push("TONEMAP_METHOD_AGX".into());
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline {
|
||||||
error!(
|
error!(
|
||||||
"TonyMcMapFace tonemapping requires the `tonemapping_luts` feature.
|
"TonyMcMapFace tonemapping requires the `tonemapping_luts` feature.
|
||||||
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
|
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
|
||||||
or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`."
|
or use a different `Tonemapping` method for your `Camera2d`/`Camera3d`."
|
||||||
);
|
);
|
||||||
shader_defs.push("TONEMAP_METHOD_TONY_MC_MAPFACE".into());
|
shader_defs.push("TONEMAP_METHOD_TONY_MC_MAPFACE".into());
|
||||||
}
|
}
|
||||||
|
@ -284,7 +284,7 @@ impl SpecializedRenderPipeline for TonemappingPipeline {
|
||||||
error!(
|
error!(
|
||||||
"BlenderFilmic tonemapping requires the `tonemapping_luts` feature.
|
"BlenderFilmic tonemapping requires the `tonemapping_luts` feature.
|
||||||
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
|
Either enable the `tonemapping_luts` feature for bevy in `Cargo.toml` (recommended),
|
||||||
or use a different `Tonemapping` method in your `Camera2dBundle`/`Camera3dBundle`."
|
or use a different `Tonemapping` method for your `Camera2d`/`Camera3d`."
|
||||||
);
|
);
|
||||||
shader_defs.push("TONEMAP_METHOD_BLENDER_FILMIC".into());
|
shader_defs.push("TONEMAP_METHOD_BLENDER_FILMIC".into());
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use core::any::{Any, TypeId};
|
||||||
use bevy_app::{App, Plugin, PostUpdate};
|
use bevy_app::{App, Plugin, PostUpdate};
|
||||||
use bevy_color::Hsla;
|
use bevy_color::Hsla;
|
||||||
use bevy_core::Name;
|
use bevy_core::Name;
|
||||||
use bevy_core_pipeline::core_2d::Camera2dBundle;
|
use bevy_core_pipeline::core_2d::Camera2d;
|
||||||
use bevy_ecs::{prelude::*, system::SystemParam};
|
use bevy_ecs::{prelude::*, system::SystemParam};
|
||||||
use bevy_gizmos::{config::GizmoConfigStore, prelude::Gizmos, AppGizmoBuilder};
|
use bevy_gizmos::{config::GizmoConfigStore, prelude::Gizmos, AppGizmoBuilder};
|
||||||
use bevy_hierarchy::{Children, Parent};
|
use bevy_hierarchy::{Children, Parent};
|
||||||
|
@ -88,17 +88,15 @@ fn update_debug_camera(
|
||||||
} else {
|
} else {
|
||||||
let spawn_cam = || {
|
let spawn_cam = || {
|
||||||
cmds.spawn((
|
cmds.spawn((
|
||||||
Camera2dBundle {
|
Camera2d,
|
||||||
projection: OrthographicProjection {
|
OrthographicProjection {
|
||||||
far: 1000.0,
|
far: 1000.0,
|
||||||
viewport_origin: Vec2::new(0.0, 0.0),
|
viewport_origin: Vec2::new(0.0, 0.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
},
|
},
|
||||||
camera: Camera {
|
Camera {
|
||||||
order: LAYOUT_DEBUG_CAMERA_ORDER,
|
order: LAYOUT_DEBUG_CAMERA_ORDER,
|
||||||
clear_color: ClearColorConfig::None,
|
clear_color: ClearColorConfig::None,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
LAYOUT_DEBUG_LAYERS.clone(),
|
LAYOUT_DEBUG_LAYERS.clone(),
|
||||||
|
|
|
@ -55,9 +55,6 @@ use core::{any::TypeId, ptr::NonNull};
|
||||||
/// would create incoherent behavior.
|
/// would create incoherent behavior.
|
||||||
/// This would be unexpected if bundles were treated as an abstraction boundary, as
|
/// This would be unexpected if bundles were treated as an abstraction boundary, as
|
||||||
/// the abstraction would be unmaintainable for these cases.
|
/// the abstraction would be unmaintainable for these cases.
|
||||||
/// For example, both `Camera3dBundle` and `Camera2dBundle` contain the `CameraRenderGraph`
|
|
||||||
/// component, but specifying different render graphs to use.
|
|
||||||
/// If the bundles were both added to the same entity, only one of these two bundles would work.
|
|
||||||
///
|
///
|
||||||
/// For this reason, there is intentionally no [`Query`] to match whether an entity
|
/// For this reason, there is intentionally no [`Query`] to match whether an entity
|
||||||
/// contains the components of a bundle.
|
/// contains the components of a bundle.
|
||||||
|
|
|
@ -9,7 +9,7 @@ use bevy_asset::{
|
||||||
};
|
};
|
||||||
use bevy_color::{Color, LinearRgba};
|
use bevy_color::{Color, LinearRgba};
|
||||||
use bevy_core::Name;
|
use bevy_core::Name;
|
||||||
use bevy_core_pipeline::prelude::Camera3dBundle;
|
use bevy_core_pipeline::prelude::Camera3d;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::{Entity, EntityHashMap},
|
entity::{Entity, EntityHashMap},
|
||||||
world::World,
|
world::World,
|
||||||
|
@ -1413,15 +1413,15 @@ fn load_node(
|
||||||
Projection::Perspective(perspective_projection)
|
Projection::Perspective(perspective_projection)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
node.insert(Camera3dBundle {
|
node.insert((
|
||||||
|
Camera3d::default(),
|
||||||
projection,
|
projection,
|
||||||
transform,
|
transform,
|
||||||
camera: Camera {
|
Camera {
|
||||||
is_active: !*active_camera_found,
|
is_active: !*active_camera_found,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
..Default::default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
*active_camera_found = true;
|
*active_camera_found = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,10 +29,7 @@ use bevy_render::{extract_component::ExtractComponent, prelude::Camera};
|
||||||
/// # fn system(mut commands: Commands) {
|
/// # fn system(mut commands: Commands) {
|
||||||
/// commands.spawn((
|
/// commands.spawn((
|
||||||
/// // Setup your camera as usual
|
/// // Setup your camera as usual
|
||||||
/// Camera3dBundle {
|
/// Camera3d::default(),
|
||||||
/// // ... camera options
|
|
||||||
/// # ..Default::default()
|
|
||||||
/// },
|
|
||||||
/// // Add fog to the same entity
|
/// // Add fog to the same entity
|
||||||
/// DistanceFog {
|
/// DistanceFog {
|
||||||
/// color: Color::WHITE,
|
/// color: Color::WHITE,
|
||||||
|
|
|
@ -8,27 +8,29 @@ use crate::{
|
||||||
render_resource::TextureView,
|
render_resource::TextureView,
|
||||||
texture::GpuImage,
|
texture::GpuImage,
|
||||||
view::{
|
view::{
|
||||||
ColorGrading, ExtractedView, ExtractedWindows, GpuCulling, RenderLayers, VisibleEntities,
|
ColorGrading, ExtractedView, ExtractedWindows, GpuCulling, Msaa, RenderLayers, Visibility,
|
||||||
|
VisibleEntities,
|
||||||
},
|
},
|
||||||
world_sync::RenderEntity,
|
world_sync::{RenderEntity, SyncToRenderWorld},
|
||||||
Extract,
|
Extract,
|
||||||
};
|
};
|
||||||
use bevy_asset::{AssetEvent, AssetId, Assets, Handle};
|
use bevy_asset::{AssetEvent, AssetId, Assets, Handle};
|
||||||
use bevy_derive::{Deref, DerefMut};
|
use bevy_derive::{Deref, DerefMut};
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
change_detection::DetectChanges,
|
change_detection::DetectChanges,
|
||||||
component::Component,
|
component::{Component, ComponentId},
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
event::EventReader,
|
event::EventReader,
|
||||||
prelude::With,
|
prelude::With,
|
||||||
query::Has,
|
query::Has,
|
||||||
reflect::ReflectComponent,
|
reflect::ReflectComponent,
|
||||||
system::{Commands, Query, Res, ResMut, Resource},
|
system::{Commands, Query, Res, ResMut, Resource},
|
||||||
|
world::DeferredWorld,
|
||||||
};
|
};
|
||||||
use bevy_math::{ops, vec2, Dir3, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3};
|
use bevy_math::{ops, vec2, Dir3, Mat4, Ray3d, Rect, URect, UVec2, UVec4, Vec2, Vec3};
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bevy_render_macros::ExtractComponent;
|
use bevy_render_macros::ExtractComponent;
|
||||||
use bevy_transform::components::GlobalTransform;
|
use bevy_transform::components::{GlobalTransform, Transform};
|
||||||
use bevy_utils::{tracing::warn, warn_once, HashMap, HashSet};
|
use bevy_utils::{tracing::warn, warn_once, HashMap, HashSet};
|
||||||
use bevy_window::{
|
use bevy_window::{
|
||||||
NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized,
|
NormalizedWindowRef, PrimaryWindow, Window, WindowCreated, WindowRef, WindowResized,
|
||||||
|
@ -274,10 +276,25 @@ pub enum ViewportConversionError {
|
||||||
/// to transform the 3D objects into a 2D image, as well as the render target into which that image
|
/// to transform the 3D objects into a 2D image, as well as the render target into which that image
|
||||||
/// is produced.
|
/// is produced.
|
||||||
///
|
///
|
||||||
/// Adding a camera is typically done by adding a bundle, either the `Camera2dBundle` or the
|
/// Note that a [`Camera`] needs a [`CameraRenderGraph`] to render anything.
|
||||||
/// `Camera3dBundle`.
|
/// This is typically provided by adding a [`Camera2d`] or [`Camera3d`] component,
|
||||||
|
/// but custom render graphs can also be defined. Inserting a [`Camera`] with no render
|
||||||
|
/// graph will emit an error at runtime.
|
||||||
|
///
|
||||||
|
/// [`Camera2d`]: https://docs.rs/crate/bevy_core_pipeline/latest/core_2d/struct.Camera2d.html
|
||||||
|
/// [`Camera3d`]: https://docs.rs/crate/bevy_core_pipeline/latest/core_3d/struct.Camera3d.html
|
||||||
#[derive(Component, Debug, Reflect, Clone)]
|
#[derive(Component, Debug, Reflect, Clone)]
|
||||||
#[reflect(Component, Default, Debug)]
|
#[reflect(Component, Default, Debug)]
|
||||||
|
#[component(on_add = warn_on_no_render_graph)]
|
||||||
|
#[require(
|
||||||
|
Frustum,
|
||||||
|
CameraMainTextureUsages,
|
||||||
|
VisibleEntities,
|
||||||
|
Transform,
|
||||||
|
Visibility,
|
||||||
|
Msaa,
|
||||||
|
SyncToRenderWorld
|
||||||
|
)]
|
||||||
pub struct Camera {
|
pub struct Camera {
|
||||||
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
|
/// If set, this camera will render to the given [`Viewport`] rectangle within the configured [`RenderTarget`].
|
||||||
pub viewport: Option<Viewport>,
|
pub viewport: Option<Viewport>,
|
||||||
|
@ -309,6 +326,12 @@ pub struct Camera {
|
||||||
pub sub_camera_view: Option<SubCameraView>,
|
pub sub_camera_view: Option<SubCameraView>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn warn_on_no_render_graph(world: DeferredWorld, entity: Entity, _: ComponentId) {
|
||||||
|
if !world.entity(entity).contains::<CameraRenderGraph>() {
|
||||||
|
warn!("Entity {entity} has a `Camera` component, but it doesn't have a render graph configured. Consider adding a `Camera2d` or `Camera3d` component, or manually adding a `CameraRenderGraph` component if you need a custom render graph.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Camera {
|
impl Default for Camera {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -200,8 +200,7 @@ impl HalfSpace {
|
||||||
/// This process is called frustum culling, and entities can opt out of it using
|
/// This process is called frustum culling, and entities can opt out of it using
|
||||||
/// the [`NoFrustumCulling`] component.
|
/// the [`NoFrustumCulling`] component.
|
||||||
///
|
///
|
||||||
/// The frustum component is typically added from a bundle, either the `Camera2dBundle`
|
/// The frustum component is typically added automatically for cameras, either `Camera2d` or `Camera3d`.
|
||||||
/// or the `Camera3dBundle`.
|
|
||||||
/// It is usually updated automatically by [`update_frusta`] from the
|
/// It is usually updated automatically by [`update_frusta`] from the
|
||||||
/// [`CameraProjection`] component and [`GlobalTransform`] of the camera entity.
|
/// [`CameraProjection`] component and [`GlobalTransform`] of the camera entity.
|
||||||
///
|
///
|
||||||
|
|
|
@ -27,7 +27,7 @@ use bevy_transform::prelude::{GlobalTransform, Transform};
|
||||||
use bevy_utils::HashSet;
|
use bevy_utils::HashSet;
|
||||||
use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged};
|
use bevy_window::{PrimaryWindow, Window, WindowScaleFactorChanged};
|
||||||
|
|
||||||
/// The bundle of components needed to draw text in a 2D scene via a 2D `Camera2dBundle`.
|
/// The bundle of components needed to draw text in a 2D scene via a `Camera2d`.
|
||||||
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/2d/text2d.rs)
|
/// [Example usage.](https://github.com/bevyengine/bevy/blob/latest/examples/2d/text2d.rs)
|
||||||
#[derive(Bundle, Clone, Debug, Default)]
|
#[derive(Bundle, Clone, Debug, Default)]
|
||||||
pub struct Text2dBundle {
|
pub struct Text2dBundle {
|
||||||
|
|
|
@ -464,7 +464,7 @@ mod tests {
|
||||||
use taffy::TraversePartialTree;
|
use taffy::TraversePartialTree;
|
||||||
|
|
||||||
use bevy_asset::{AssetEvent, Assets};
|
use bevy_asset::{AssetEvent, Assets};
|
||||||
use bevy_core_pipeline::core_2d::Camera2dBundle;
|
use bevy_core_pipeline::core_2d::Camera2d;
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
event::Events,
|
event::Events,
|
||||||
|
@ -539,7 +539,7 @@ mod tests {
|
||||||
},
|
},
|
||||||
PrimaryWindow,
|
PrimaryWindow,
|
||||||
));
|
));
|
||||||
world.spawn(Camera2dBundle::default());
|
world.spawn(Camera2d);
|
||||||
|
|
||||||
let mut ui_schedule = Schedule::default();
|
let mut ui_schedule = Schedule::default();
|
||||||
ui_schedule.add_systems(
|
ui_schedule.add_systems(
|
||||||
|
@ -646,7 +646,7 @@ mod tests {
|
||||||
assert!(ui_surface.camera_entity_to_taffy.is_empty());
|
assert!(ui_surface.camera_entity_to_taffy.is_empty());
|
||||||
|
|
||||||
// respawn camera
|
// respawn camera
|
||||||
let camera_entity = world.spawn(Camera2dBundle::default()).id();
|
let camera_entity = world.spawn(Camera2d).id();
|
||||||
|
|
||||||
let ui_entity = world
|
let ui_entity = world
|
||||||
.spawn((NodeBundle::default(), TargetCamera(camera_entity)))
|
.spawn((NodeBundle::default(), TargetCamera(camera_entity)))
|
||||||
|
@ -970,13 +970,13 @@ mod tests {
|
||||||
|
|
||||||
let (mut world, mut ui_schedule) = setup_ui_test_world();
|
let (mut world, mut ui_schedule) = setup_ui_test_world();
|
||||||
|
|
||||||
world.spawn(Camera2dBundle {
|
world.spawn((
|
||||||
camera: Camera {
|
Camera2d,
|
||||||
|
Camera {
|
||||||
order: 1,
|
order: 1,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
world.spawn((
|
world.spawn((
|
||||||
NodeBundle {
|
NodeBundle {
|
||||||
|
|
|
@ -2437,7 +2437,7 @@ impl TargetCamera {
|
||||||
/// # use bevy_ui::prelude::*;
|
/// # use bevy_ui::prelude::*;
|
||||||
/// # use bevy_ecs::prelude::Commands;
|
/// # use bevy_ecs::prelude::Commands;
|
||||||
/// # use bevy_render::camera::{Camera, RenderTarget};
|
/// # use bevy_render::camera::{Camera, RenderTarget};
|
||||||
/// # use bevy_core_pipeline::prelude::Camera2dBundle;
|
/// # use bevy_core_pipeline::prelude::Camera2d;
|
||||||
/// # use bevy_window::{Window, WindowRef};
|
/// # use bevy_window::{Window, WindowRef};
|
||||||
///
|
///
|
||||||
/// fn spawn_camera(mut commands: Commands) {
|
/// fn spawn_camera(mut commands: Commands) {
|
||||||
|
@ -2446,11 +2446,9 @@ impl TargetCamera {
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// }).id();
|
/// }).id();
|
||||||
/// commands.spawn((
|
/// commands.spawn((
|
||||||
/// Camera2dBundle {
|
/// Camera2d,
|
||||||
/// camera: Camera {
|
/// Camera {
|
||||||
/// target: RenderTarget::Window(WindowRef::Entity(another_window)),
|
/// target: RenderTarget::Window(WindowRef::Entity(another_window)),
|
||||||
/// ..Default::default()
|
|
||||||
/// },
|
|
||||||
/// ..Default::default()
|
/// ..Default::default()
|
||||||
/// },
|
/// },
|
||||||
/// // We add the Marker here so all Ui will spawn in
|
/// // We add the Marker here so all Ui will spawn in
|
||||||
|
@ -2502,7 +2500,7 @@ impl<'w, 's> DefaultUiCamera<'w, 's> {
|
||||||
///
|
///
|
||||||
/// fn spawn_camera(mut commands: Commands) {
|
/// fn spawn_camera(mut commands: Commands) {
|
||||||
/// commands.spawn((
|
/// commands.spawn((
|
||||||
/// Camera2dBundle::default(),
|
/// Camera2d,
|
||||||
/// // This will cause all Ui in this camera to be rendered without
|
/// // This will cause all Ui in this camera to be rendered without
|
||||||
/// // anti-aliasing
|
/// // anti-aliasing
|
||||||
/// UiAntiAlias::Off,
|
/// UiAntiAlias::Off,
|
||||||
|
|
|
@ -41,7 +41,7 @@ The default feature set enables most of the expected features of a game engine,
|
||||||
|png|PNG image format support|
|
|png|PNG image format support|
|
||||||
|smaa_luts|Include SMAA Look Up Tables KTX2 Files|
|
|smaa_luts|Include SMAA Look Up Tables KTX2 Files|
|
||||||
|sysinfo_plugin|Enables system information diagnostic plugin|
|
|sysinfo_plugin|Enables system information diagnostic plugin|
|
||||||
|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.|
|
|tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method for your `Camera2d` or `Camera3d`.|
|
||||||
|vorbis|OGG/VORBIS audio format support|
|
|vorbis|OGG/VORBIS audio format support|
|
||||||
|webgl2|Enable some limitations to be able to use WebGL2. Please refer to the [WebGL2 and WebGPU](https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu) section of the examples README for more information on how to run Wasm builds with WebGPU.|
|
|webgl2|Enable some limitations to be able to use WebGL2. Please refer to the [WebGL2 and WebGPU](https://github.com/bevyengine/bevy/tree/latest/examples#webgl2-and-webgpu) section of the examples README for more information on how to run Wasm builds with WebGPU.|
|
||||||
|x11|X11 display server support|
|
|x11|X11 display server support|
|
||||||
|
|
|
@ -40,10 +40,10 @@ fn setup_cube(
|
||||||
});
|
});
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -83,10 +83,10 @@ fn setup_cube(
|
||||||
});
|
});
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn setup(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
let shapes = [
|
let shapes = [
|
||||||
meshes.add(Circle::new(50.0)),
|
meshes.add(Circle::new(50.0)),
|
||||||
|
|
|
@ -34,5 +34,5 @@ fn draw_cursor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,15 +23,13 @@ fn setup(
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera2dBundle {
|
Camera2d,
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true, // 1. HDR is required for bloom
|
hdr: true, // 1. HDR is required for bloom
|
||||||
..default()
|
|
||||||
},
|
|
||||||
tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
Bloom::default(), // 3. Enable bloom for the camera
|
Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended
|
||||||
|
Bloom::default(), // 3. Enable bloom for the camera
|
||||||
));
|
));
|
||||||
|
|
||||||
// Sprite
|
// Sprite
|
||||||
|
|
|
@ -206,7 +206,7 @@ const OFFSET_X: f32 = 125.;
|
||||||
const OFFSET_Y: f32 = 75.;
|
const OFFSET_Y: f32 = 75.;
|
||||||
|
|
||||||
fn setup(mut commands: Commands) {
|
fn setup(mut commands: Commands) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
SpatialBundle {
|
SpatialBundle {
|
||||||
transform: Transform::from_xyz(-OFFSET_X, OFFSET_Y, 0.),
|
transform: Transform::from_xyz(-OFFSET_X, OFFSET_Y, 0.),
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Add a camera
|
// Add a camera
|
||||||
commands.spawn(Camera2dBundle { ..default() });
|
commands.spawn(Camera2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This custom material uses barycentric coordinates from
|
/// This custom material uses barycentric coordinates from
|
||||||
|
|
|
@ -14,7 +14,7 @@ fn setup(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Mesh2d(meshes.add(Rectangle::default())),
|
Mesh2d(meshes.add(Rectangle::default())),
|
||||||
MeshMaterial2d(materials.add(Color::from(PURPLE))),
|
MeshMaterial2d(materials.add(Color::from(PURPLE))),
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn setup(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<ColorMaterial>>,
|
mut materials: ResMut<Assets<ColorMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
let texture_handle = asset_server.load("branding/icon.png");
|
let texture_handle = asset_server.load("branding/icon.png");
|
||||||
let mesh_handle = meshes.add(Rectangle::from_size(Vec2::splat(256.0)));
|
let mesh_handle = meshes.add(Rectangle::from_size(Vec2::splat(256.0)));
|
||||||
|
|
|
@ -39,13 +39,13 @@ fn setup(
|
||||||
) {
|
) {
|
||||||
let material = materials.add(asset_server.load("branding/icon.png"));
|
let material = materials.add(asset_server.load("branding/icon.png"));
|
||||||
|
|
||||||
commands.spawn(Camera2dBundle {
|
commands.spawn((
|
||||||
camera: Camera {
|
Camera2d,
|
||||||
|
Camera {
|
||||||
clear_color: ClearColorConfig::Custom(DARK_SLATE_GREY.into()),
|
clear_color: ClearColorConfig::Custom(DARK_SLATE_GREY.into()),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
const UPPER_Y: f32 = 50.0;
|
const UPPER_Y: f32 = 50.0;
|
||||||
const LOWER_Y: f32 = -50.0;
|
const LOWER_Y: f32 = -50.0;
|
||||||
|
|
|
@ -115,7 +115,7 @@ fn star(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Spawn the camera
|
// Spawn the camera
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Require `HasMaterial2d` to indicate that no placeholder material should be rendeed.
|
// Require `HasMaterial2d` to indicate that no placeholder material should be rendeed.
|
||||||
|
|
|
@ -33,7 +33,7 @@ fn setup(
|
||||||
let mesh_handle = meshes.add(mesh);
|
let mesh_handle = meshes.add(mesh);
|
||||||
|
|
||||||
// Spawn camera
|
// Spawn camera
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
// Spawn the quad with vertex colors
|
// Spawn the quad with vertex colors
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
|
@ -17,7 +17,7 @@ enum Direction {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
SpriteBundle {
|
SpriteBundle {
|
||||||
texture: asset_server.load("branding/icon.png"),
|
texture: asset_server.load("branding/icon.png"),
|
||||||
|
|
|
@ -119,16 +119,14 @@ fn setup_camera(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
|
||||||
|
|
||||||
// this camera renders whatever is on `PIXEL_PERFECT_LAYERS` to the canvas
|
// this camera renders whatever is on `PIXEL_PERFECT_LAYERS` to the canvas
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera2dBundle {
|
Camera2d,
|
||||||
camera: Camera {
|
Camera {
|
||||||
// render before the "main pass" camera
|
// render before the "main pass" camera
|
||||||
order: -1,
|
order: -1,
|
||||||
target: RenderTarget::Image(image_handle.clone()),
|
target: RenderTarget::Image(image_handle.clone()),
|
||||||
..default()
|
|
||||||
},
|
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Msaa::Off,
|
||||||
InGameCamera,
|
InGameCamera,
|
||||||
PIXEL_PERFECT_LAYERS,
|
PIXEL_PERFECT_LAYERS,
|
||||||
));
|
));
|
||||||
|
@ -145,14 +143,7 @@ fn setup_camera(mut commands: Commands, mut images: ResMut<Assets<Image>>) {
|
||||||
|
|
||||||
// the "outer" camera renders whatever is on `HIGH_RES_LAYERS` to the screen.
|
// the "outer" camera renders whatever is on `HIGH_RES_LAYERS` to the screen.
|
||||||
// here, the canvas and one of the sample sprites will be rendered by this camera
|
// here, the canvas and one of the sample sprites will be rendered by this camera
|
||||||
commands.spawn((
|
commands.spawn((Camera2d, Msaa::Off, OuterCamera, HIGH_RES_LAYERS));
|
||||||
Camera2dBundle {
|
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
OuterCamera,
|
|
||||||
HIGH_RES_LAYERS,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rotates entities to demonstrate grid snapping.
|
/// Rotates entities to demonstrate grid snapping.
|
||||||
|
|
|
@ -55,7 +55,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let enemy_b_handle = asset_server.load("textures/simplespace/enemy_B.png");
|
let enemy_b_handle = asset_server.load("textures/simplespace/enemy_B.png");
|
||||||
|
|
||||||
// 2D orthographic camera
|
// 2D orthographic camera
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
let horizontal_margin = BOUNDS.x / 4.0;
|
let horizontal_margin = BOUNDS.x / 4.0;
|
||||||
let vertical_margin = BOUNDS.y / 4.0;
|
let vertical_margin = BOUNDS.y / 4.0;
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.spawn(SpriteBundle {
|
commands.spawn(SpriteBundle {
|
||||||
texture: asset_server.load("branding/bevy_bird_dark.png"),
|
texture: asset_server.load("branding/bevy_bird_dark.png"),
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -90,7 +90,7 @@ fn setup(
|
||||||
asset_server: Res<AssetServer>,
|
asset_server: Res<AssetServer>,
|
||||||
mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
|
mut texture_atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
// load the sprite sheet using the `AssetServer`
|
// load the sprite sheet using the `AssetServer`
|
||||||
let texture = asset_server.load("textures/rpg/chars/gabe/gabe-idle-run.png");
|
let texture = asset_server.load("textures/rpg/chars/gabe/gabe-idle-run.png");
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.spawn(SpriteBundle {
|
commands.spawn(SpriteBundle {
|
||||||
texture: asset_server.load("branding/bevy_bird_dark.png"),
|
texture: asset_server.load("branding/bevy_bird_dark.png"),
|
||||||
sprite: Sprite {
|
sprite: Sprite {
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn setup(
|
||||||
let texture_atlas_layout = texture_atlas_layouts.add(layout);
|
let texture_atlas_layout = texture_atlas_layouts.add(layout);
|
||||||
// Use only the subset of sprites in the sheet that make up the run animation
|
// Use only the subset of sprites in the sheet that make up the run animation
|
||||||
let animation_indices = AnimationIndices { first: 1, last: 6 };
|
let animation_indices = AnimationIndices { first: 1, last: 6 };
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
SpriteBundle {
|
SpriteBundle {
|
||||||
transform: Transform::from_scale(Vec3::splat(6.0)),
|
transform: Transform::from_scale(Vec3::splat(6.0)),
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn spawn_sprites(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
|
let font = asset_server.load("fonts/FiraSans-Bold.ttf");
|
||||||
let style = TextStyle {
|
let style = TextStyle {
|
||||||
font: font.clone(),
|
font: font.clone(),
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct AnimationState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
commands.insert_resource(AnimationState {
|
commands.insert_resource(AnimationState {
|
||||||
min: 128.0,
|
min: 128.0,
|
||||||
max: 512.0,
|
max: 512.0,
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
};
|
};
|
||||||
let text_justification = JustifyText::Center;
|
let text_justification = JustifyText::Center;
|
||||||
// 2d camera
|
// 2d camera
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
// Demonstrate changing translation
|
// Demonstrate changing translation
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Text2dBundle {
|
Text2dBundle {
|
||||||
|
|
|
@ -94,7 +94,7 @@ fn setup(
|
||||||
let atlas_nearest_padded_handle = texture_atlases.add(texture_atlas_nearest_padded);
|
let atlas_nearest_padded_handle = texture_atlases.add(texture_atlas_nearest_padded);
|
||||||
|
|
||||||
// setup 2d scene
|
// setup 2d scene
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
// padded textures are to the right, unpadded to the left
|
// padded textures are to the right, unpadded to the left
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
let sprite_handle = asset_server.load("branding/icon.png");
|
let sprite_handle = asset_server.load("branding/icon.png");
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
// Text used to show controls
|
// Text used to show controls
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
|
|
|
@ -36,8 +36,8 @@ fn setup(
|
||||||
Transform::from_xyz(4.0, 8.0, 4.0),
|
Transform::from_xyz(4.0, 8.0, 4.0),
|
||||||
));
|
));
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,10 +127,10 @@ fn setup(
|
||||||
MeshMaterial3d(materials.add(Color::from(SILVER))),
|
MeshMaterial3d(materials.add(Color::from(SILVER))),
|
||||||
));
|
));
|
||||||
|
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(0.0, 7., 14.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(0.0, 7., 14.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
|
|
|
@ -69,8 +69,8 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(15.0, 5.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(15.0, 5.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,8 @@ fn setup(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(3.0, 1.0, 3.0)
|
Transform::from_xyz(3.0, 1.0, 3.0).looking_at(Vec3::new(0.0, -0.5, 0.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(0.0, -0.5, 0.0), Vec3::Y),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -64,11 +64,10 @@ fn main() {
|
||||||
|
|
||||||
/// Creates the initial scene.
|
/// Creates the initial scene.
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_status: Res<AppStatus>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_status: Res<AppStatus>) {
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_translation(CAMERA_INITIAL_POSITION)
|
Camera3d::default(),
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_translation(CAMERA_INITIAL_POSITION).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
spawn_directional_light(&mut commands);
|
spawn_directional_light(&mut commands);
|
||||||
|
|
||||||
|
|
|
@ -301,15 +301,12 @@ fn setup(
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(0.7, 0.7, 1.0)
|
|
||||||
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
||||||
ContrastAdaptiveSharpening {
|
ContrastAdaptiveSharpening {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -25,11 +25,8 @@ fn main() {
|
||||||
|
|
||||||
fn setup_camera_fog(mut commands: Commands) {
|
fn setup_camera_fog(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(-1.0, 0.1, 1.0)
|
Transform::from_xyz(-1.0, 0.1, 1.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
DistanceFog {
|
DistanceFog {
|
||||||
color: Color::srgba(0.35, 0.48, 0.66, 1.0),
|
color: Color::srgba(0.35, 0.48, 0.66, 1.0),
|
||||||
directional_light_color: Color::srgba(1.0, 0.95, 0.85, 0.5),
|
directional_light_color: Color::srgba(1.0, 0.95, 0.85, 0.5),
|
||||||
|
|
|
@ -39,14 +39,12 @@ fn setup(
|
||||||
let metering_mask = asset_server.load("textures/basic_metering_mask.png");
|
let metering_mask = asset_server.load("textures/basic_metering_mask.png");
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(1.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(1.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
AutoExposure {
|
AutoExposure {
|
||||||
metering_mask: metering_mask.clone(),
|
metering_mask: metering_mask.clone(),
|
||||||
..default()
|
..default()
|
||||||
|
|
|
@ -152,10 +152,10 @@ fn setup(
|
||||||
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
|
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 8.0, 4.0)));
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(0.0, 2.5, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(0.0, 2.5, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
// Controls Text
|
// Controls Text
|
||||||
|
|
||||||
|
|
|
@ -28,15 +28,13 @@ fn setup_scene(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true, // 1. HDR is required for bloom
|
hdr: true, // 1. HDR is required for bloom
|
||||||
..default()
|
|
||||||
},
|
|
||||||
tonemapping: Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended
|
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Tonemapping::TonyMcMapface, // 2. Using a tonemapper that desaturates to white is recommended
|
||||||
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
// 3. Enable bloom for the camera
|
// 3. Enable bloom for the camera
|
||||||
Bloom::NATURAL,
|
Bloom::NATURAL,
|
||||||
));
|
));
|
||||||
|
|
|
@ -72,8 +72,9 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Main perspective Camera
|
// Main perspective Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(LARGE_SIZE, LARGE_SIZE),
|
physical_size: UVec2::new(LARGE_SIZE, LARGE_SIZE),
|
||||||
physical_position: UVec2::new(PADDING, PADDING * 2 + SMALL_SIZE),
|
physical_position: UVec2::new(PADDING, PADDING * 2 + SMALL_SIZE),
|
||||||
|
@ -82,12 +83,12 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform,
|
transform,
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Perspective camera left half
|
// Perspective camera left half
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
||||||
physical_position: UVec2::new(PADDING, PADDING),
|
physical_position: UVec2::new(PADDING, PADDING),
|
||||||
|
@ -109,37 +110,35 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform,
|
transform,
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Perspective camera moving
|
// Perspective camera moving
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
||||||
physical_position: UVec2::new(PADDING * 2 + SMALL_SIZE, PADDING),
|
physical_position: UVec2::new(PADDING * 2 + SMALL_SIZE, PADDING),
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
sub_camera_view: Some(SubCameraView {
|
|
||||||
// Set the sub view camera to a fifth of the full view and
|
|
||||||
// move it in another system
|
|
||||||
full_size: UVec2::new(500, 500),
|
|
||||||
offset: Vec2::ZERO,
|
|
||||||
size: UVec2::new(100, 100),
|
|
||||||
}),
|
|
||||||
order: 2,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
}),
|
||||||
transform,
|
sub_camera_view: Some(SubCameraView {
|
||||||
|
// Set the sub view camera to a fifth of the full view and
|
||||||
|
// move it in another system
|
||||||
|
full_size: UVec2::new(500, 500),
|
||||||
|
offset: Vec2::ZERO,
|
||||||
|
size: UVec2::new(100, 100),
|
||||||
|
}),
|
||||||
|
order: 2,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
transform,
|
||||||
MovingCameraMarker,
|
MovingCameraMarker,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Perspective camera control
|
// Perspective camera control
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
||||||
physical_position: UVec2::new(PADDING * 3 + SMALL_SIZE * 2, PADDING),
|
physical_position: UVec2::new(PADDING * 3 + SMALL_SIZE * 2, PADDING),
|
||||||
|
@ -156,17 +155,16 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform,
|
transform,
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Main orthographic camera
|
// Main orthographic camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
projection: OrthographicProjection {
|
Camera3d::default(),
|
||||||
|
Projection::from(OrthographicProjection {
|
||||||
scaling_mode: ScalingMode::FixedVertical(6.0),
|
scaling_mode: ScalingMode::FixedVertical(6.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
}
|
}),
|
||||||
.into(),
|
Camera {
|
||||||
camera: Camera {
|
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(LARGE_SIZE, LARGE_SIZE),
|
physical_size: UVec2::new(LARGE_SIZE, LARGE_SIZE),
|
||||||
physical_position: UVec2::new(PADDING * 2 + LARGE_SIZE, PADDING * 2 + SMALL_SIZE),
|
physical_position: UVec2::new(PADDING * 2 + LARGE_SIZE, PADDING * 2 + SMALL_SIZE),
|
||||||
|
@ -176,17 +174,16 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform,
|
transform,
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Orthographic camera left half
|
// Orthographic camera left half
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
projection: OrthographicProjection {
|
Camera3d::default(),
|
||||||
|
Projection::from(OrthographicProjection {
|
||||||
scaling_mode: ScalingMode::FixedVertical(6.0),
|
scaling_mode: ScalingMode::FixedVertical(6.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
}
|
}),
|
||||||
.into(),
|
Camera {
|
||||||
camera: Camera {
|
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
||||||
physical_position: UVec2::new(PADDING * 5 + SMALL_SIZE * 4, PADDING),
|
physical_position: UVec2::new(PADDING * 5 + SMALL_SIZE * 4, PADDING),
|
||||||
|
@ -206,47 +203,43 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform,
|
transform,
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Orthographic camera moving
|
// Orthographic camera moving
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
projection: OrthographicProjection {
|
Projection::from(OrthographicProjection {
|
||||||
scaling_mode: ScalingMode::FixedVertical(6.0),
|
scaling_mode: ScalingMode::FixedVertical(6.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
}
|
}),
|
||||||
.into(),
|
Camera {
|
||||||
camera: Camera {
|
viewport: Option::from(Viewport {
|
||||||
viewport: Option::from(Viewport {
|
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
||||||
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
physical_position: UVec2::new(PADDING * 6 + SMALL_SIZE * 5, PADDING),
|
||||||
physical_position: UVec2::new(PADDING * 6 + SMALL_SIZE * 5, PADDING),
|
|
||||||
..default()
|
|
||||||
}),
|
|
||||||
sub_camera_view: Some(SubCameraView {
|
|
||||||
// Set the sub view camera to a fifth of the full view and
|
|
||||||
// move it in another system
|
|
||||||
full_size: UVec2::new(500, 500),
|
|
||||||
offset: Vec2::ZERO,
|
|
||||||
size: UVec2::new(100, 100),
|
|
||||||
}),
|
|
||||||
order: 6,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
}),
|
||||||
transform,
|
sub_camera_view: Some(SubCameraView {
|
||||||
|
// Set the sub view camera to a fifth of the full view and
|
||||||
|
// move it in another system
|
||||||
|
full_size: UVec2::new(500, 500),
|
||||||
|
offset: Vec2::ZERO,
|
||||||
|
size: UVec2::new(100, 100),
|
||||||
|
}),
|
||||||
|
order: 6,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
transform,
|
||||||
MovingCameraMarker,
|
MovingCameraMarker,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Orthographic camera control
|
// Orthographic camera control
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
projection: OrthographicProjection {
|
Camera3d::default(),
|
||||||
|
Projection::from(OrthographicProjection {
|
||||||
scaling_mode: ScalingMode::FixedVertical(6.0),
|
scaling_mode: ScalingMode::FixedVertical(6.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
}
|
}),
|
||||||
.into(),
|
Camera {
|
||||||
camera: Camera {
|
|
||||||
viewport: Option::from(Viewport {
|
viewport: Option::from(Viewport {
|
||||||
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
physical_size: UVec2::new(SMALL_SIZE, SMALL_SIZE),
|
||||||
physical_position: UVec2::new(PADDING * 7 + SMALL_SIZE * 6, PADDING),
|
physical_position: UVec2::new(PADDING * 7 + SMALL_SIZE * 6, PADDING),
|
||||||
|
@ -263,8 +256,7 @@ fn setup(
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform,
|
transform,
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn move_camera_view(
|
fn move_camera_view(
|
||||||
|
|
|
@ -189,19 +189,19 @@ fn spawn_light(commands: &mut Commands) {
|
||||||
/// Spawns a camera with associated skybox and environment map.
|
/// Spawns a camera with associated skybox and environment map.
|
||||||
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
||||||
commands
|
commands
|
||||||
.spawn(Camera3dBundle {
|
.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
projection: Projection::Perspective(PerspectiveProjection {
|
Projection::Perspective(PerspectiveProjection {
|
||||||
fov: 27.0 / 180.0 * PI,
|
fov: 27.0 / 180.0 * PI,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 10.0),
|
Transform::from_xyz(0.0, 0.0, 10.0),
|
||||||
tonemapping: AcesFitted,
|
AcesFitted,
|
||||||
..default()
|
))
|
||||||
})
|
|
||||||
.insert(Skybox {
|
.insert(Skybox {
|
||||||
brightness: 5000.0,
|
brightness: 5000.0,
|
||||||
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -352,16 +352,13 @@ fn add_text<'a>(
|
||||||
|
|
||||||
fn add_camera(commands: &mut Commands, asset_server: &AssetServer, color_grading: ColorGrading) {
|
fn add_camera(commands: &mut Commands, asset_server: &AssetServer, color_grading: ColorGrading) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(0.7, 0.7, 1.0)
|
|
||||||
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
|
||||||
color_grading,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
||||||
|
color_grading,
|
||||||
DistanceFog {
|
DistanceFog {
|
||||||
color: Color::srgb_u8(43, 44, 47),
|
color: Color::srgb_u8(43, 44, 47),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
|
|
|
@ -34,18 +34,15 @@ fn setup(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
// Deferred both supports both hdr: true and hdr: false
|
// Deferred both supports both hdr: true and hdr: false
|
||||||
hdr: false,
|
hdr: false,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(0.7, 0.7, 1.0)
|
|
||||||
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
|
||||||
// MSAA needs to be off for Deferred rendering
|
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
||||||
|
// MSAA needs to be off for Deferred rendering
|
||||||
|
Msaa::Off,
|
||||||
DistanceFog {
|
DistanceFog {
|
||||||
color: Color::srgb_u8(43, 44, 47),
|
color: Color::srgb_u8(43, 44, 47),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
|
|
|
@ -70,16 +70,16 @@ fn main() {
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: Res<AppSettings>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: Res<AppSettings>) {
|
||||||
// Spawn the camera. Enable HDR and bloom, as that highlights the depth of
|
// Spawn the camera. Enable HDR and bloom, as that highlights the depth of
|
||||||
// field effect.
|
// field effect.
|
||||||
let mut camera = commands.spawn(Camera3dBundle {
|
let mut camera = commands.spawn((
|
||||||
transform: Transform::from_xyz(0.0, 4.5, 8.25).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Transform::from_xyz(0.0, 4.5, 8.25).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
tonemapping: Tonemapping::TonyMcMapface,
|
Tonemapping::TonyMcMapface,
|
||||||
..default()
|
Bloom::NATURAL,
|
||||||
});
|
));
|
||||||
camera.insert(Bloom::NATURAL);
|
|
||||||
|
|
||||||
// Insert the depth of field settings.
|
// Insert the depth of field settings.
|
||||||
if let Some(depth_of_field) = Option::<DepthOfField>::from(*app_settings) {
|
if let Some(depth_of_field) = Option::<DepthOfField>::from(*app_settings) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ fn main() {
|
||||||
|
|
||||||
fn setup_camera_fog(mut commands: Commands) {
|
fn setup_camera_fog(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle::default(),
|
Camera3d::default(),
|
||||||
DistanceFog {
|
DistanceFog {
|
||||||
color: Color::srgb(0.25, 0.25, 0.25),
|
color: Color::srgb(0.25, 0.25, 0.25),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
|
|
|
@ -61,23 +61,21 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
));
|
));
|
||||||
|
|
||||||
// Spawn a camera.
|
// Spawn a camera.
|
||||||
commands
|
commands.spawn((
|
||||||
.spawn(Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(-0.75, 1.0, 2.0)
|
Transform::from_xyz(-0.75, 1.0, 2.0).looking_at(vec3(0.0, 0.0, 0.0), Vec3::Y),
|
||||||
.looking_at(vec3(0.0, 0.0, 0.0), Vec3::Y),
|
Camera {
|
||||||
camera: Camera {
|
hdr: true,
|
||||||
hdr: true,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
..default()
|
..default()
|
||||||
})
|
},
|
||||||
.insert(VolumetricFog {
|
VolumetricFog {
|
||||||
// Make this relatively high in order to increase the fog quality.
|
// Make this relatively high in order to increase the fog quality.
|
||||||
step_count: 64,
|
step_count: 64,
|
||||||
// Disable ambient light.
|
// Disable ambient light.
|
||||||
ambient_intensity: 0.0,
|
ambient_intensity: 0.0,
|
||||||
..default()
|
..default()
|
||||||
});
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rotates the camera a bit every frame.
|
/// Rotates the camera a bit every frame.
|
||||||
|
|
|
@ -51,10 +51,7 @@ fn setup(
|
||||||
Transform::from_xyz(1.8, 1.8, 1.8).looking_at(Vec3::ZERO, Vec3::Y);
|
Transform::from_xyz(1.8, 1.8, 1.8).looking_at(Vec3::ZERO, Vec3::Y);
|
||||||
|
|
||||||
// Camera in 3D space.
|
// Camera in 3D space.
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((Camera3d::default(), camera_and_light_transform));
|
||||||
transform: camera_and_light_transform,
|
|
||||||
..default()
|
|
||||||
});
|
|
||||||
|
|
||||||
// Light up the scene.
|
// Light up the scene.
|
||||||
commands.spawn((PointLight::default(), camera_and_light_transform));
|
commands.spawn((PointLight::default(), camera_and_light_transform));
|
||||||
|
|
|
@ -231,16 +231,15 @@ fn spawn_main_scene(commands: &mut Commands, assets: &ExampleAssets) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_camera(commands: &mut Commands, assets: &ExampleAssets) {
|
fn spawn_camera(commands: &mut Commands, assets: &ExampleAssets) {
|
||||||
commands
|
commands.spawn((
|
||||||
.spawn(Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(-10.012, 4.8605, 13.281).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_xyz(-10.012, 4.8605, 13.281).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
Skybox {
|
||||||
})
|
|
||||||
.insert(Skybox {
|
|
||||||
image: assets.skybox.clone(),
|
image: assets.skybox.clone(),
|
||||||
brightness: 150.0,
|
brightness: 150.0,
|
||||||
..default()
|
..default()
|
||||||
});
|
},
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_irradiance_volume(commands: &mut Commands, assets: &ExampleAssets) {
|
fn spawn_irradiance_volume(commands: &mut Commands, assets: &ExampleAssets) {
|
||||||
|
|
|
@ -244,11 +244,11 @@ fn setup(
|
||||||
);
|
);
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
exposure: Exposure::from_physical_camera(**parameters),
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
Exposure::from_physical_camera(**parameters),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_exposure(
|
fn update_exposure(
|
||||||
|
|
|
@ -16,10 +16,10 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
GltfAssetLabel::Scene(0).from_asset("models/CornellBox/CornellBox.glb"),
|
GltfAssetLabel::Scene(0).from_asset("models/CornellBox/CornellBox.glb"),
|
||||||
)));
|
)));
|
||||||
|
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-278.0, 273.0, 800.0),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-278.0, 273.0, 800.0),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_lightmaps_to_meshes(
|
fn add_lightmaps_to_meshes(
|
||||||
|
|
|
@ -59,10 +59,10 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)]
|
#[derive(Asset, TypePath, Default, AsBindGroup, Debug, Clone)]
|
||||||
|
|
|
@ -17,11 +17,8 @@ fn main() {
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(0.7, 0.7, 1.0)
|
Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -17,10 +17,10 @@ fn main() {
|
||||||
struct ExampleDisplay;
|
struct ExampleDisplay;
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(2.0, 2.0, 2.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
commands.spawn(DirectionalLight {
|
commands.spawn(DirectionalLight {
|
||||||
shadows_enabled: true,
|
shadows_enabled: true,
|
||||||
|
|
|
@ -49,12 +49,9 @@ fn setup(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_translation(Vec3::new(1.8, 0.4, -0.1))
|
Transform::from_translation(Vec3::new(1.8, 0.4, -0.1)).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
Msaa::Off,
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -18,7 +18,7 @@ fn main() {
|
||||||
|
|
||||||
fn setup_camera(mut commands: Commands) {
|
fn setup_camera(mut commands: Commands) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle::default(),
|
Camera3d::default(),
|
||||||
// Add the `MotionBlur` component to a camera to enable motion blur.
|
// Add the `MotionBlur` component to a camera to enable motion blur.
|
||||||
// Motion blur requires the depth and motion vector prepass, which this bundle adds.
|
// Motion blur requires the depth and motion vector prepass, which this bundle adds.
|
||||||
// Configure the amount and quality of motion blur per-camera using this component.
|
// Configure the amount and quality of motion blur per-camera using this component.
|
||||||
|
|
|
@ -16,16 +16,15 @@ fn setup(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
projection: OrthographicProjection {
|
Camera3d::default(),
|
||||||
|
Projection::from(OrthographicProjection {
|
||||||
// 6 world units per window height.
|
// 6 world units per window height.
|
||||||
scaling_mode: ScalingMode::FixedVertical(6.0),
|
scaling_mode: ScalingMode::FixedVertical(6.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
}
|
}),
|
||||||
.into(),
|
Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
transform: Transform::from_xyz(5.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
));
|
||||||
..default()
|
|
||||||
});
|
|
||||||
|
|
||||||
// plane
|
// plane
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
|
@ -212,10 +212,8 @@ fn setup(
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_xyz(1.5, 1.5, 1.5).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
|
||||||
},
|
|
||||||
CameraController,
|
CameraController,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ fn setup(
|
||||||
// light
|
// light
|
||||||
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, -4.0)));
|
commands.spawn((PointLight::default(), Transform::from_xyz(4.0, 5.0, -4.0)));
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(5.0, 10.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,15 +114,12 @@ fn setup(
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::default(), Vec3::Y),
|
Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::default(), Vec3::Y),
|
||||||
projection: OrthographicProjection {
|
Projection::from(OrthographicProjection {
|
||||||
scaling_mode: ScalingMode::WindowSize(100.0),
|
scaling_mode: ScalingMode::WindowSize(100.0),
|
||||||
..OrthographicProjection::default_3d()
|
..OrthographicProjection::default_3d()
|
||||||
}
|
}),
|
||||||
.into(),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -151,16 +151,12 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_status: Res
|
||||||
/// Spawns the camera, with the initial shadow filtering method.
|
/// Spawns the camera, with the initial shadow filtering method.
|
||||||
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
||||||
commands
|
commands
|
||||||
.spawn(Camera3dBundle {
|
.spawn((
|
||||||
transform: Transform::from_xyz(-12.912 * 0.7, 4.466 * 0.7, -10.624 * 0.7)
|
Camera3d::default(),
|
||||||
.with_rotation(Quat::from_euler(
|
Transform::from_xyz(-12.912 * 0.7, 4.466 * 0.7, -10.624 * 0.7).with_rotation(
|
||||||
EulerRot::YXZ,
|
Quat::from_euler(EulerRot::YXZ, -134.76 / 180.0 * PI, -0.175, 0.0),
|
||||||
-134.76 / 180.0 * PI,
|
),
|
||||||
-0.175,
|
))
|
||||||
0.0,
|
|
||||||
)),
|
|
||||||
..default()
|
|
||||||
})
|
|
||||||
.insert(ShadowFilteringMethod::Gaussian)
|
.insert(ShadowFilteringMethod::Gaussian)
|
||||||
// `TemporalJitter` is needed for TAA. Note that it does nothing without
|
// `TemporalJitter` is needed for TAA. Note that it does nothing without
|
||||||
// `TemporalAntiAliasSettings`.
|
// `TemporalAntiAliasSettings`.
|
||||||
|
|
|
@ -59,15 +59,12 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
|
||||||
/// Spawns the camera, including the [`ChromaticAberration`] component.
|
/// Spawns the camera, including the [`ChromaticAberration`] component.
|
||||||
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(0.7, 0.7, 1.0)
|
|
||||||
.looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(0.7, 0.7, 1.0).looking_at(Vec3::new(0.0, 0.3, 0.0), Vec3::Y),
|
||||||
DistanceFog {
|
DistanceFog {
|
||||||
color: Color::srgb_u8(43, 44, 47),
|
color: Color::srgb_u8(43, 44, 47),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
|
|
|
@ -54,11 +54,8 @@ fn find_top_material_and_mesh(
|
||||||
|
|
||||||
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(0.6, 1.6, 11.3)
|
Transform::from_xyz(0.6, 1.6, 11.3).looking_at(Vec3::new(0.0, 0.0, 3.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(0.0, 0.0, 3.0), Vec3::Y),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -103,14 +103,14 @@ fn spawn_scene(commands: &mut Commands, asset_server: &AssetServer) {
|
||||||
|
|
||||||
// Spawns the camera.
|
// Spawns the camera.
|
||||||
fn spawn_camera(commands: &mut Commands) {
|
fn spawn_camera(commands: &mut Commands) {
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform: Transform::from_xyz(-6.483, 0.325, 4.381).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_xyz(-6.483, 0.325, 4.381).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the sphere mesh and spawns it.
|
// Creates the sphere mesh and spawns it.
|
||||||
|
|
|
@ -84,16 +84,13 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
target: image_handle.clone().into(),
|
target: image_handle.clone().into(),
|
||||||
clear_color: Color::WHITE.into(),
|
clear_color: Color::WHITE.into(),
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 15.0))
|
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_translation(Vec3::new(0.0, 0.0, 15.0)).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
first_pass_layer,
|
first_pass_layer,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -117,10 +114,10 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// The main pass camera.
|
// The main pass camera.
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(0.0, 0.0, 15.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Rotates the inner cube (first pass)
|
/// Rotates the inner cube (first pass)
|
||||||
|
|
|
@ -93,19 +93,19 @@ fn spawn_light(commands: &mut Commands) {
|
||||||
/// Spawns a camera with associated skybox and environment map.
|
/// Spawns a camera with associated skybox and environment map.
|
||||||
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
||||||
commands
|
commands
|
||||||
.spawn(Camera3dBundle {
|
.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
projection: Projection::Perspective(PerspectiveProjection {
|
Projection::Perspective(PerspectiveProjection {
|
||||||
fov: 27.0 / 180.0 * PI,
|
fov: 27.0 / 180.0 * PI,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 10.0),
|
Transform::from_xyz(0.0, 0.0, 10.0),
|
||||||
tonemapping: AcesFitted,
|
AcesFitted,
|
||||||
..default()
|
))
|
||||||
})
|
|
||||||
.insert(Skybox {
|
.insert(Skybox {
|
||||||
brightness: 5000.0,
|
brightness: 5000.0,
|
||||||
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -49,14 +49,10 @@ fn setup(
|
||||||
) {
|
) {
|
||||||
// Spawn camera with temporal anti-aliasing and a VolumetricFog configuration.
|
// Spawn camera with temporal anti-aliasing and a VolumetricFog configuration.
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(0.0, 2.0, 0.0)
|
Transform::from_xyz(0.0, 2.0, 0.0).looking_at(Vec3::new(-5.0, 3.5, -6.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(-5.0, 3.5, -6.0), Vec3::Y),
|
Camera {
|
||||||
camera: Camera {
|
hdr: true,
|
||||||
hdr: true,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
TemporalAntiAliasing::default(),
|
TemporalAntiAliasing::default(),
|
||||||
|
|
|
@ -73,11 +73,8 @@ fn setup(
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(-1.0, 1.0, 1.0)
|
Transform::from_xyz(-1.0, 1.0, 1.0).looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
CameraController::default(),
|
CameraController::default(),
|
||||||
ShadowFilteringMethod::Hardware2x2,
|
ShadowFilteringMethod::Hardware2x2,
|
||||||
));
|
));
|
||||||
|
|
|
@ -98,11 +98,10 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-5.0, 5.0, 5.0)
|
Camera3d::default(),
|
||||||
.looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y),
|
Transform::from_xyz(-5.0, 5.0, 5.0).looking_at(Vec3::new(-1.0, 1.0, 0.0), Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_light(
|
fn toggle_light(
|
||||||
|
|
|
@ -71,10 +71,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
let skybox_handle = asset_server.load(CUBEMAPS[0].0);
|
let skybox_handle = asset_server.load(CUBEMAPS[0].0);
|
||||||
// camera
|
// camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
|
||||||
},
|
|
||||||
CameraController::default(),
|
CameraController::default(),
|
||||||
Skybox {
|
Skybox {
|
||||||
image: skybox_handle.clone(),
|
image: skybox_handle.clone(),
|
||||||
|
|
|
@ -19,10 +19,10 @@ fn setup(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(0.2, 1.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(0.2, 1.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
// plane
|
// plane
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
|
@ -68,14 +68,11 @@ fn setup(
|
||||||
{
|
{
|
||||||
let camera = commands
|
let camera = commands
|
||||||
.spawn((
|
.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_translation(*camera_pos)
|
Transform::from_translation(*camera_pos).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
Camera {
|
||||||
camera: Camera {
|
// Renders cameras with different priorities to prevent ambiguities
|
||||||
// Renders cameras with different priorities to prevent ambiguities
|
order: index as isize,
|
||||||
order: index as isize,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
CameraPosition {
|
CameraPosition {
|
||||||
|
|
|
@ -117,14 +117,14 @@ fn setup(
|
||||||
}
|
}
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
camera: Camera {
|
Camera3d::default(),
|
||||||
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
transform: Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_xyz(-4.0, 5.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
TextBundle::from_section(INSTRUCTIONS, TextStyle::default()).with_style(Style {
|
TextBundle::from_section(INSTRUCTIONS, TextStyle::default()).with_style(Style {
|
||||||
|
|
|
@ -27,15 +27,13 @@ fn setup(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(-2.0, 2.0, -2.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(-2.0, 2.0, -2.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
Msaa::Off,
|
||||||
ScreenSpaceAmbientOcclusion::default(),
|
ScreenSpaceAmbientOcclusion::default(),
|
||||||
TemporalAntiAliasing::default(),
|
TemporalAntiAliasing::default(),
|
||||||
));
|
));
|
||||||
|
|
|
@ -225,16 +225,15 @@ fn spawn_camera(commands: &mut Commands, asset_server: &AssetServer) {
|
||||||
// rendering by adding depth and deferred prepasses. Turn on FXAA to make
|
// rendering by adding depth and deferred prepasses. Turn on FXAA to make
|
||||||
// the scene look a little nicer. Finally, add screen space reflections.
|
// the scene look a little nicer. Finally, add screen space reflections.
|
||||||
commands
|
commands
|
||||||
.spawn(Camera3dBundle {
|
.spawn((
|
||||||
transform: Transform::from_translation(vec3(-1.25, 2.25, 4.5))
|
Camera3d::default(),
|
||||||
.looking_at(Vec3::ZERO, Vec3::Y),
|
Transform::from_translation(vec3(-1.25, 2.25, 4.5)).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
msaa: Msaa::Off,
|
Msaa::Off,
|
||||||
..default()
|
))
|
||||||
})
|
|
||||||
.insert(EnvironmentMapLight {
|
.insert(EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -71,8 +71,8 @@ fn setup(
|
||||||
Transform::from_xyz(0.0, 0.0, -1.5).with_rotation(Quat::from_rotation_x(-PI / 5.0)),
|
Transform::from_xyz(0.0, 0.0, -1.5).with_rotation(Quat::from_rotation_x(-PI / 5.0)),
|
||||||
));
|
));
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(3.0, 5.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(3.0, 5.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,14 +58,12 @@ fn setup(
|
||||||
) {
|
) {
|
||||||
// camera
|
// camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: camera_transform.0,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
camera_transform.0,
|
||||||
DistanceFog {
|
DistanceFog {
|
||||||
color: Color::srgb_u8(43, 44, 47),
|
color: Color::srgb_u8(43, 44, 47),
|
||||||
falloff: FogFalloff::Linear {
|
falloff: FogFalloff::Linear {
|
||||||
|
|
|
@ -302,25 +302,23 @@ fn setup(
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
|
||||||
},
|
|
||||||
transform: Transform::from_xyz(1.0, 1.8, 7.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
||||||
color_grading: ColorGrading {
|
|
||||||
global: ColorGradingGlobal {
|
|
||||||
post_saturation: 1.2,
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
tonemapping: Tonemapping::TonyMcMapface,
|
|
||||||
exposure: Exposure { ev100: 6.0 },
|
|
||||||
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
|
|
||||||
msaa: Msaa::Off,
|
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
Transform::from_xyz(1.0, 1.8, 7.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
|
ColorGrading {
|
||||||
|
global: ColorGradingGlobal {
|
||||||
|
post_saturation: 1.2,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
..default()
|
||||||
|
},
|
||||||
|
Tonemapping::TonyMcMapface,
|
||||||
|
Exposure { ev100: 6.0 },
|
||||||
|
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
|
||||||
|
Msaa::Off,
|
||||||
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
|
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
|
||||||
TemporalAntiAliasing::default(),
|
TemporalAntiAliasing::default(),
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
|
|
|
@ -90,10 +90,10 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Fades the alpha channel of all materials between 0 and 1 over time.
|
/// Fades the alpha channel of all materials between 0 and 1 over time.
|
||||||
|
|
|
@ -38,20 +38,20 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(10.0, 10., -5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
camera: Camera {
|
Camera {
|
||||||
// renders after / on top of the main camera
|
// renders after / on top of the main camera
|
||||||
order: 1,
|
order: 1,
|
||||||
clear_color: ClearColorConfig::None,
|
clear_color: ClearColorConfig::None,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
Transform::from_xyz(10.0, 10., -5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,8 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Camera3dBundle {
|
Camera3d::default(),
|
||||||
transform: Transform::from_xyz(-0.5, 0.9, 1.5)
|
Transform::from_xyz(-0.5, 0.9, 1.5).looking_at(Vec3::new(-0.5, 0.3, 0.0), Vec3::Y),
|
||||||
.looking_at(Vec3::new(-0.5, 0.3, 0.0), Vec3::Y),
|
|
||||||
..default()
|
|
||||||
},
|
|
||||||
EnvironmentMapLight {
|
EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -51,8 +51,8 @@ fn setup(
|
||||||
));
|
));
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,10 +137,10 @@ fn setup(
|
||||||
|
|
||||||
// Spawn a camera.
|
// Spawn a camera.
|
||||||
commands
|
commands
|
||||||
.spawn(Camera3dBundle {
|
.spawn((
|
||||||
transform: Transform::from_xyz(0.7, 0.7, 1.0).looking_at(CAMERA_FOCAL_POINT, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(0.7, 0.7, 1.0).looking_at(CAMERA_FOCAL_POINT, Vec3::Y),
|
||||||
})
|
))
|
||||||
.insert(EnvironmentMapLight {
|
.insert(EnvironmentMapLight {
|
||||||
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
|
||||||
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
|
|
|
@ -63,17 +63,16 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>, app_settings: R
|
||||||
|
|
||||||
// Spawn the camera.
|
// Spawn the camera.
|
||||||
commands
|
commands
|
||||||
.spawn(Camera3dBundle {
|
.spawn((
|
||||||
transform: Transform::from_xyz(-1.7, 1.5, 4.5)
|
Camera3d::default(),
|
||||||
.looking_at(vec3(-1.5, 1.7, 3.5), Vec3::Y),
|
Camera {
|
||||||
camera: Camera {
|
|
||||||
hdr: true,
|
hdr: true,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
..default()
|
Transform::from_xyz(-1.7, 1.5, 4.5).looking_at(vec3(-1.5, 1.7, 3.5), Vec3::Y),
|
||||||
})
|
Tonemapping::TonyMcMapface,
|
||||||
.insert(Tonemapping::TonyMcMapface)
|
Bloom::default(),
|
||||||
.insert(Bloom::default())
|
))
|
||||||
.insert(Skybox {
|
.insert(Skybox {
|
||||||
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
|
||||||
brightness: 1000.0,
|
brightness: 1000.0,
|
||||||
|
|
|
@ -93,10 +93,10 @@ fn setup(
|
||||||
commands.spawn((PointLight::default(), Transform::from_xyz(2.0, 4.0, 2.0)));
|
commands.spawn((PointLight::default(), Transform::from_xyz(2.0, 4.0, 2.0)));
|
||||||
|
|
||||||
// camera
|
// camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
// Text used to show controls
|
// Text used to show controls
|
||||||
commands.spawn(
|
commands.spawn(
|
||||||
|
|
|
@ -52,11 +52,10 @@ fn setup(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(100.0, 100.0, 150.0)
|
Camera3d::default(),
|
||||||
.looking_at(Vec3::new(0.0, 20.0, 0.0), Vec3::Y),
|
Transform::from_xyz(100.0, 100.0, 150.0).looking_at(Vec3::new(0.0, 20.0, 0.0), Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Plane
|
// Plane
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
|
@ -26,10 +26,10 @@ fn setup(
|
||||||
mut graphs: ResMut<Assets<AnimationGraph>>,
|
mut graphs: ResMut<Assets<AnimationGraph>>,
|
||||||
) {
|
) {
|
||||||
// Camera
|
// Camera
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
// Light
|
// Light
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
|
@ -144,7 +144,7 @@ fn setup(
|
||||||
animation_player.play(animation_node_index).repeat();
|
animation_player.play(animation_node_index).repeat();
|
||||||
|
|
||||||
// Add a camera.
|
// Add a camera.
|
||||||
commands.spawn(Camera2dBundle::default());
|
commands.spawn(Camera2d);
|
||||||
|
|
||||||
// Build the UI. We have a parent node that covers the whole screen and
|
// Build the UI. We have a parent node that covers the whole screen and
|
||||||
// contains the `AnimationPlayer`, as well as a child node that contains the
|
// contains the `AnimationPlayer`, as well as a child node that contains the
|
||||||
|
|
|
@ -218,10 +218,10 @@ fn setup_scene(
|
||||||
mut meshes: ResMut<Assets<Mesh>>,
|
mut meshes: ResMut<Assets<Mesh>>,
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-10.0, 5.0, 13.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
|
Camera3d::default(),
|
||||||
..default()
|
Transform::from_xyz(-10.0, 5.0, 13.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
|
||||||
});
|
));
|
||||||
|
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PointLight {
|
PointLight {
|
||||||
|
|
|
@ -122,11 +122,10 @@ fn setup_scene(
|
||||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||||
) {
|
) {
|
||||||
// Spawn the camera.
|
// Spawn the camera.
|
||||||
commands.spawn(Camera3dBundle {
|
commands.spawn((
|
||||||
transform: Transform::from_xyz(-15.0, 10.0, 20.0)
|
Camera3d::default(),
|
||||||
.looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
|
Transform::from_xyz(-15.0, 10.0, 20.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
|
||||||
..default()
|
));
|
||||||
});
|
|
||||||
|
|
||||||
// Spawn the light.
|
// Spawn the light.
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue