pub struct SphereMeshBuilder {
pub sphere: Sphere,
pub kind: SphereKind,
}
Fields§
§sphere: Sphere
The Sphere
shape.
kind: SphereKind
The type of sphere mesh that will be built.
Implementations§
Source§impl SphereMeshBuilder
impl SphereMeshBuilder
Sourcepub const fn new(radius: f32, kind: SphereKind) -> SphereMeshBuilder
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}
Sourcepub const fn kind(self, kind: SphereKind) -> SphereMeshBuilder
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}
Sourcepub fn ico(&self, subdivisions: u32) -> Result<Mesh, IcosphereError>
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
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}
Sourcepub fn uv(&self, sectors: u32, stacks: u32) -> Mesh
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
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}
Additional examples can be found in:
Trait Implementations§
Source§impl Clone for SphereMeshBuilder
impl Clone for SphereMeshBuilder
Source§fn clone(&self) -> SphereMeshBuilder
fn clone(&self) -> SphereMeshBuilder
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for SphereMeshBuilder
impl Debug for SphereMeshBuilder
Source§impl Default for SphereMeshBuilder
impl Default for SphereMeshBuilder
Source§fn default() -> SphereMeshBuilder
fn default() -> SphereMeshBuilder
Returns the “default value” for a type. Read more
Source§impl FromArg for &'static SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for &'static mut SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for &'static mut SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromArg for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromArg for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl FromReflect for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl FromReflect for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn from_reflect(
reflect: &(dyn PartialReflect + 'static),
) -> Option<SphereMeshBuilder>
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>>
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 GetOwnership for &SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for &mut SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for &mut SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetOwnership for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetOwnership for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§impl GetTypeRegistration for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl GetTypeRegistration for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
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 IntoReturn for &SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &SphereMeshBuilderwhere
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,
fn into_return<'into_return>(self) -> Return<'into_return>where
&SphereMeshBuilder: 'into_return,
Source§impl IntoReturn for &mut SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for &mut SphereMeshBuilderwhere
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,
fn into_return<'into_return>(self) -> Return<'into_return>where
&mut SphereMeshBuilder: 'into_return,
Source§impl IntoReturn for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl IntoReturn for SphereMeshBuilderwhere
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,
fn into_return<'into_return>(self) -> Return<'into_return>where
SphereMeshBuilder: 'into_return,
Source§impl MeshBuilder for SphereMeshBuilder
impl MeshBuilder for SphereMeshBuilder
Source§impl PartialReflect for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl PartialReflect for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
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<SphereMeshBuilder>) -> ReflectOwned
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>>
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)>
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<SphereMeshBuilder>) -> Box<dyn PartialReflect>
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)
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 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 clone_value(&self) -> Box<dyn PartialReflect>
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 moreSource§fn to_dynamic(&self) -> Box<dyn PartialReflect>
fn to_dynamic(&self) -> Box<dyn PartialReflect>
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
Source§impl Reflect for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Reflect for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn into_any(self: Box<SphereMeshBuilder>) -> Box<dyn Any>
fn into_any(self: Box<SphereMeshBuilder>) -> Box<dyn Any>
Returns the value as a
Box<dyn Any>
. Read moreSource§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<SphereMeshBuilder>) -> Box<dyn Reflect>
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)
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 Struct for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Struct for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
Source§fn field(&self, name: &str) -> Option<&(dyn PartialReflect + 'static)>
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)>
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)>
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)>
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>
fn name_at(&self, index: usize) -> Option<&str>
Returns the name of the field with index
index
.Source§fn iter_fields(&self) -> FieldIter<'_> ⓘ
fn iter_fields(&self) -> FieldIter<'_> ⓘ
Returns an iterator over the values of the reflectable fields for this struct.
fn to_dynamic_struct(&self) -> DynamicStruct
Source§fn clone_dynamic(&self) -> DynamicStruct
fn clone_dynamic(&self) -> DynamicStruct
👎Deprecated since 0.16.0: use
to_dynamic_struct
insteadClones the struct into a
DynamicStruct
.Source§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.Source§impl TypePath for SphereMeshBuilder
impl TypePath for SphereMeshBuilder
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>
Source§impl Typed for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Typed for SphereMeshBuilderwhere
SphereMeshBuilder: Any + Send + Sync,
Sphere: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
SphereKind: FromReflect + TypePath + MaybeTyped + RegisterForReflection,
impl Copy for SphereMeshBuilder
Auto Trait Implementations§
impl Freeze for SphereMeshBuilder
impl RefUnwindSafe for SphereMeshBuilder
impl Send for SphereMeshBuilder
impl Sync for SphereMeshBuilder
impl Unpin for SphereMeshBuilder
impl UnwindSafe for SphereMeshBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
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
.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> 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> 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<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<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.Source§impl<T> Pointable for T
impl<T> Pointable for T
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()
.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.