pub struct Cuboid {
pub half_size: Vec3,
}Expand description
A cuboid primitive, which is like a cube, except that the x, y, and z dimensions are not required to be the same.
Fields§
§half_size: Vec3Half of the width, height and depth of the cuboid
Implementations§
Source§impl Cuboid
impl Cuboid
Sourcepub const fn new(x_length: f32, y_length: f32, z_length: f32) -> Cuboid
pub const fn new(x_length: f32, y_length: f32, z_length: f32) -> Cuboid
Create a new Cuboid from a full x, y, and z length
Examples found in repository?
More examples
examples/async_tasks/async_channel_pattern.rs (line 122)
116fn setup_assets(
117 mut commands: Commands,
118 mut meshes: ResMut<Assets<Mesh>>,
119 mut materials: ResMut<Assets<StandardMaterial>>,
120) {
121 // Create and store a cube mesh
122 let box_mesh_handle = meshes.add(Cuboid::new(0.4, 0.4, 0.4));
123 commands.insert_resource(BoxMeshHandle(box_mesh_handle));
124
125 // Create and store a red material
126 let box_material_handle = materials.add(Color::srgb(1.0, 0.2, 0.3));
127 commands.insert_resource(BoxMaterialHandle(box_material_handle));
128}examples/shader_advanced/render_depth_to_texture.rs (line 204)
199fn spawn_rotating_cube(
200 commands: &mut Commands,
201 meshes: &mut Assets<Mesh>,
202 standard_materials: &mut Assets<StandardMaterial>,
203) {
204 let cube_handle = meshes.add(Cuboid::new(3.0, 3.0, 3.0));
205 let rotating_cube_material_handle = standard_materials.add(StandardMaterial {
206 base_color: Color::WHITE,
207 unlit: false,
208 ..default()
209 });
210 commands.spawn((
211 Mesh3d(cube_handle.clone()),
212 MeshMaterial3d(rotating_cube_material_handle),
213 Transform::IDENTITY,
214 RotatingCube,
215 ));
216}examples/3d/ssr.rs (line 285)
277fn spawn_cube(
278 commands: &mut Commands,
279 asset_server: &AssetServer,
280 meshes: &mut Assets<Mesh>,
281 standard_materials: &mut Assets<StandardMaterial>,
282) {
283 commands
284 .spawn((
285 Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
286 MeshMaterial3d(standard_materials.add(StandardMaterial {
287 base_color: Color::from(WHITE),
288 base_color_texture: Some(asset_server.load("branding/icon.png")),
289 ..default()
290 })),
291 Transform::from_xyz(0.0, 0.5, 0.0),
292 ))
293 .insert(CubeModel);
294}examples/picking/debug_picking.rs (line 95)
86fn on_click_spawn_cube(
87 _click: On<PointerClick>,
88 mut commands: Commands,
89 mut meshes: ResMut<Assets<Mesh>>,
90 mut materials: ResMut<Assets<StandardMaterial>>,
91 mut num: Local<usize>,
92) {
93 commands
94 .spawn((
95 Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
96 MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
97 Transform::from_xyz(0.0, 0.25 + 0.55 * *num as f32, 0.0),
98 ))
99 // With the MeshPickingPlugin added, you can add pointer event observers to meshes:
100 .observe(on_drag_rotate);
101 *num += 1;
102}examples/picking/simple_picking.rs (line 69)
60fn on_click_spawn_cube(
61 _click: On<PointerClick>,
62 mut commands: Commands,
63 mut meshes: ResMut<Assets<Mesh>>,
64 mut materials: ResMut<Assets<StandardMaterial>>,
65 mut num: Local<usize>,
66) {
67 commands
68 .spawn((
69 Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
70 MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
71 Transform::from_xyz(0.0, 0.25 + 0.55 * *num as f32, 0.0),
72 ))
73 // With the MeshPickingPlugin added, you can add pointer event observers to meshes:
74 .observe(on_drag_rotate);
75 *num += 1;
76}Additional examples can be found in:
- examples/3d/clustered_decals.rs
- examples/3d/3d_scene.rs
- examples/app/externally_driven_headless_renderer.rs
- examples/shader_advanced/manual_material.rs
- examples/3d/light_textures.rs
- examples/shader_advanced/mesh_shader_intro.rs
- examples/3d/order_independent_transparency.rs
- examples/3d/parenting.rs
- examples/remote/server.rs
- examples/3d/animated_material.rs
- examples/camera/custom_projection.rs
- examples/diagnostics/log_diagnostics.rs
- examples/dev_tools/infinite_grid.rs
- examples/3d/atmospheric_fog.rs
- examples/window/low_power.rs
- examples/shader_advanced/custom_shader_instancing.rs
- examples/testbed/ui.rs
- examples/camera/first_person_view_model.rs
- examples/gizmos/axes.rs
- examples/camera/free_camera_controller.rs
- examples/app/headless_renderer.rs
- examples/3d/occlusion_culling.rs
- examples/ui/widgets/viewport_node.rs
- examples/app/render_recovery.rs
- examples/shader_advanced/custom_render_phase.rs
- examples/audio/spatial_audio_3d.rs
- examples/3d/fog.rs
- examples/3d/motion_blur.rs
- examples/stress_tests/many_cameras_lights.rs
- examples/3d/anti_aliasing.rs
- examples/gizmos/3d_gizmos.rs
- examples/3d/scrolling_fog.rs
- examples/3d/render_to_texture.rs
- examples/asset/repeated_texture.rs
- examples/3d/spotlight.rs
- examples/testbed/3d.rs
- examples/gizmos/light_gizmos.rs
- examples/gizmos/transform_gizmo.rs
- examples/3d/parallax_mapping.rs
- examples/3d/deferred_rendering.rs
- examples/animation/animated_transform.rs
- examples/3d/lighting.rs
- examples/3d/transmission.rs
Sourcepub const fn from_size(size: Vec3) -> Cuboid
pub const fn from_size(size: Vec3) -> Cuboid
Create a new Cuboid from a given full size
Examples found in repository?
examples/math/custom_primitives.rs (line 330)
317fn bounding_shapes_3d(
318 shapes: Query<&Transform, With<Shape3d>>,
319 mut gizmos: Gizmos,
320 bounding_shape: Res<State<BoundingShape>>,
321) {
322 for transform in shapes.iter() {
323 match bounding_shape.get() {
324 BoundingShape::None => (),
325 BoundingShape::BoundingBox => {
326 // Get the AABB of the extrusion with the rotation and translation of the mesh.
327 let aabb = EXTRUSION.aabb_3d(transform.to_isometry());
328
329 gizmos.primitive_3d(
330 &Cuboid::from_size(Vec3::from(aabb.half_size()) * 2.),
331 aabb.center(),
332 WHITE,
333 );
334 }
335 BoundingShape::BoundingSphere => {
336 // Get the bounding sphere of the extrusion with the rotation and translation of the mesh.
337 let bounding_sphere = EXTRUSION.bounding_sphere(transform.to_isometry());
338
339 gizmos.sphere(bounding_sphere.center(), bounding_sphere.radius(), WHITE);
340 }
341 }
342 }
343}More examples
examples/movement/smooth_follow.rs (line 113)
92fn move_target(
93 mut target: Single<&mut Transform, With<TargetSphere>>,
94 target_speed: Res<TargetSphereSpeed>,
95 mut target_pos: ResMut<TargetPosition>,
96 time: Res<Time>,
97 mut rng: ResMut<RandomSource>,
98) {
99 match Dir3::new(target_pos.0 - target.translation) {
100 // The target and the present position of the target sphere are far enough to have a well-
101 // defined direction between them, so let's move closer:
102 Ok(dir) => {
103 let delta_time = time.delta_secs();
104 let abs_delta = (target_pos.0 - target.translation).norm();
105
106 // Avoid overshooting in case of high values of `delta_time`:
107 let magnitude = f32::min(abs_delta, delta_time * target_speed.0);
108 target.translation += dir * magnitude;
109 }
110
111 // The two are really close, so let's generate a new target position:
112 Err(_) => {
113 let legal_region = Cuboid::from_size(Vec3::splat(4.0));
114 *target_pos = TargetPosition(legal_region.sample_interior(&mut rng.0));
115 }
116 }
117}examples/stress_tests/many_materials.rs (line 79)
47fn setup(
48 mut commands: Commands,
49 args: Res<Args>,
50 mesh_assets: ResMut<Assets<Mesh>>,
51 material_assets: ResMut<Assets<StandardMaterial>>,
52) {
53 warn!(include_str!("warning_string.txt"));
54
55 let args = args.into_inner();
56 let material_assets = material_assets.into_inner();
57 let mesh_assets = mesh_assets.into_inner();
58 let n = args.grid_size;
59
60 // Camera
61 let w = n as f32;
62 commands.spawn((
63 Camera3d::default(),
64 Transform::from_xyz(w * 1.25, w + 1.0, w * 1.25)
65 .looking_at(Vec3::new(0.0, (w * -1.1) + 1.0, 0.0), Vec3::Y),
66 ));
67
68 // Light
69 commands.spawn((
70 Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
71 DirectionalLight {
72 illuminance: 3000.0,
73 shadow_maps_enabled: true,
74 ..default()
75 },
76 ));
77
78 // Cubes
79 let mesh_handle = mesh_assets.add(Cuboid::from_size(Vec3::ONE));
80 for x in 0..n {
81 for z in 0..n {
82 commands.spawn((
83 Mesh3d(mesh_handle.clone()),
84 MeshMaterial3d(material_assets.add(Color::WHITE)),
85 Transform::from_translation(Vec3::new(x as f32, 0.0, z as f32)),
86 ));
87 }
88 }
89}examples/shader/storage_buffer.rs (line 38)
21fn setup(
22 mut commands: Commands,
23 mut meshes: ResMut<Assets<Mesh>>,
24 mut buffers: ResMut<Assets<ShaderBuffer>>,
25 mut materials: ResMut<Assets<CustomMaterial>>,
26) {
27 // Example data for the storage buffer
28 let color_data: Vec<[f32; 4]> = vec![
29 [1.0, 0.0, 0.0, 1.0],
30 [0.0, 1.0, 0.0, 1.0],
31 [0.0, 0.0, 1.0, 1.0],
32 [1.0, 1.0, 0.0, 1.0],
33 [0.0, 1.0, 1.0, 1.0],
34 ];
35
36 let colors = buffers.add(ShaderBuffer::from(color_data));
37
38 let mesh_handle = meshes.add(Cuboid::from_size(Vec3::splat(0.3)));
39 // Create the custom material with the storage buffer
40 let material_handle = materials.add(CustomMaterial {
41 colors: colors.clone(),
42 });
43
44 commands.insert_resource(CustomMaterialHandle(material_handle.clone()));
45
46 // Spawn cubes with the custom material
47 let mut current_color_id: u32 = 0;
48 for i in -6..=6 {
49 for j in -3..=3 {
50 commands.spawn((
51 Mesh3d(mesh_handle.clone()),
52 MeshMaterial3d(material_handle.clone()),
53 MeshTag::new(current_color_id % 5),
54 Transform::from_xyz(i as f32, j as f32, 0.0),
55 ));
56 current_color_id += 1;
57 }
58 }
59
60 // Camera
61 commands.spawn((
62 Camera3d::default(),
63 Transform::from_xyz(0.0, 0.0, 10.0).looking_at(Vec3::ZERO, Vec3::Y),
64 ));
65}examples/3d/order_independent_transparency.rs (line 524)
519fn spawn_occlusion_test(commands: &mut Commands, resources: &mut SceneResources) {
520 let meshes = &mut resources.meshes;
521 let materials = &mut resources.materials;
522
523 let sphere_handle = meshes.add(Sphere::new(1.0).mesh());
524 let cube_handle = meshes.add(Cuboid::from_size(Vec3::ONE).mesh());
525 let cube_material = materials.add(Color::srgb(0.8, 0.7, 0.6));
526
527 // front
528 let x = -2.5;
529 commands.spawn((
530 Mesh3d(cube_handle.clone()),
531 MeshMaterial3d(cube_material.clone()),
532 Transform::from_xyz(x, 0.0, 2.0),
533 ));
534 commands.spawn((
535 Mesh3d(sphere_handle.clone()),
536 MeshMaterial3d(materials.add(StandardMaterial {
537 base_color: RED.with_alpha(0.5).into(),
538 alpha_mode: AlphaMode::Blend,
539 ..default()
540 })),
541 Transform::from_xyz(x, 0., 0.),
542 ));
543
544 // intersection
545 commands.spawn((
546 Mesh3d(cube_handle.clone()),
547 MeshMaterial3d(cube_material.clone()),
548 Transform::from_xyz(x, 0.0, 1.0),
549 ));
550 commands.spawn((
551 Mesh3d(sphere_handle.clone()),
552 MeshMaterial3d(materials.add(StandardMaterial {
553 base_color: RED.with_alpha(0.5).into(),
554 alpha_mode: AlphaMode::Blend,
555 ..default()
556 })),
557 Transform::from_xyz(0., 0., 0.),
558 ));
559
560 // back
561 let x = 2.5;
562 commands.spawn((
563 Mesh3d(cube_handle.clone()),
564 MeshMaterial3d(cube_material.clone()),
565 Transform::from_xyz(x, 0.0, -2.0),
566 ));
567 commands.spawn((
568 Mesh3d(sphere_handle.clone()),
569 MeshMaterial3d(materials.add(StandardMaterial {
570 base_color: RED.with_alpha(0.5).into(),
571 alpha_mode: AlphaMode::Blend,
572 ..default()
573 })),
574 Transform::from_xyz(x, 0., 0.),
575 ));
576}examples/shader/automatic_instancing.rs (line 36)
26fn setup(
27 mut commands: Commands,
28 assets: Res<AssetServer>,
29 mut meshes: ResMut<Assets<Mesh>>,
30 mut materials: ResMut<Assets<CustomMaterial>>,
31) {
32 // We will use this image as our external data for our material to sample from in the vertex shader
33 let image = assets.load("branding/icon.png");
34
35 // Our single mesh handle that will be instanced
36 let mesh_handle = meshes.add(Cuboid::from_size(Vec3::splat(0.01)));
37
38 // Create the custom material with a reference to our texture
39 // Automatic instancing works with any Material, including the `StandardMaterial`.
40 // This custom material is used to demonstrate the optional `MeshTag` feature.
41 let material_handle = materials.add(CustomMaterial {
42 image: image.clone(),
43 });
44
45 // We're hardcoding the image dimensions for simplicity
46 let image_dims = UVec2::new(256, 256);
47 let total_pixels = image_dims.x * image_dims.y;
48
49 for index in 0..total_pixels {
50 // Get x,y from index - x goes left to right, y goes top to bottom
51 let x = index % image_dims.x;
52 let y = index / image_dims.x;
53
54 // Convert to centered world coordinates
55 let world_x = (x as f32 - image_dims.x as f32 / 2.0) / 50.0;
56 let world_y = -((y as f32 - image_dims.y as f32 / 2.0) / 50.0); // Still need negative for world space
57
58 commands.spawn((
59 // For automatic instancing to take effect you need to
60 // use the same mesh handle and material handle for each instance
61 Mesh3d(mesh_handle.clone()),
62 MeshMaterial3d(material_handle.clone()),
63 // This is an optional component that can be used to help tie external data to a mesh instance
64 MeshTag::new(index),
65 Transform::from_xyz(world_x, world_y, 0.0),
66 ));
67 }
68
69 // Camera
70 commands.spawn((
71 Camera3d::default(),
72 Transform::from_xyz(0.0, 0.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
73 ));
74}Additional examples can be found in:
Sourcepub fn from_corners(point1: Vec3, point2: Vec3) -> Cuboid
pub fn from_corners(point1: Vec3, point2: Vec3) -> Cuboid
Create a new Cuboid from two corner points
Sourcepub const fn from_length(length: f32) -> Cuboid
pub const fn from_length(length: f32) -> Cuboid
Create a Cuboid from a single length.
The resulting Cuboid will be the same size in every direction.
Examples found in repository?
examples/shader_advanced/deferred_raymarch.rs (line 70)
42fn setup(
43 mut commands: Commands,
44 mut meshes: ResMut<Assets<Mesh>>,
45 mut materials: ResMut<Assets<StandardMaterial>>,
46) {
47 commands.spawn((
48 Camera3d::default(),
49 Transform::from_xyz(4.0, 3.0, 6.0).looking_at(Vec3::new(0.0, 0.2, 0.0), Vec3::Y),
50 // Deferred rendering requires MSAA to be off.
51 Msaa::Off,
52 DepthPrepass,
53 DeferredPrepass,
54 AmbientLight {
55 brightness: 200.0,
56 ..default()
57 },
58 FreeCamera::default(),
59 ));
60
61 // A ground plane that catches the SDF's shadow
62 commands.spawn((
63 Mesh3d(meshes.add(Plane3d::default().mesh().size(20.0, 20.0))),
64 MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
65 Transform::from_xyz(0.0, -1.5, 0.0),
66 ));
67
68 // A "regular" mesh cube
69 commands.spawn((
70 Mesh3d(meshes.add(Cuboid::from_length(1.2))),
71 MeshMaterial3d(materials.add(StandardMaterial {
72 base_color: Color::srgb(0.2, 0.4, 0.9),
73 perceptual_roughness: 0.4,
74 ..default()
75 })),
76 Transform::from_xyz(2.2, -0.9, 0.5),
77 ));
78
79 commands.spawn((
80 DirectionalLight {
81 illuminance: 8_000.0,
82 shadow_maps_enabled: true,
83 ..default()
84 },
85 Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
86 ));
87}More examples
tests/window/desktop_request_redraw.rs (line 80)
39fn setup(
40 mut commands: Commands,
41 mut meshes: ResMut<Assets<Mesh>>,
42 mut materials: ResMut<Assets<StandardMaterial>>,
43) {
44 commands.spawn((
45 Camera3d::default(),
46 Transform::from_xyz(0.0, 5.0, 0.0).looking_at(Vec3::ZERO, Vec3::Y),
47 ));
48
49 commands.spawn((
50 PointLight {
51 intensity: 1e6,
52 ..Default::default()
53 },
54 Transform::from_xyz(-1.0, 5.0, 1.0),
55 ));
56
57 let node = Node {
58 display: Display::Block,
59 padding: UiRect::all(Val::Px(10.0)),
60 row_gap: Val::Px(10.0),
61 ..Default::default()
62 };
63
64 commands.spawn((
65 node.clone(),
66 children![
67 (
68 node.clone(),
69 children![Text::new("Right click cube to pause animation")]
70 ),
71 (
72 node.clone(),
73 children![Text::new("Left click cube to start animation")]
74 )
75 ],
76 ));
77
78 commands
79 .spawn((
80 Mesh3d(meshes.add(Cuboid::from_length(1.0))),
81 MeshMaterial3d(materials.add(Color::WHITE)),
82 AnimationActive,
83 ))
84 .observe(
85 |click: On<PointerClick>, mut commands: Commands| match click.button {
86 PointerButton::Primary => {
87 commands.entity(click.entity).insert(AnimationActive);
88 }
89 PointerButton::Secondary => {
90 commands.entity(click.entity).remove::<AnimationActive>();
91 }
92 _ => {}
93 },
94 );
95}examples/animation/eased_motion.rs (line 41)
19fn setup(
20 mut commands: Commands,
21 mut meshes: ResMut<Assets<Mesh>>,
22 mut materials: ResMut<Assets<StandardMaterial>>,
23 mut animation_graphs: ResMut<Assets<AnimationGraph>>,
24 mut animation_clips: ResMut<Assets<AnimationClip>>,
25) {
26 // Create the animation:
27 let AnimationInfo {
28 target_name: animation_target_name,
29 target_id: animation_target_id,
30 graph: animation_graph,
31 node_index: animation_node_index,
32 } = AnimationInfo::create(&mut animation_graphs, &mut animation_clips);
33
34 // Build an animation player that automatically plays the animation.
35 let mut animation_player = AnimationPlayer::default();
36 animation_player.play(animation_node_index).repeat();
37
38 // A cube together with the components needed to animate it
39 let cube_entity = commands
40 .spawn((
41 Mesh3d(meshes.add(Cuboid::from_length(2.0))),
42 MeshMaterial3d(materials.add(Color::from(ORANGE))),
43 Transform::from_translation(vec3(-6., 2., 0.)),
44 animation_target_name,
45 animation_player,
46 AnimationGraphHandle(animation_graph),
47 ))
48 .id();
49
50 commands
51 .entity(cube_entity)
52 .insert((animation_target_id, AnimatedBy(cube_entity)));
53
54 // Some light to see something
55 commands.spawn((
56 PointLight {
57 shadow_maps_enabled: true,
58 intensity: 10_000_000.,
59 range: 100.0,
60 ..default()
61 },
62 Transform::from_xyz(8., 16., 8.),
63 ));
64
65 // Ground plane
66 commands.spawn((
67 Mesh3d(meshes.add(Plane3d::default().mesh().size(50., 50.))),
68 MeshMaterial3d(materials.add(Color::from(SILVER))),
69 ));
70
71 // The camera
72 commands.spawn((
73 Camera3d::default(),
74 Transform::from_xyz(0., 6., 12.).looking_at(Vec3::new(0., 1.5, 0.), Vec3::Y),
75 ));
76}examples/math/random_sampling.rs (line 68)
51fn setup(
52 mut commands: Commands,
53 mut meshes: ResMut<Assets<Mesh>>,
54 mut materials: ResMut<Assets<StandardMaterial>>,
55) {
56 // Use seeded rng and store it in a resource; this makes the random output reproducible.
57 let seeded_rng = ChaCha8Rng::seed_from_u64(19878367467712);
58 commands.insert_resource(RandomSource(seeded_rng));
59
60 // Make a plane for establishing space.
61 commands.spawn((
62 Mesh3d(meshes.add(Plane3d::default().mesh().size(12.0, 12.0))),
63 MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
64 Transform::from_xyz(0.0, -2.5, 0.0),
65 ));
66
67 // Store the shape we sample from in a resource:
68 let shape = Cuboid::from_length(2.9);
69 commands.insert_resource(SampledShape(shape));
70
71 // The sampled shape shown transparently:
72 commands.spawn((
73 Mesh3d(meshes.add(shape)),
74 MeshMaterial3d(materials.add(StandardMaterial {
75 base_color: Color::srgba(0.2, 0.1, 0.6, 0.3),
76 alpha_mode: AlphaMode::Blend,
77 cull_mode: None,
78 ..default()
79 })),
80 ));
81
82 // A light:
83 commands.spawn((
84 PointLight {
85 shadow_maps_enabled: true,
86 ..default()
87 },
88 Transform::from_xyz(4.0, 8.0, 4.0),
89 ));
90
91 // A camera:
92 commands.spawn((
93 Camera3d::default(),
94 Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
95 ));
96
97 // Store the mesh and material for sample points in resources:
98 commands.insert_resource(PointMesh(
99 meshes.add(
100 Sphere::new(0.03)
101 .mesh()
102 .kind(SphereKind::Ico { subdivisions: 3 }),
103 ),
104 ));
105 commands.insert_resource(PointMaterial(materials.add(StandardMaterial {
106 base_color: Color::srgb(1.0, 0.8, 0.8),
107 metallic: 0.8,
108 ..default()
109 })));
110
111 // Instructions for the example:
112 commands.spawn((
113 Text::new(
114 "Controls:\n\
115 M: Toggle between sampling boundary and interior.\n\
116 R: Restart (erase all samples).\n\
117 S: Add one random sample.\n\
118 D: Add 100 random samples.\n\
119 Rotate camera by holding left mouse and panning left/right.",
120 ),
121 Node {
122 position_type: PositionType::Absolute,
123 top: px(12),
124 left: px(12),
125 ..default()
126 },
127 ));
128
129 // The mode starts with interior points.
130 commands.insert_resource(Mode::Interior);
131
132 // Starting mouse-pressed state is false.
133 commands.insert_resource(MousePressed(false));
134}tests/3d/test_meshlet.rs (line 81)
38fn setup(
39 mut commands: Commands,
40 mut standard_materials: ResMut<Assets<StandardMaterial>>,
41 mut debug_materials: ResMut<Assets<MeshletDebugMaterial>>,
42 mut meshes: ResMut<Assets<Mesh>>,
43 mut meshlets: ResMut<Assets<MeshletMesh>>,
44 mut images: ResMut<Assets<Image>>,
45) {
46 commands.spawn_scene_list(bsn_list! {
47 Camera3d
48 Transform::from_translation(Vec3::new(0.0, 1.5, -3.0))
49 .looking_at(vec3(0.0, 0.0, 1.5), Vec3::Y)
50 Msaa::Off
51 FreeCamera
52 --
53 DirectionalLight {
54 illuminance: light_consts::lux::FULL_DAYLIGHT
55 }
56 Transform::from_xyz(0.0, 1.0, -0.5).looking_at(Vec3::ZERO, Vec3::Z)
57 --
58 Text::new("M: toggle debug material")
59 Node {
60 position_type: PositionType::Absolute,
61 top: px(12),
62 left: px(12),
63 }
64 --
65 Text::new("meshlet")
66 Node {
67 position_type: PositionType::Absolute,
68 bottom: px(12),
69 left: percent(25),
70 }
71 --
72 Text::new("regular")
73 Node {
74 position_type: PositionType::Absolute,
75 bottom: px(12),
76 right: percent(25),
77 }
78 });
79
80 let sphere_mesh = Sphere::default().mesh().uv(48, 27);
81 let cube_mesh = Cuboid::from_length(0.8).mesh().build();
82
83 let sphere_meshlet = MeshletMesh::from_mesh(
84 &sphere_mesh,
85 MESHLET_DEFAULT_VERTEX_POSITION_QUANTIZATION_FACTOR,
86 )
87 .unwrap();
88
89 let cube_meshlet = MeshletMesh::from_mesh(
90 &cube_mesh,
91 MESHLET_DEFAULT_VERTEX_POSITION_QUANTIZATION_FACTOR,
92 )
93 .unwrap();
94
95 let sphere_mesh_asset = meshes.add(sphere_mesh);
96 let cube_mesh_asset = meshes.add(cube_mesh);
97
98 let sphere_meshlet_asset = meshlets.add(sphere_meshlet);
99 let cube_meshlet_asset = meshlets.add(cube_meshlet);
100
101 let mipmap_material = mipmap_material(&mut standard_materials, &mut images);
102 let debug_material = debug_materials.add(MeshletDebugMaterial::default());
103
104 for distance in [0.0, 8.0, 32.0, 128.0] {
105 commands.spawn_scene_list(bsn_list! {
106 Mesh3d({sphere_mesh_asset.clone()})
107 MeshMaterial3d::<StandardMaterial>({mipmap_material.clone()})
108 Transform::from_xyz(-0.5, 0.0, distance)
109 --
110 MeshletMesh3d({sphere_meshlet_asset.clone()})
111 MeshMaterial3d::<StandardMaterial>({mipmap_material.clone()})
112 Transform::from_xyz(0.5, 0.0, distance)
113 --
114 Mesh3d({cube_mesh_asset.clone()})
115 MeshMaterial3d::<StandardMaterial>({mipmap_material.clone()})
116 Transform::from_xyz(-1.5, 0.0, distance)
117 --
118 MeshletMesh3d({cube_meshlet_asset.clone()})
119 MeshMaterial3d::<StandardMaterial>({mipmap_material.clone()})
120 Transform::from_xyz(1.5, 0.0, distance)
121 });
122 }
123
124 commands.insert_resource(Materials {
125 mipmap: mipmap_material,
126 debug: debug_material,
127 });
128}examples/3d/solari_reflections.rs (line 190)
144fn setup(
145 mut commands: Commands,
146 asset_server: Res<AssetServer>,
147 mut meshes: ResMut<Assets<Mesh>>,
148 mut materials: ResMut<Assets<StandardMaterial>>,
149 #[cfg(all(feature = "dlss", not(feature = "force_disable_dlss")))] dlss_rr_supported: Option<
150 Res<DlssRayReconstructionSupported>,
151 >,
152) {
153 let test_material = materials.add(StandardMaterial {
154 base_color: METALLIC_BASE_COLOR,
155 metallic: 1.0,
156 perceptual_roughness: INITIAL_ROUGHNESS,
157 ..default()
158 });
159 commands.insert_resource(TestMaterial(test_material.clone()));
160
161 let mirror = materials.add(StandardMaterial {
162 base_color: Color::srgb(0.95, 0.95, 0.97),
163 metallic: 1.0,
164 perceptual_roughness: 0.0,
165 ..default()
166 });
167
168 spawn_room(&mut commands, &asset_server, &mut meshes, &mut materials);
169
170 let panel = meshes.add(raytraced(Plane3d::new(Vec3::Z, Vec2::new(2.0, 1.5))));
171 commands.spawn((
172 RaytracingMesh3d(panel.clone()),
173 Mesh3d(panel),
174 MeshMaterial3d(test_material.clone()),
175 Transform::from_xyz(MIRROR_BASE_X, 1.7, -3.0).with_rotation(mirror_rotation(0.0)),
176 PanningMirror,
177 ));
178
179 commands
180 .spawn((
181 WorldAssetRoot(asset_server.load(
182 GltfAssetLabel::Scene(0).from_asset("models/FlightHelmet/FlightHelmet.gltf"),
183 )),
184 Transform::from_xyz(4.8, 0.0, -1.6)
185 .with_scale(Vec3::splat(4.0))
186 .with_rotation(Quat::from_rotation_y(-0.4)),
187 ))
188 .observe(add_raytracing_meshes_on_scene_load);
189
190 let cube = meshes.add(raytraced(Cuboid::from_length(0.6)));
191 commands.spawn((
192 RaytracingMesh3d(cube.clone()),
193 Mesh3d(cube.clone()),
194 MeshMaterial3d(materials.add(StandardMaterial {
195 base_color: Color::srgb(0.9, 0.15, 0.05),
196 perceptual_roughness: 0.6,
197 ..default()
198 })),
199 Transform::from_xyz(3.5, 1.5, 2.5),
200 OrbitingObject,
201 ));
202
203 let moving_sphere = meshes.add(raytraced(Sphere::new(0.8).mesh().build()));
204 commands.spawn((
205 RaytracingMesh3d(moving_sphere.clone()),
206 Mesh3d(moving_sphere),
207 MeshMaterial3d(test_material),
208 Transform::from_xyz(0.0, 0.9, 3.6),
209 SlidingObject,
210 ));
211
212 let nested = meshes.add(raytraced(Plane3d::new(Vec3::Z, Vec2::new(1.3, 1.9))));
213 for (x, yaw) in [(-5.2, 1.04), (-1.8, -1.04)] {
214 commands.spawn((
215 RaytracingMesh3d(nested.clone()),
216 Mesh3d(nested.clone()),
217 MeshMaterial3d(mirror.clone()),
218 Transform::from_xyz(x, 2.0, -3.5).with_rotation(Quat::from_rotation_y(yaw)),
219 ));
220 }
221
222 commands.spawn((
223 RaytracingMesh3d(cube.clone()),
224 Mesh3d(cube),
225 MeshMaterial3d(materials.add(StandardMaterial {
226 base_color: Color::srgb(0.95, 0.75, 0.1),
227 perceptual_roughness: 0.6,
228 ..default()
229 })),
230 Transform::from_xyz(-3.5, 2.0, -4.0).with_scale(Vec3::splat(0.6)),
231 ));
232
233 let mut camera = commands.spawn((
234 Camera3d::default(),
235 Camera {
236 clear_color: ClearColorConfig::Custom(Color::BLACK),
237 ..default()
238 },
239 FreeCamera {
240 walk_speed: 3.0,
241 run_speed: 10.0,
242 ..default()
243 },
244 Transform::from_xyz(0.0, 2.8, 9.5).looking_at(Vec3::new(0.0, 1.6, -1.0), Vec3::Y),
245 Exposure::INDOOR,
246 CameraMainTextureUsages::default().with(TextureUsages::STORAGE_BINDING),
247 Msaa::Off,
248 SolariLighting::default(),
249 ));
250
251 #[cfg(all(feature = "dlss", not(feature = "force_disable_dlss")))]
252 if dlss_rr_supported.is_some() {
253 camera.insert(Dlss::<DlssRayReconstructionFeature>::default());
254 }
255 let _ = &mut camera;
256
257 spawn_ui(&mut commands);
258}Additional examples can be found in:
Sourcepub fn closest_point(&self, point: Vec3) -> Vec3
pub fn closest_point(&self, point: Vec3) -> Vec3
Finds the point on the cuboid that is closest to the given point.
If the point is outside the cuboid, the returned point will be on the surface of the cuboid. Otherwise, it will be inside the cuboid and returned as is.
Trait Implementations§
Source§impl Bounded3d for Cuboid
impl Bounded3d for Cuboid
Source§fn aabb_3d(&self, isometry: impl Into<Isometry3d>) -> Aabb3d
fn aabb_3d(&self, isometry: impl Into<Isometry3d>) -> Aabb3d
Get an axis-aligned bounding box for the shape translated and rotated by the given isometry.
Source§fn bounding_sphere(&self, isometry: impl Into<Isometry3d>) -> BoundingSphere
fn bounding_sphere(&self, isometry: impl Into<Isometry3d>) -> BoundingSphere
Get a bounding sphere for the shape translated and rotated by the given isometry.
impl Copy for Cuboid
Source§impl<'de> Deserialize<'de> for Cuboid
impl<'de> Deserialize<'de> for Cuboid
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Cuboid, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Cuboid, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromReflect for Cuboid
impl FromReflect for Cuboid
Source§fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Cuboid>
fn from_reflect(reflect: &(dyn PartialReflect + 'static)) -> Option<Cuboid>
Constructs a concrete instance of
Self from a reflected value.Source§fn take_from_reflect(
reflect: Box<dyn PartialReflect>,
) -> Result<Self, Box<dyn PartialReflect>>
fn take_from_reflect( reflect: Box<dyn PartialReflect>, ) -> Result<Self, Box<dyn PartialReflect>>
Attempts to downcast the given value to
Self using,
constructing the value using from_reflect if that fails. Read moreSource§impl GetTypeRegistration for Cuboid
impl GetTypeRegistration for Cuboid
Source§fn get_type_registration() -> TypeRegistration
fn get_type_registration() -> TypeRegistration
Returns the default
TypeRegistration for this type.Source§fn register_type_dependencies(registry: &mut TypeRegistry)
fn register_type_dependencies(registry: &mut TypeRegistry)
Registers other types needed by this type. Read more
Source§impl<Config, Clear> GizmoPrimitive3d<Cuboid> for GizmoBuffer<Config, Clear>
impl<Config, Clear> GizmoPrimitive3d<Cuboid> for GizmoBuffer<Config, Clear>
Source§type Output<'a> = ()
where
GizmoBuffer<Config, Clear>: 'a
type Output<'a> = () where GizmoBuffer<Config, Clear>: 'a
The output of
primitive_3d. This is a builder to set non-default values.Source§fn primitive_3d(
&mut self,
primitive: &Cuboid,
isometry: impl Into<Isometry3d>,
color: impl Into<Color>,
) -> <GizmoBuffer<Config, Clear> as GizmoPrimitive3d<Cuboid>>::Output<'_>
fn primitive_3d( &mut self, primitive: &Cuboid, isometry: impl Into<Isometry3d>, color: impl Into<Color>, ) -> <GizmoBuffer<Config, Clear> as GizmoPrimitive3d<Cuboid>>::Output<'_>
Renders a 3D primitive with its associated details.
Source§impl IntoReturn for Cuboid
impl IntoReturn for Cuboid
Source§impl Measured3d for Cuboid
impl Measured3d for Cuboid
Source§impl PartialReflect for Cuboid
impl PartialReflect for Cuboid
Source§fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
fn get_represented_type_info(&self) -> Option<&'static TypeInfo>
Source§fn try_apply(
&mut self,
value: &(dyn PartialReflect + 'static),
) -> Result<(), ApplyError>
fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>
Source§fn reflect_kind(&self) -> ReflectKind
fn reflect_kind(&self) -> ReflectKind
Returns a zero-sized enumeration of “kinds” of type. Read more
Source§fn reflect_ref(&self) -> ReflectRef<'_>
fn reflect_ref(&self) -> ReflectRef<'_>
Returns an immutable enumeration of “kinds” of type. Read more
Source§fn reflect_mut(&mut self) -> ReflectMut<'_>
fn reflect_mut(&mut self) -> ReflectMut<'_>
Returns a mutable enumeration of “kinds” of type. Read more
Source§fn reflect_owned(self: Box<Cuboid>) -> ReflectOwned
fn reflect_owned(self: Box<Cuboid>) -> ReflectOwned
Returns an owned enumeration of “kinds” of type. Read more
Source§fn try_into_reflect(
self: Box<Cuboid>,
) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
fn try_into_reflect( self: Box<Cuboid>, ) -> Result<Box<dyn Reflect>, Box<dyn PartialReflect>>
Attempts to cast this type to a boxed, fully-reflected value.
Source§fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
fn try_as_reflect(&self) -> Option<&(dyn Reflect + 'static)>
Attempts to cast this type to a fully-reflected value.
Source§fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
fn try_as_reflect_mut(&mut self) -> Option<&mut (dyn Reflect + 'static)>
Attempts to cast this type to a mutable, fully-reflected value.
Source§fn into_partial_reflect(self: Box<Cuboid>) -> Box<dyn PartialReflect>
fn into_partial_reflect(self: Box<Cuboid>) -> Box<dyn PartialReflect>
Casts this type to a boxed, reflected value. Read more
Source§fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
fn as_partial_reflect(&self) -> &(dyn PartialReflect + 'static)
Casts this type to a reflected value. Read more
Source§fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
fn as_partial_reflect_mut(&mut self) -> &mut (dyn PartialReflect + 'static)
Casts this type to a mutable, reflected value. Read more
Source§fn reflect_partial_eq(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<bool>
fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>
Returns a “partial equality” comparison result. Read more
Source§fn reflect_partial_cmp(
&self,
value: &(dyn PartialReflect + 'static),
) -> Option<Ordering>
fn reflect_partial_cmp( &self, value: &(dyn PartialReflect + 'static), ) -> Option<Ordering>
Returns a “partial comparison” result. Read more
Source§fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn debug(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Debug formatter for the value. Read more
Source§fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
fn reflect_clone(&self) -> Result<Box<dyn Reflect>, ReflectCloneError>
Attempts to clone
Self using reflection. Read moreSource§fn apply(&mut self, value: &(dyn PartialReflect + 'static))
fn apply(&mut self, value: &(dyn PartialReflect + 'static))
Applies a reflected value to this value. Read more
Source§fn to_dynamic(&self) -> Result<Box<dyn PartialReflect>, ReflectCloneError>
fn to_dynamic(&self) -> Result<Box<dyn PartialReflect>, ReflectCloneError>
Source§fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
fn reflect_clone_and_take<T>(&self) -> Result<T, ReflectCloneError>
For a type implementing
PartialReflect, combines reflect_clone and
take in a useful fashion, automatically constructing an appropriate
ReflectCloneError if the downcast fails.Source§fn reflect_hash(&self) -> Option<u64>
fn reflect_hash(&self) -> Option<u64>
Returns a hash of the value (which includes the type). Read more
Source§fn is_dynamic(&self) -> bool
fn is_dynamic(&self) -> bool
Indicates whether or not this type is a dynamic type. Read more
impl Primitive3d for Cuboid
Source§impl Reflect for Cuboid
impl Reflect for Cuboid
Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Returns the value as a
&mut dyn Any. Read moreSource§fn into_reflect(self: Box<Cuboid>) -> Box<dyn Reflect>
fn into_reflect(self: Box<Cuboid>) -> Box<dyn Reflect>
Casts this type to a boxed, fully-reflected value.
Source§fn as_reflect(&self) -> &(dyn Reflect + 'static)
fn as_reflect(&self) -> &(dyn Reflect + 'static)
Casts this type to a fully-reflected value.
Source§fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
fn as_reflect_mut(&mut self) -> &mut (dyn Reflect + 'static)
Casts this type to a mutable, fully-reflected value.
Source§impl Serialize for Cuboid
impl Serialize for Cuboid
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl ShapeSample for Cuboid
impl ShapeSample for Cuboid
Source§fn sample_interior<R>(&self, rng: &mut R) -> Vec3
fn sample_interior<R>(&self, rng: &mut R) -> Vec3
Uniformly sample a point from inside the area/volume of this shape, centered on 0. Read more
Source§fn sample_boundary<R>(&self, rng: &mut R) -> Vec3
fn sample_boundary<R>(&self, rng: &mut R) -> Vec3
Uniformly sample a point from the surface of this shape, centered on 0. Read more
Source§fn interior_dist(self) -> impl Distribution<Self::Output>where
Self: Sized,
fn interior_dist(self) -> impl Distribution<Self::Output>where
Self: Sized,
Extract a
Distribution whose samples are points of this shape’s interior, taken uniformly. Read moreSource§fn boundary_dist(self) -> impl Distribution<Self::Output>where
Self: Sized,
fn boundary_dist(self) -> impl Distribution<Self::Output>where
Self: Sized,
Extract a
Distribution whose samples are points of this shape’s boundary, taken uniformly. Read moreSource§impl Struct for Cuboid
impl Struct for Cuboid
Source§fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
Gets a reference to the value of the field named
name as a &dyn PartialReflect.Source§fn field_mut(
&mut self,
name: &str,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_mut( &mut self, name: &str, ) -> Option<&mut (dyn PartialReflect + 'static)>
Gets a mutable reference to the value of the field named
name as a
&mut dyn PartialReflect.Source§fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
fn field_at(&self, index: usize) -> Option<&(dyn PartialReflect + 'static)>
Gets a reference to the value of the field with index
index as a
&dyn PartialReflect.Source§fn field_at_mut(
&mut self,
index: usize,
) -> Option<&mut (dyn PartialReflect + 'static)>
fn field_at_mut( &mut self, index: usize, ) -> Option<&mut (dyn PartialReflect + 'static)>
Gets a mutable reference to the value of the field with index
index
as a &mut dyn PartialReflect.Source§fn index_of_name(&self, name: &str) -> Option<usize>
fn index_of_name(&self, name: &str) -> Option<usize>
Gets the index of the field with the given name.
Source§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
Returns an iterator over the values of the reflectable fields for this struct.
Source§fn to_dynamic_struct(&self) -> Result<DynamicStruct, ReflectCloneError>
fn to_dynamic_struct(&self) -> Result<DynamicStruct, ReflectCloneError>
Creates a new
DynamicStruct from this struct. Read moreSource§fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
fn get_represented_struct_info(&self) -> Option<&'static StructInfo>
Will return
None if TypeInfo is not available.impl StructuralPartialEq for Cuboid
Source§impl TypePath for Cuboid
impl TypePath for Cuboid
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Returns the fully qualified path of the underlying type. Read more
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Returns a short, pretty-print enabled path to the type. Read more
Source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Auto Trait Implementations§
impl Freeze for Cuboid
impl RefUnwindSafe for Cuboid
impl Send for Cuboid
impl Sync for Cuboid
impl Unpin for Cuboid
impl UnsafeUnpin for Cuboid
impl UnwindSafe for Cuboid
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
Return the
T ShaderType for self. When used in AsBindGroup
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
Source§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
See
TypePath::type_path.Source§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
Source§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
See
TypePath::type_ident.Source§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
See
TypePath::crate_name.Source§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
Source§impl<T> DynamicTyped for Twhere
T: Typed,
impl<T> DynamicTyped for Twhere
T: Typed,
Source§fn reflect_type_info(&self) -> &'static TypeInfo
fn reflect_type_info(&self) -> &'static TypeInfo
See
Typed::type_info.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self to use its UpperHex implementation when
Debug-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<S> GetField for Swhere
S: Struct,
impl<S> GetField for Swhere
S: Struct,
Source§impl<T> GetPath for T
impl<T> GetPath for T
Source§fn reflect_path<'p>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path<'p>( &self, path: impl ReflectPath<'p>, ) -> Result<&(dyn PartialReflect + 'static), ReflectPathError<'p>>
Returns a reference to the value specified by
path. Read moreSource§fn reflect_path_mut<'p>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
fn reflect_path_mut<'p>( &mut self, path: impl ReflectPath<'p>, ) -> Result<&mut (dyn PartialReflect + 'static), ReflectPathError<'p>>
Returns a mutable reference to the value specified by
path. Read moreSource§fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
fn path<'p, T>(
&self,
path: impl ReflectPath<'p>,
) -> Result<&T, ReflectPathError<'p>>where
T: Reflect,
Returns a statically typed reference to the value specified by
path. Read moreSource§fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
fn path_mut<'p, T>(
&mut self,
path: impl ReflectPath<'p>,
) -> Result<&mut T, ReflectPathError<'p>>where
T: Reflect,
Returns a statically typed mutable reference to the value specified by
path. Read moreSource§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T> HitDataExtra for T
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<G> PatchFromTemplate for Gwhere
G: FromTemplate,
impl<G> PatchFromTemplate for Gwhere
G: FromTemplate,
Source§fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
fn patch<F>(func: F) -> TemplatePatch<F, <G as PatchFromTemplate>::Template>
Takes a “patch function”
func, and turns it into a TemplatePatch.Source§impl<T> PatchTemplate for Twhere
T: Template,
impl<T> PatchTemplate for Twhere
T: Template,
Source§fn patch_template<F>(func: F) -> TemplatePatch<F, T>
fn patch_template<F>(func: F) -> TemplatePatch<F, T>
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().impl<T> Reflectable for T
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
impl<T> Settings for T
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
Uses this template and the given
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clones this template. See
Clone.Source§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of
self.