Struct SphereMeshBuilder

Source
pub struct SphereMeshBuilder {
    pub sphere: Sphere,
    pub kind: SphereKind,
}
Expand description

A builder used for creating a Mesh with an Sphere shape.

Fields§

§sphere: Sphere

The Sphere shape.

§kind: SphereKind

The type of sphere mesh that will be built.

Implementations§

Source§

impl SphereMeshBuilder

Source

pub const fn new(radius: f32, kind: SphereKind) -> SphereMeshBuilder

Creates a new SphereMeshBuilder from a radius and SphereKind.

Examples found in repository?
examples/shader/extended_material_bindless.rs (lines 118-124)
110fn setup(
111    mut commands: Commands,
112    asset_server: Res<AssetServer>,
113    mut meshes: ResMut<Assets<Mesh>>,
114    mut materials: ResMut<Assets<ExtendedMaterial<StandardMaterial, ExampleBindlessExtension>>>,
115) {
116    // Create a gray sphere, modulated with a red-tinted Bevy logo.
117    commands.spawn((
118        Mesh3d(meshes.add(SphereMeshBuilder::new(
119            1.0,
120            SphereKind::Uv {
121                sectors: 20,
122                stacks: 20,
123            },
124        ))),
125        MeshMaterial3d(materials.add(ExtendedMaterial {
126            base: StandardMaterial {
127                base_color: GRAY_600.into(),
128                ..default()
129            },
130            extension: ExampleBindlessExtension {
131                modulate_color: RED.into(),
132                modulate_texture: Some(asset_server.load("textures/uv_checker_bw.png")),
133            },
134        })),
135        Transform::from_xyz(0.0, 0.5, 0.0),
136    ));
137
138    // Create a light.
139    commands.spawn((
140        DirectionalLight::default(),
141        Transform::from_xyz(1.0, 1.0, 1.0).looking_at(Vec3::ZERO, Vec3::Y),
142    ));
143
144    // Create a camera.
145    commands.spawn((
146        Camera3d::default(),
147        Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
148    ));
149}
Source

pub const fn kind(self, kind: SphereKind) -> SphereMeshBuilder

Sets the SphereKind that will be used for building the mesh.

Examples found in repository?
examples/math/random_sampling.rs (line 102)
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            shadows_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: Val::Px(12.0),
124            left: Val::Px(12.0),
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}
Source

pub fn ico(&self, subdivisions: u32) -> Result<Mesh, IcosphereError>

Creates an icosphere mesh with the given number of subdivisions.

The number of faces quadruples with each subdivision. If there are 80 or more subdivisions, the vertex count will be too large, and an IcosphereError is returned.

A good default is 5 subdivisions.

Examples found in repository?
examples/3d/reflection_probes.rs (line 123)
117fn spawn_sphere(
118    commands: &mut Commands,
119    meshes: &mut Assets<Mesh>,
120    materials: &mut Assets<StandardMaterial>,
121) {
122    // Create a sphere mesh.
123    let sphere_mesh = meshes.add(Sphere::new(1.0).mesh().ico(7).unwrap());
124
125    // Create a sphere.
126    commands.spawn((
127        Mesh3d(sphere_mesh.clone()),
128        MeshMaterial3d(materials.add(StandardMaterial {
129            base_color: Srgba::hex("#ffd891").unwrap().into(),
130            metallic: 1.0,
131            perceptual_roughness: 0.0,
132            ..StandardMaterial::default()
133        })),
134    ));
135}
More examples
Hide additional examples
examples/testbed/3d.rs (line 177)
151    pub fn setup(
152        mut commands: Commands,
153        mut meshes: ResMut<Assets<Mesh>>,
154        mut materials: ResMut<Assets<StandardMaterial>>,
155    ) {
156        commands.spawn((
157            Camera3d::default(),
158            Camera {
159                hdr: true,
160                ..default()
161            },
162            Tonemapping::TonyMcMapface,
163            Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
164            Bloom::NATURAL,
165            StateScoped(CURRENT_SCENE),
166        ));
167
168        let material_emissive1 = materials.add(StandardMaterial {
169            emissive: LinearRgba::rgb(13.99, 5.32, 2.0),
170            ..default()
171        });
172        let material_emissive2 = materials.add(StandardMaterial {
173            emissive: LinearRgba::rgb(2.0, 13.99, 5.32),
174            ..default()
175        });
176
177        let mesh = meshes.add(Sphere::new(0.5).mesh().ico(5).unwrap());
178
179        for z in -2..3_i32 {
180            let material = match (z % 2).abs() {
181                0 => material_emissive1.clone(),
182                1 => material_emissive2.clone(),
183                _ => unreachable!(),
184            };
185
186            commands.spawn((
187                Mesh3d(mesh.clone()),
188                MeshMaterial3d(material),
189                Transform::from_xyz(z as f32 * 2.0, 0.0, 0.0),
190                StateScoped(CURRENT_SCENE),
191            ));
192        }
193    }
examples/transforms/transform.rs (line 48)
41fn setup(
42    mut commands: Commands,
43    mut meshes: ResMut<Assets<Mesh>>,
44    mut materials: ResMut<Assets<StandardMaterial>>,
45) {
46    // Add an object (sphere) for visualizing scaling.
47    commands.spawn((
48        Mesh3d(meshes.add(Sphere::new(3.0).mesh().ico(32).unwrap())),
49        MeshMaterial3d(materials.add(Color::from(YELLOW))),
50        Transform::from_translation(Vec3::ZERO),
51        Center {
52            max_size: 1.0,
53            min_size: 0.1,
54            scale_factor: 0.05,
55        },
56    ));
57
58    // Add the cube to visualize rotation and translation.
59    // This cube will circle around the center_sphere
60    // by changing its rotation each frame and moving forward.
61    // Define a start transform for an orbiting cube, that's away from our central object (sphere)
62    // and rotate it so it will be able to move around the sphere and not towards it.
63    let cube_spawn =
64        Transform::from_translation(Vec3::Z * -10.0).with_rotation(Quat::from_rotation_y(PI / 2.));
65    commands.spawn((
66        Mesh3d(meshes.add(Cuboid::default())),
67        MeshMaterial3d(materials.add(Color::WHITE)),
68        cube_spawn,
69        CubeState {
70            start_pos: cube_spawn.translation,
71            move_speed: 2.0,
72            turn_speed: 0.2,
73        },
74    ));
75
76    // Spawn a camera looking at the entities to show what's happening in this example.
77    commands.spawn((
78        Camera3d::default(),
79        Transform::from_xyz(0.0, 10.0, 20.0).looking_at(Vec3::ZERO, Vec3::Y),
80    ));
81
82    // Add a light source for better 3d visibility.
83    commands.spawn((
84        DirectionalLight::default(),
85        Transform::from_xyz(3.0, 3.0, 3.0).looking_at(Vec3::ZERO, Vec3::Y),
86    ));
87}
examples/3d/occlusion_culling.rs (line 319)
284fn spawn_small_cubes(
285    commands: &mut Commands,
286    meshes: &mut Assets<Mesh>,
287    materials: &mut Assets<StandardMaterial>,
288) {
289    // Add the cube mesh.
290    let small_cube = meshes.add(Cuboid::new(
291        SMALL_CUBE_SIZE,
292        SMALL_CUBE_SIZE,
293        SMALL_CUBE_SIZE,
294    ));
295
296    // Add the cube material.
297    let small_cube_material = materials.add(StandardMaterial {
298        base_color: SILVER.into(),
299        ..default()
300    });
301
302    // Create the entity that the small cubes will be parented to. This is the
303    // entity that we rotate.
304    let sphere_parent = commands
305        .spawn(Transform::from_translation(Vec3::ZERO))
306        .insert(Visibility::default())
307        .insert(SphereParent)
308        .id();
309
310    // Now we have to figure out where to place the cubes. To do that, we create
311    // a sphere mesh, but we don't add it to the scene. Instead, we inspect the
312    // sphere mesh to find the positions of its vertices, and spawn a small cube
313    // at each one. That way, we end up with a bunch of cubes arranged in a
314    // spherical shape.
315
316    // Create the sphere mesh, and extract the positions of its vertices.
317    let sphere = Sphere::new(OUTER_RADIUS)
318        .mesh()
319        .ico(OUTER_SUBDIVISION_COUNT)
320        .unwrap();
321    let sphere_positions = sphere.attribute(Mesh::ATTRIBUTE_POSITION).unwrap();
322
323    // At each vertex, create a small cube.
324    for sphere_position in sphere_positions.as_float3().unwrap() {
325        let sphere_position = Vec3::from_slice(sphere_position);
326        let small_cube = commands
327            .spawn(Mesh3d(small_cube.clone()))
328            .insert(MeshMaterial3d(small_cube_material.clone()))
329            .insert(Transform::from_translation(sphere_position))
330            .id();
331        commands.entity(sphere_parent).add_child(small_cube);
332    }
333}
examples/ecs/error_handling.rs (line 97)
67fn setup(
68    mut commands: Commands,
69    mut meshes: ResMut<Assets<Mesh>>,
70    mut materials: ResMut<Assets<StandardMaterial>>,
71) -> Result {
72    let mut seeded_rng = ChaCha8Rng::seed_from_u64(19878367467712);
73
74    // Make a plane for establishing space.
75    commands.spawn((
76        Mesh3d(meshes.add(Plane3d::default().mesh().size(12.0, 12.0))),
77        MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
78        Transform::from_xyz(0.0, -2.5, 0.0),
79    ));
80
81    // Spawn a light:
82    commands.spawn((
83        PointLight {
84            shadows_enabled: true,
85            ..default()
86        },
87        Transform::from_xyz(4.0, 8.0, 4.0),
88    ));
89
90    // Spawn a camera:
91    commands.spawn((
92        Camera3d::default(),
93        Transform::from_xyz(-2.0, 3.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
94    ));
95
96    // Create a new sphere mesh:
97    let mut sphere_mesh = Sphere::new(1.0).mesh().ico(7)?;
98    sphere_mesh.generate_tangents()?;
99
100    // Spawn the mesh into the scene:
101    let mut sphere = commands.spawn((
102        Mesh3d(meshes.add(sphere_mesh.clone())),
103        MeshMaterial3d(materials.add(StandardMaterial::default())),
104        Transform::from_xyz(-1.0, 1.0, 0.0),
105    ));
106
107    // Generate random sample points:
108    let triangles = sphere_mesh.triangles()?;
109    let distribution = UniformMeshSampler::try_new(triangles)?;
110
111    // Setup sample points:
112    let point_mesh = meshes.add(Sphere::new(0.01).mesh().ico(3)?);
113    let point_material = materials.add(StandardMaterial {
114        base_color: Srgba::RED.into(),
115        emissive: LinearRgba::rgb(1.0, 0.0, 0.0),
116        ..default()
117    });
118
119    // Add sample points as children of the sphere:
120    for point in distribution.sample_iter(&mut seeded_rng).take(10000) {
121        sphere.with_child((
122            Mesh3d(point_mesh.clone()),
123            MeshMaterial3d(point_material.clone()),
124            Transform::from_translation(point),
125        ));
126    }
127
128    // Indicate the system completed successfully:
129    Ok(())
130}
examples/stress_tests/many_lights.rs (line 57)
44fn setup(
45    mut commands: Commands,
46    mut meshes: ResMut<Assets<Mesh>>,
47    mut materials: ResMut<Assets<StandardMaterial>>,
48) {
49    warn!(include_str!("warning_string.txt"));
50
51    const LIGHT_RADIUS: f32 = 0.3;
52    const LIGHT_INTENSITY: f32 = 1000.0;
53    const RADIUS: f32 = 50.0;
54    const N_LIGHTS: usize = 100_000;
55
56    commands.spawn((
57        Mesh3d(meshes.add(Sphere::new(RADIUS).mesh().ico(9).unwrap())),
58        MeshMaterial3d(materials.add(Color::WHITE)),
59        Transform::from_scale(Vec3::NEG_ONE),
60    ));
61
62    let mesh = meshes.add(Cuboid::default());
63    let material = materials.add(StandardMaterial {
64        base_color: DEEP_PINK.into(),
65        ..default()
66    });
67
68    // NOTE: This pattern is good for testing performance of culling as it provides roughly
69    // the same number of visible meshes regardless of the viewing angle.
70    // NOTE: f64 is used to avoid precision issues that produce visual artifacts in the distribution
71    let golden_ratio = 0.5f64 * (1.0f64 + 5.0f64.sqrt());
72
73    // Spawn N_LIGHTS many lights
74    commands.spawn_batch((0..N_LIGHTS).map(move |i| {
75        let mut rng = thread_rng();
76
77        let spherical_polar_theta_phi = fibonacci_spiral_on_sphere(golden_ratio, i, N_LIGHTS);
78        let unit_sphere_p = spherical_polar_to_cartesian(spherical_polar_theta_phi);
79
80        (
81            PointLight {
82                range: LIGHT_RADIUS,
83                intensity: LIGHT_INTENSITY,
84                color: Color::hsl(rng.gen_range(0.0..360.0), 1.0, 0.5),
85                ..default()
86            },
87            Transform::from_translation((RADIUS as f64 * unit_sphere_p).as_vec3()),
88        )
89    }));
90
91    // camera
92    match std::env::args().nth(1).as_deref() {
93        Some("orthographic") => commands.spawn((
94            Camera3d::default(),
95            Projection::from(OrthographicProjection {
96                scaling_mode: ScalingMode::FixedHorizontal {
97                    viewport_width: 20.0,
98                },
99                ..OrthographicProjection::default_3d()
100            }),
101        )),
102        _ => commands.spawn(Camera3d::default()),
103    };
104
105    // add one cube, the only one with strong handles
106    // also serves as a reference point during rotation
107    commands.spawn((
108        Mesh3d(mesh),
109        MeshMaterial3d(material),
110        Transform {
111            translation: Vec3::new(0.0, RADIUS, 0.0),
112            scale: Vec3::splat(5.0),
113            ..default()
114        },
115    ));
116}
Source

pub fn uv(&self, sectors: u32, stacks: u32) -> Mesh

Creates a UV sphere Mesh with the given number of longitudinal sectors and latitudinal stacks, aka horizontal and vertical resolution.

A good default is 32 sectors and 18 stacks.

Examples found in repository?
examples/3d/irradiance_volumes.rs (line 493)
486    fn from_world(world: &mut World) -> Self {
487        let fox_animation =
488            world.load_asset(GltfAssetLabel::Animation(1).from_asset("models/animated/Fox.glb"));
489        let (fox_animation_graph, fox_animation_node) =
490            AnimationGraph::from_clip(fox_animation.clone());
491
492        ExampleAssets {
493            main_sphere: world.add_asset(Sphere::default().mesh().uv(32, 18)),
494            fox: world.load_asset(GltfAssetLabel::Scene(0).from_asset("models/animated/Fox.glb")),
495            main_sphere_material: world.add_asset(Color::from(SILVER)),
496            main_scene: world.load_asset(
497                GltfAssetLabel::Scene(0)
498                    .from_asset("models/IrradianceVolumeExample/IrradianceVolumeExample.glb"),
499            ),
500            irradiance_volume: world.load_asset("irradiance_volumes/Example.vxgi.ktx2"),
501            fox_animation_graph: world.add_asset(fox_animation_graph),
502            fox_animation_node,
503            voxel_cube: world.add_asset(Cuboid::default()),
504            // Just use a specular map for the skybox since it's not too blurry.
505            // In reality you wouldn't do this--you'd use a real skybox texture--but
506            // reusing the textures like this saves space in the Bevy repository.
507            skybox: world.load_asset("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
508        }
509    }
More examples
Hide additional examples
examples/3d/spherical_area_lights.rs (line 42)
16fn setup(
17    mut commands: Commands,
18    mut meshes: ResMut<Assets<Mesh>>,
19    mut materials: ResMut<Assets<StandardMaterial>>,
20) {
21    // camera
22    commands.spawn((
23        Camera3d::default(),
24        Transform::from_xyz(0.2, 1.5, 2.5).looking_at(Vec3::ZERO, Vec3::Y),
25    ));
26
27    // plane
28    commands.spawn((
29        Mesh3d(meshes.add(Plane3d::default().mesh().size(100.0, 100.0))),
30        MeshMaterial3d(materials.add(StandardMaterial {
31            base_color: Color::srgb(0.2, 0.2, 0.2),
32            perceptual_roughness: 0.08,
33            ..default()
34        })),
35    ));
36
37    const COUNT: usize = 6;
38    let position_range = -2.0..2.0;
39    let radius_range = 0.0..0.4;
40    let pos_len = position_range.end - position_range.start;
41    let radius_len = radius_range.end - radius_range.start;
42    let mesh = meshes.add(Sphere::new(1.0).mesh().uv(120, 64));
43
44    for i in 0..COUNT {
45        let percent = i as f32 / COUNT as f32;
46        let radius = radius_range.start + percent * radius_len;
47
48        // sphere light
49        commands
50            .spawn((
51                Mesh3d(mesh.clone()),
52                MeshMaterial3d(materials.add(StandardMaterial {
53                    base_color: Color::srgb(0.5, 0.5, 1.0),
54                    unlit: true,
55                    ..default()
56                })),
57                Transform::from_xyz(position_range.start + percent * pos_len, 0.3, 0.0)
58                    .with_scale(Vec3::splat(radius)),
59            ))
60            .with_child(PointLight {
61                radius,
62                color: Color::srgb(0.2, 0.2, 1.0),
63                ..default()
64            });
65    }
66}
examples/3d/ssao.rs (line 63)
24fn setup(
25    mut commands: Commands,
26    mut meshes: ResMut<Assets<Mesh>>,
27    mut materials: ResMut<Assets<StandardMaterial>>,
28) {
29    commands.spawn((
30        Camera3d::default(),
31        Camera {
32            hdr: true,
33            ..default()
34        },
35        Transform::from_xyz(-2.0, 2.0, -2.0).looking_at(Vec3::ZERO, Vec3::Y),
36        Msaa::Off,
37        ScreenSpaceAmbientOcclusion::default(),
38        TemporalAntiAliasing::default(),
39    ));
40
41    let material = materials.add(StandardMaterial {
42        base_color: Color::srgb(0.5, 0.5, 0.5),
43        perceptual_roughness: 1.0,
44        reflectance: 0.0,
45        ..default()
46    });
47    commands.spawn((
48        Mesh3d(meshes.add(Cuboid::default())),
49        MeshMaterial3d(material.clone()),
50        Transform::from_xyz(0.0, 0.0, 1.0),
51    ));
52    commands.spawn((
53        Mesh3d(meshes.add(Cuboid::default())),
54        MeshMaterial3d(material.clone()),
55        Transform::from_xyz(0.0, -1.0, 0.0),
56    ));
57    commands.spawn((
58        Mesh3d(meshes.add(Cuboid::default())),
59        MeshMaterial3d(material),
60        Transform::from_xyz(1.0, 0.0, 0.0),
61    ));
62    commands.spawn((
63        Mesh3d(meshes.add(Sphere::new(0.4).mesh().uv(72, 36))),
64        MeshMaterial3d(materials.add(StandardMaterial {
65            base_color: Color::srgb(0.4, 0.4, 0.4),
66            perceptual_roughness: 1.0,
67            reflectance: 0.0,
68            ..default()
69        })),
70        SphereMarker,
71    ));
72
73    commands.spawn((
74        DirectionalLight {
75            shadows_enabled: true,
76            ..default()
77        },
78        Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, PI * -0.15, PI * -0.15)),
79    ));
80
81    commands.spawn((
82        Text::default(),
83        Node {
84            position_type: PositionType::Absolute,
85            bottom: Val::Px(12.0),
86            left: Val::Px(12.0),
87            ..default()
88        },
89    ));
90}
examples/audio/spatial_audio_3d.rs (line 29)
18fn setup(
19    mut commands: Commands,
20    asset_server: Res<AssetServer>,
21    mut meshes: ResMut<Assets<Mesh>>,
22    mut materials: ResMut<Assets<StandardMaterial>>,
23) {
24    // Space between the two ears
25    let gap = 4.0;
26
27    // sound emitter
28    commands.spawn((
29        Mesh3d(meshes.add(Sphere::new(0.2).mesh().uv(32, 18))),
30        MeshMaterial3d(materials.add(Color::from(BLUE))),
31        Transform::from_xyz(0.0, 0.0, 0.0),
32        Emitter::default(),
33        AudioPlayer::new(asset_server.load("sounds/Windless Slopes.ogg")),
34        PlaybackSettings::LOOP.with_spatial(true),
35    ));
36
37    let listener = SpatialListener::new(gap);
38    commands.spawn((
39        Transform::default(),
40        Visibility::default(),
41        listener.clone(),
42        children![
43            // left ear indicator
44            (
45                Mesh3d(meshes.add(Cuboid::new(0.2, 0.2, 0.2))),
46                MeshMaterial3d(materials.add(Color::from(RED))),
47                Transform::from_translation(listener.left_ear_offset),
48            ),
49            // right ear indicator
50            (
51                Mesh3d(meshes.add(Cuboid::new(0.2, 0.2, 0.2))),
52                MeshMaterial3d(materials.add(Color::from(LIME))),
53                Transform::from_translation(listener.right_ear_offset),
54            )
55        ],
56    ));
57
58    // light
59    commands.spawn((
60        DirectionalLight::default(),
61        Transform::from_xyz(4.0, 8.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y),
62    ));
63
64    // example instructions
65    commands.spawn((
66        Text::new(
67            "Up/Down/Left/Right: Move Listener\nSpace: Toggle Emitter Movement\nM: Toggle Mute",
68        ),
69        Node {
70            position_type: PositionType::Absolute,
71            bottom: Val::Px(12.0),
72            left: Val::Px(12.0),
73            ..default()
74        },
75    ));
76
77    // camera
78    commands.spawn((
79        Camera3d::default(),
80        Transform::from_xyz(0.0, 5.0, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
81    ));
82}
examples/3d/specular_tint.rs (line 108)
75fn setup(
76    mut commands: Commands,
77    asset_server: Res<AssetServer>,
78    app_status: Res<AppStatus>,
79    mut meshes: ResMut<Assets<Mesh>>,
80    mut standard_materials: ResMut<Assets<StandardMaterial>>,
81) {
82    // Spawns a camera.
83    commands.spawn((
84        Transform::from_xyz(-2.0, 0.0, 3.5).looking_at(Vec3::ZERO, Vec3::Y),
85        Camera {
86            hdr: true,
87            ..default()
88        },
89        Camera3d::default(),
90        Skybox {
91            image: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
92            brightness: 3000.0,
93            ..default()
94        },
95        EnvironmentMapLight {
96            diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
97            specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
98            // We want relatively high intensity here in order for the specular
99            // tint to show up well.
100            intensity: 25000.0,
101            ..default()
102        },
103    ));
104
105    // Spawn the sphere.
106    commands.spawn((
107        Transform::from_rotation(Quat::from_rotation_x(PI * 0.5)),
108        Mesh3d(meshes.add(Sphere::default().mesh().uv(32, 18))),
109        MeshMaterial3d(standard_materials.add(StandardMaterial {
110            // We want only reflected specular light here, so we set the base
111            // color as black.
112            base_color: Color::BLACK,
113            reflectance: 1.0,
114            specular_tint: Color::hsva(app_status.hue, 1.0, 1.0, 1.0),
115            // The object must not be metallic, or else the reflectance is
116            // ignored per the Filament spec:
117            //
118            // <https://google.github.io/filament/Filament.html#listing_fnormal>
119            metallic: 0.0,
120            perceptual_roughness: 0.0,
121            ..default()
122        })),
123    ));
124
125    // Spawn the help text.
126    commands.spawn((
127        Node {
128            position_type: PositionType::Absolute,
129            bottom: Val::Px(12.0),
130            left: Val::Px(12.0),
131            ..default()
132        },
133        app_status.create_text(),
134    ));
135}
examples/3d/3d_shapes.rs (line 67)
47fn setup(
48    mut commands: Commands,
49    mut meshes: ResMut<Assets<Mesh>>,
50    mut images: ResMut<Assets<Image>>,
51    mut materials: ResMut<Assets<StandardMaterial>>,
52) {
53    let debug_material = materials.add(StandardMaterial {
54        base_color_texture: Some(images.add(uv_debug_texture())),
55        ..default()
56    });
57
58    let shapes = [
59        meshes.add(Cuboid::default()),
60        meshes.add(Tetrahedron::default()),
61        meshes.add(Capsule3d::default()),
62        meshes.add(Torus::default()),
63        meshes.add(Cylinder::default()),
64        meshes.add(Cone::default()),
65        meshes.add(ConicalFrustum::default()),
66        meshes.add(Sphere::default().mesh().ico(5).unwrap()),
67        meshes.add(Sphere::default().mesh().uv(32, 18)),
68    ];
69
70    let extrusions = [
71        meshes.add(Extrusion::new(Rectangle::default(), 1.)),
72        meshes.add(Extrusion::new(Capsule2d::default(), 1.)),
73        meshes.add(Extrusion::new(Annulus::default(), 1.)),
74        meshes.add(Extrusion::new(Circle::default(), 1.)),
75        meshes.add(Extrusion::new(Ellipse::default(), 1.)),
76        meshes.add(Extrusion::new(RegularPolygon::default(), 1.)),
77        meshes.add(Extrusion::new(Triangle2d::default(), 1.)),
78    ];
79
80    let num_shapes = shapes.len();
81
82    for (i, shape) in shapes.into_iter().enumerate() {
83        commands.spawn((
84            Mesh3d(shape),
85            MeshMaterial3d(debug_material.clone()),
86            Transform::from_xyz(
87                -SHAPES_X_EXTENT / 2. + i as f32 / (num_shapes - 1) as f32 * SHAPES_X_EXTENT,
88                2.0,
89                Z_EXTENT / 2.,
90            )
91            .with_rotation(Quat::from_rotation_x(-PI / 4.)),
92            Shape,
93        ));
94    }
95
96    let num_extrusions = extrusions.len();
97
98    for (i, shape) in extrusions.into_iter().enumerate() {
99        commands.spawn((
100            Mesh3d(shape),
101            MeshMaterial3d(debug_material.clone()),
102            Transform::from_xyz(
103                -EXTRUSION_X_EXTENT / 2.
104                    + i as f32 / (num_extrusions - 1) as f32 * EXTRUSION_X_EXTENT,
105                2.0,
106                -Z_EXTENT / 2.,
107            )
108            .with_rotation(Quat::from_rotation_x(-PI / 4.)),
109            Shape,
110        ));
111    }
112
113    commands.spawn((
114        PointLight {
115            shadows_enabled: true,
116            intensity: 10_000_000.,
117            range: 100.0,
118            shadow_depth_bias: 0.2,
119            ..default()
120        },
121        Transform::from_xyz(8.0, 16.0, 8.0),
122    ));
123
124    // ground plane
125    commands.spawn((
126        Mesh3d(meshes.add(Plane3d::default().mesh().size(50.0, 50.0).subdivisions(10))),
127        MeshMaterial3d(materials.add(Color::from(SILVER))),
128    ));
129
130    commands.spawn((
131        Camera3d::default(),
132        Transform::from_xyz(0.0, 7., 14.0).looking_at(Vec3::new(0., 1., 0.), Vec3::Y),
133    ));
134
135    #[cfg(not(target_arch = "wasm32"))]
136    commands.spawn((
137        Text::new("Press space to toggle wireframes"),
138        Node {
139            position_type: PositionType::Absolute,
140            top: Val::Px(12.0),
141            left: Val::Px(12.0),
142            ..default()
143        },
144    ));
145}

Trait Implementations§

Source§

impl Clone for SphereMeshBuilder

Source§

fn clone(&self) -> SphereMeshBuilder

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SphereMeshBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for SphereMeshBuilder

Source§

fn default() -> SphereMeshBuilder

Returns the “default value” for a type. Read more
Source§

impl FromArg for &'static SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg SphereMeshBuilder

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static SphereMeshBuilder as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromArg for &'static mut SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = &'from_arg mut SphereMeshBuilder

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<&'static mut SphereMeshBuilder as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromArg for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

type This<'from_arg> = SphereMeshBuilder

The type to convert into. Read more
Source§

fn from_arg( arg: Arg<'_>, ) -> Result<<SphereMeshBuilder as FromArg>::This<'_>, ArgError>

Creates an item from an argument. Read more
Source§

impl FromReflect for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn from_reflect( reflect: &(dyn PartialReflect + 'static), ) -> Option<SphereMeshBuilder>

Constructs a concrete instance of Self from a reflected value.
Source§

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 more
Source§

impl GetOwnership for &SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for &mut SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetOwnership for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn ownership() -> Ownership

Returns the ownership of Self.
Source§

impl GetTypeRegistration for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn get_type_registration() -> TypeRegistration

Returns the default TypeRegistration for this type.
Source§

fn register_type_dependencies(registry: &mut TypeRegistry)

Registers other types needed by this type. Read more
Source§

impl IntoReturn for &SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &SphereMeshBuilder: 'into_return,

Converts Self into a Return value.
Source§

impl IntoReturn for &mut SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where &mut SphereMeshBuilder: 'into_return,

Converts Self into a Return value.
Source§

impl IntoReturn for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_return<'into_return>(self) -> Return<'into_return>
where SphereMeshBuilder: 'into_return,

Converts Self into a Return value.
Source§

impl MeshBuilder for SphereMeshBuilder

Source§

fn build(&self) -> Mesh

Builds a Mesh according to the configuration in self.

§Panics

Panics if the sphere is a SphereKind::Ico with a subdivision count that is greater than or equal to 80 because there will be too many vertices.

Source§

impl PartialReflect for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn get_represented_type_info(&self) -> Option<&'static TypeInfo>

Returns the TypeInfo of the type represented by this value. Read more
Source§

fn try_apply( &mut self, value: &(dyn PartialReflect + 'static), ) -> Result<(), ApplyError>

Tries to apply a reflected value to this value. Read more
Source§

fn reflect_kind(&self) -> ReflectKind

Returns a zero-sized enumeration of “kinds” of type. Read more
Source§

fn reflect_ref(&self) -> ReflectRef<'_>

Returns an immutable enumeration of “kinds” of type. Read more
Source§

fn reflect_mut(&mut self) -> ReflectMut<'_>

Returns a mutable enumeration of “kinds” of type. Read more
Source§

fn reflect_owned(self: Box<SphereMeshBuilder>) -> ReflectOwned

Returns an owned enumeration of “kinds” of type. Read more
Source§

fn try_into_reflect( self: Box<SphereMeshBuilder>, ) -> 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)>

Attempts to cast this type to a fully-reflected value.
Source§

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<SphereMeshBuilder>) -> Box<dyn PartialReflect>

Casts this type to a boxed, reflected value. Read more
Source§

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)

Casts this type to a mutable, reflected value. Read more
Source§

fn reflect_partial_eq( &self, value: &(dyn PartialReflect + 'static), ) -> Option<bool>

Returns a “partial equality” comparison result. Read more
Source§

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>

Attempts to clone Self using reflection. Read more
Source§

fn apply(&mut self, value: &(dyn PartialReflect + 'static))

Applies a reflected value to this value. Read more
Source§

fn clone_value(&self) -> Box<dyn PartialReflect>

👎Deprecated since 0.16.0: to clone reflected values, prefer using reflect_clone. To convert reflected values to dynamic ones, use to_dynamic.
Clones Self into its dynamic representation. Read more
Source§

fn to_dynamic(&self) -> Box<dyn PartialReflect>

Converts this reflected value into its dynamic representation based on its kind. Read more
Source§

fn reflect_hash(&self) -> Option<u64>

Returns a hash of the value (which includes the type). Read more
Source§

fn is_dynamic(&self) -> bool

Indicates whether or not this type is a dynamic type. Read more
Source§

impl Reflect for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn into_any(self: Box<SphereMeshBuilder>) -> Box<dyn Any>

Returns the value as a Box<dyn Any>. Read more
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns the value as a &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Returns the value as a &mut dyn Any. Read more
Source§

fn into_reflect(self: Box<SphereMeshBuilder>) -> Box<dyn Reflect>

Casts this type to a boxed, fully-reflected value.
Source§

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)

Casts this type to a mutable, fully-reflected value.
Source§

fn set(&mut self, value: Box<dyn Reflect>) -> Result<(), Box<dyn Reflect>>

Performs a type-checked assignment of a reflected value to this value. Read more
Source§

impl Struct for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>

Returns 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)>

Returns 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)>

Returns 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)>

Returns a mutable reference to the value of the field with index index as a &mut dyn PartialReflect.
Source§

fn name_at(&self, index: usize) -> Option<&str>

Returns the name of the field with index index.
Source§

fn field_len(&self) -> usize

Returns the number of fields in the struct.
Source§

fn iter_fields(&self) -> FieldIter<'_>

Returns an iterator over the values of the reflectable fields for this struct.
Source§

fn to_dynamic_struct(&self) -> DynamicStruct

Source§

fn clone_dynamic(&self) -> DynamicStruct

👎Deprecated since 0.16.0: use to_dynamic_struct instead
Clones the struct into a DynamicStruct.
Source§

fn get_represented_struct_info(&self) -> Option<&'static StructInfo>

Will return None if TypeInfo is not available.
Source§

impl TypePath for SphereMeshBuilder

Source§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
Source§

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>

Returns the name of the type, or None if it is anonymous. Read more
Source§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
Source§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
Source§

impl Typed for SphereMeshBuilder
where SphereMeshBuilder: Any + Send + Sync, Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection, SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,

Source§

fn type_info() -> &'static TypeInfo

Returns the compile-time info for the underlying type.
Source§

impl Copy for SphereMeshBuilder

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

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> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

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 T
where T: Any,

Source§

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>

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)

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)

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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynamicTypePath for T
where T: TypePath,

Source§

impl<T> DynamicTyped for T
where T: Typed,

Source§

impl<T> FmtForward for T

Source§

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,

Causes self to use its Display implementation when Debug-formatted.
Source§

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,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

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,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

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,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> FromWorld for T
where T: Default,

Source§

fn from_world(_world: &mut World) -> T

Creates Self using default().

Source§

impl<S> GetField for S
where S: Struct,

Source§

fn get_field<T>(&self, name: &str) -> Option<&T>
where T: Reflect,

Returns a reference to the value of the field named name, downcast to T.
Source§

fn get_field_mut<T>(&mut self, name: &str) -> Option<&mut T>
where T: Reflect,

Returns a mutable reference to the value of the field named name, downcast to T.
Source§

impl<T> GetPath for T
where T: Reflect + ?Sized,

Source§

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 more
Source§

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 more
Source§

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 more
Source§

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 more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where 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) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

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
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

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
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

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().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

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

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
where Self: Borrow<B>, B: ?Sized,

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
where Self: BorrowMut<B>, B: ?Sized,

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
where Self: AsRef<R>, R: ?Sized,

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
where Self: AsMut<R>, R: ?Sized,

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
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ConditionalSend for T
where T: Send,

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Reflectable for T

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,