
# Objective Adjust instruction text in some newer examples to match the [example visual guidelines](https://bevyengine.org/learn/contribute/helping-out/creating-examples/#visual-guidelines). ## Solution Move text 12px from edge of screen ## Testing ``` cargo run --example alter_mesh cargo run --example alter_sprite cargo run --example camera_orbit cargo run --example projection_zoom cargo run --example irradiance_volumes cargo run --example log_layers_ecs cargo run --example multi_asset_sync cargo run --example multiple_windows cargo run --example order_independent_transparency ``` ## Additional information This isn't comprehensive, just the most trivial cases. I'll double check my notes and probably follow up with an issue to look into visual guidelines for a few other examples.
70 lines
2.0 KiB
Rust
70 lines
2.0 KiB
Rust
//! Uses two windows to visualize a 3D model from different angles.
|
|
|
|
use bevy::{prelude::*, render::camera::RenderTarget, window::WindowRef};
|
|
|
|
fn main() {
|
|
App::new()
|
|
// By default, a primary window gets spawned by `WindowPlugin`, contained in `DefaultPlugins`
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Startup, setup_scene)
|
|
.run();
|
|
}
|
|
|
|
fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|
// add entities to the world
|
|
commands.spawn(SceneRoot(
|
|
asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/torus/torus.gltf")),
|
|
));
|
|
// light
|
|
commands.spawn((
|
|
DirectionalLight::default(),
|
|
Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
));
|
|
|
|
let first_window_camera = commands
|
|
.spawn((
|
|
Camera3d::default(),
|
|
Transform::from_xyz(0.0, 0.0, 6.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
))
|
|
.id();
|
|
|
|
// Spawn a second window
|
|
let second_window = commands
|
|
.spawn(Window {
|
|
title: "Second window".to_owned(),
|
|
..default()
|
|
})
|
|
.id();
|
|
|
|
let second_window_camera = commands
|
|
.spawn((
|
|
Camera3d::default(),
|
|
Transform::from_xyz(6.0, 0.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
|
|
Camera {
|
|
target: RenderTarget::Window(WindowRef::Entity(second_window)),
|
|
..default()
|
|
},
|
|
))
|
|
.id();
|
|
|
|
let style = Style {
|
|
position_type: PositionType::Absolute,
|
|
top: Val::Px(12.0),
|
|
left: Val::Px(12.0),
|
|
..default()
|
|
};
|
|
|
|
commands.spawn((
|
|
Text::new("First window"),
|
|
style.clone(),
|
|
// Since we are using multiple cameras, we need to specify which camera UI should be rendered to
|
|
TargetCamera(first_window_camera),
|
|
));
|
|
|
|
commands.spawn((
|
|
Text::new("Second window"),
|
|
style,
|
|
TargetCamera(second_window_camera),
|
|
));
|
|
}
|