Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bevyengine
GitHub Repository: bevyengine/bevy
Path: blob/main/examples/gizmos/3d_text_gizmos.rs
9402 views
1
//! Basic example demonstrating 3d text gizmos
2
3
use bevy::color::palettes::css::{ORANGE, RED, YELLOW};
4
use bevy::prelude::*;
5
6
fn main() {
7
App::new()
8
.add_plugins(DefaultPlugins)
9
.add_systems(Startup, setup_camera)
10
.add_systems(Update, hello_world)
11
.run();
12
}
13
14
fn setup_camera(mut commands: Commands, mut gizmo_config_store: ResMut<GizmoConfigStore>) {
15
commands.spawn((
16
Camera3d::default(),
17
Transform::from_xyz(0.0, 0.0, 10.0).looking_at(Vec3::new(0.0, 0.0, 0.0), Vec3::Y),
18
));
19
20
let (config, _) = gizmo_config_store.config_mut::<DefaultGizmoConfigGroup>();
21
22
config.line.width = 4.;
23
}
24
25
fn hello_world(mut text_gizmos: Gizmos, time: Res<Time>) {
26
let t = 0.2 * time.elapsed_secs();
27
28
text_gizmos.text(
29
Isometry3d::new(Vec3::new(0.0, 1.5, 0.0), Quat::from_rotation_y(-t)),
30
"Hello",
31
1.,
32
Vec2::ZERO,
33
RED,
34
);
35
36
text_gizmos.text(
37
Isometry3d::new(Vec3::new(0.0, 0.0, 0.0), Quat::from_rotation_y(t + 0.25)),
38
"Text",
39
1.,
40
Vec2::ZERO,
41
ORANGE,
42
);
43
44
text_gizmos.text(
45
Isometry3d::new(Vec3::new(0.0, -1.5, 0.0), Quat::from_rotation_y(-t - 0.5)),
46
"Gizmos",
47
1.,
48
Vec2::ZERO,
49
YELLOW,
50
);
51
}
52
53