pub struct RingMeshBuilder<P>where
P: Primitive2d + Meshable,{
pub outer_shape_builder: <P as Meshable>::Output,
pub inner_shape_builder: <P as Meshable>::Output,
}bevy_render only.Fields§
§outer_shape_builder: <P as Meshable>::Output§inner_shape_builder: <P as Meshable>::OutputImplementations§
Source§impl<P> RingMeshBuilder<P>where
P: Primitive2d + Meshable,
impl<P> RingMeshBuilder<P>where
P: Primitive2d + Meshable,
Sourcepub fn new(ring: &Ring<P>) -> RingMeshBuilder<P>
Available on crate feature bevy_mesh only.
pub fn new(ring: &Ring<P>) -> RingMeshBuilder<P>
bevy_mesh only.Create a new RingMeshBuilder<P> from a given Ring<P> shape.
Sourcepub fn with_inner(
self,
func: impl Fn(<P as Meshable>::Output) -> <P as Meshable>::Output,
) -> RingMeshBuilder<P>
Available on crate feature bevy_mesh only.
pub fn with_inner( self, func: impl Fn(<P as Meshable>::Output) -> <P as Meshable>::Output, ) -> RingMeshBuilder<P>
bevy_mesh only.Apply a function to the inner builders
Examples found in repository?
166fn setup(
167 mut commands: Commands,
168 mut meshes: ResMut<Assets<Mesh>>,
169 mut materials: ResMut<Assets<StandardMaterial>>,
170) {
171 // Spawn the camera
172 commands.spawn((Camera3d::default(), TRANSFORM_2D, PROJECTION_2D));
173
174 // Spawn the 2D heart
175 commands.spawn((
176 // We can use the methods defined on the `MeshBuilder` to customize the mesh.
177 Mesh3d(meshes.add(HEART.mesh().resolution(50))),
178 MeshMaterial3d(materials.add(StandardMaterial {
179 emissive: RED.into(),
180 base_color: RED.into(),
181 ..Default::default()
182 })),
183 Transform::from_xyz(0.0, 0.0, 0.0),
184 Shape2d,
185 Visibility::Visible,
186 ShapeActive::Heart,
187 ));
188
189 // Spawn the 2D heart ring
190 commands.spawn((
191 // We can use the methods defined on the `MeshBuilder` to customize the mesh.
192 Mesh3d(meshes.add(RING.mesh().with_inner(|heart| heart.resolution(50)))),
193 MeshMaterial3d(materials.add(StandardMaterial {
194 emissive: RED.into(),
195 base_color: RED.into(),
196 ..Default::default()
197 })),
198 Transform::from_xyz(0.0, 0.0, 0.0),
199 Shape2d,
200 Visibility::Hidden,
201 ShapeActive::Ring,
202 ));
203
204 // Spawn an extrusion of the heart
205 commands.spawn((
206 // We can set a custom resolution for the round parts of the extrusion as well.
207 Mesh3d(meshes.add(EXTRUSION.mesh().resolution(50))),
208 MeshMaterial3d(materials.add(StandardMaterial {
209 base_color: RED.into(),
210 ..Default::default()
211 })),
212 Transform::from_xyz(0., -3., -5.).with_rotation(Quat::from_rotation_x(-PI / 4.)),
213 Shape3d,
214 Visibility::Hidden,
215 ShapeActive::Extrusion,
216 ));
217
218 // Spawn an extrusion of the heart ring
219 commands.spawn((
220 // We can set a custom resolution for the round parts of the extrusion as well.
221 Mesh3d(
222 meshes.add(
223 RING_EXTRUSION
224 .mesh()
225 .with_inner(|ring| ring.with_inner(|heart| heart.resolution(50))),
226 ),
227 ),
228 MeshMaterial3d(materials.add(StandardMaterial {
229 base_color: RED.into(),
230 ..Default::default()
231 })),
232 Transform::from_xyz(0., -3., -5.).with_rotation(Quat::from_rotation_x(-PI / 4.)),
233 Shape3d,
234 Visibility::Hidden,
235 ShapeActive::RingExtrusion,
236 ));
237
238 // Point light for 3D
239 commands.spawn((
240 PointLight {
241 shadow_maps_enabled: true,
242 intensity: 10_000_000.,
243 range: 100.0,
244 shadow_depth_bias: 0.2,
245 ..default()
246 },
247 Transform::from_xyz(8.0, 12.0, 1.0),
248 ));
249
250 let mut text = "\
251 Press 'B' to cycle between no bounding shapes, bounding boxes (AABBs) and bounding spheres / circles\n\
252 Press 'Tab' to cycle between 2D and 3D shapes\n\
253 Press 'R' to pause/resume rotation".to_string();
254 #[cfg(not(target_family = "wasm"))]
255 text.push_str("\nPress 'Space' to toggle display of wireframes");
256 // Example instructions
257 commands.spawn((
258 Text::new(text),
259 Node {
260 position_type: PositionType::Absolute,
261 top: px(12),
262 left: px(12),
263 ..default()
264 },
265 ));
266}Trait Implementations§
Source§impl<P> Extrudable for RingMeshBuilder<P>
impl<P> Extrudable for RingMeshBuilder<P>
Source§fn perimeter(&self) -> Vec<PerimeterSegment>
fn perimeter(&self) -> Vec<PerimeterSegment>
A list of the indices each representing a part of the perimeter of the mesh.
§Panics
Panics if the following assumptions are not met.
It is assumed that the inner and outer meshes have the same number of vertices.
If not, then the MeshBuilder of the underlying 2d primitive has generated
a different number of vertices for the inner and outer instances of the primitive.
It is assumed that the primitive_topology of the mesh returned by
the underlying builder is PrimitiveTopology::TriangleList
and that the mesh has Mesh::ATTRIBUTE_POSITION, Mesh::ATTRIBUTE_NORMAL and Mesh::ATTRIBUTE_UV_0 attributes.
Source§impl<P> MeshBuilder for RingMeshBuilder<P>where
P: Primitive2d + Meshable,
impl<P> MeshBuilder for RingMeshBuilder<P>where
P: Primitive2d + Meshable,
Source§fn build(&self) -> Mesh
fn build(&self) -> Mesh
Builds a Mesh based on the configuration in self.
§Panics
Panics if the following assumptions are not met.
It is assumed that the inner and outer meshes have the same number of vertices.
If not, then the MeshBuilder of the underlying 2d primitive has generated
a different number of vertices for the inner and outer instances of the primitive.
It is assumed that the primitive_topology of the mesh returned by
the underlying builder is PrimitiveTopology::TriangleList
and that the mesh has Mesh::ATTRIBUTE_POSITION, Mesh::ATTRIBUTE_NORMAL and Mesh::ATTRIBUTE_UV_0 attributes.
Auto Trait Implementations§
impl<P> Freeze for RingMeshBuilder<P>
impl<P> RefUnwindSafe for RingMeshBuilder<P>
impl<P> Send for RingMeshBuilder<P>
impl<P> Sync for RingMeshBuilder<P>
impl<P> Unpin for RingMeshBuilder<P>
impl<P> UnsafeUnpin for RingMeshBuilder<P>
impl<P> UnwindSafe for RingMeshBuilder<P>
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
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
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>
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>
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)
&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)
&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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
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,
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,
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,
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,
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,
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,
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,
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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<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,
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,
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,
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
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
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
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Settings for T
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
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
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
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
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
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
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
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
.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
.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
.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
.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
.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
.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
.tap_deref() only in debug builds, and is erased in release
builds.