Struct bevy_mod_raycast::RaycastSource
source · pub struct RaycastSource<T> {
pub cast_method: RaycastMethod,
pub ray: Option<Ray3d>,
/* private fields */
}
Expand description
The RaycastSource
component is used to generate rays with the specified cast_method
. A ray
is generated when the RaycastSource is initialized, either by waiting for update_raycast system
to process the ray, or by using a with_ray
function.
Fields
cast_method: RaycastMethod
ray: Option<Ray3d>
Implementations
sourceimpl<T> RaycastSource<T>
impl<T> RaycastSource<T>
sourcepub fn new() -> RaycastSource<T>
pub fn new() -> RaycastSource<T>
Instantiates a RaycastSource. It will not be initialized until the update_raycast system
runs, or one of the with_ray
functions is run.
sourcepub fn with_ray_screenspace(
self,
cursor_pos_screen: Vec2,
camera: &Camera,
camera_transform: &GlobalTransform
) -> Self
pub fn with_ray_screenspace(
self,
cursor_pos_screen: Vec2,
camera: &Camera,
camera_transform: &GlobalTransform
) -> Self
Initializes a RaycastSource with a valid screenspace ray.
sourcepub fn with_ray_transform(self, transform: Mat4) -> Self
pub fn with_ray_transform(self, transform: Mat4) -> Self
Initializes a RaycastSource with a valid ray derived from a transform.
sourcepub fn new_screenspace(
cursor_pos_screen: Vec2,
camera: &Camera,
camera_transform: &GlobalTransform
) -> Self
pub fn new_screenspace(
cursor_pos_screen: Vec2,
camera: &Camera,
camera_transform: &GlobalTransform
) -> Self
Instantiates and initializes a RaycastSource with a valid screenspace ray.
sourcepub fn new_transform(transform: Mat4) -> Self
pub fn new_transform(transform: Mat4) -> Self
Initializes a RaycastSource with a valid ray derived from a transform.
sourcepub fn new_transform_empty() -> Self
pub fn new_transform_empty() -> Self
Instantiates a RaycastSource with RaycastMethod::Transform, and an empty ray. It will not be initialized until the update_raycast system is run and a [GlobalTransform] is present on this entity.
Warning
Only use this if the entity this is associated with will have its [Transform] or [GlobalTransform] specified elsewhere. If the [GlobalTransform] is not set, this ray casting source will never be able to generate a raycast.
sourcepub fn get_intersections(&self) -> Option<&[(Entity, IntersectionData)]>
pub fn get_intersections(&self) -> Option<&[(Entity, IntersectionData)]>
Get a reference to the ray cast source’s intersections, if one exists.
sourcepub fn intersections(&self) -> &[(Entity, IntersectionData)]
pub fn intersections(&self) -> &[(Entity, IntersectionData)]
Get a reference to the ray cast source’s intersections. Returns an empty list if there are no intersections.
sourcepub fn get_nearest_intersection(&self) -> Option<(Entity, &IntersectionData)>
pub fn get_nearest_intersection(&self) -> Option<(Entity, &IntersectionData)>
Get a reference to the nearest intersection point, if there is one.
sourcepub fn intersect_primitive(&self, shape: Primitive3d) -> Option<IntersectionData>
pub fn intersect_primitive(&self, shape: Primitive3d) -> Option<IntersectionData>
Run an intersection check between this RaycastSource
and a 3D primitive Primitive3d
.
sourcepub fn intersections_mut(&mut self) -> &mut Vec<(Entity, IntersectionData)>ⓘ
pub fn intersections_mut(&mut self) -> &mut Vec<(Entity, IntersectionData)>ⓘ
Get a mutable reference to the ray cast source’s intersections.
Trait Implementations
sourceimpl<T> Component for RaycastSource<T>where
Self: Send + Sync + 'static,
impl<T> Component for RaycastSource<T>where
Self: Send + Sync + 'static,
type Storage = TableStorage
Auto Trait Implementations
impl<T> RefUnwindSafe for RaycastSource<T>
impl<T> Send for RaycastSource<T>
impl<T> Sync for RaycastSource<T>
impl<T> Unpin for RaycastSource<T>
impl<T> UnwindSafe for RaycastSource<T>
Blanket Implementations
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist. Read moresourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids(
components: &mut Components,
storages: &mut Storages,
ids: &mut impl FnMut(ComponentId)
)
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Cwhere
F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,
fn get_components(self, func: &mut impl FnMut(OwningPtr<'_>))
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn 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. Read morefn 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. Read moreimpl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Self
using data from the given [World]